Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module.exports is not matched #10

Open
ghost opened this issue Jun 27, 2018 · 5 comments · May be fixed by #26
Open

module.exports is not matched #10

ghost opened this issue Jun 27, 2018 · 5 comments · May be fixed by #26

Comments

@ghost
Copy link

ghost commented Jun 27, 2018

The following function is not matched:

module.exports = function sum (a, b) {
  return a + b
}

I've done a rule to match that case as a function, but don't know if you didn't want to support on purpose since this is also the case for export default function name1(…) { … } as you pointed out on issue #7.
Wouldn't make sense to create an default export tag type and put them together on that new tag type? What do you think?
(We could try to create a rule only for default named exports with body definition once the ones that doesn't have definition would be already taken by another rules)

@romainl
Copy link
Owner

romainl commented Jun 28, 2018

This could be an extension of the function rules, I think. Something like:

--regex-javascript=/^[ \t]*module\.exports[ \t]*=[ \t]*function[ \t]\{1,\}\([a-z][A-Za-z0-9_$]\{1,\}\)/\1/F,Function,Functions/b

@ghost
Copy link
Author

ghost commented Jul 2, 2018

nice! I think this could work. Any plans to update the master branch?

@romainl
Copy link
Owner

romainl commented Jul 2, 2018

I don't think I'll be able to do it in the short term. Could you give it a try on your side?

@filmaj
Copy link

filmaj commented Apr 21, 2019

So I added the following to the bottom of my ~/.ctags file as @romainl recommended, right after the options file import, so my ~/.ctags looks like:

➜ cat ~/.ctags
--exclude=.git
--exclude=.hg
--exclude=log
--exclude=tmp
--exclude=node_modules
--exclude=gulp
--options=/Users/maj/src/dotfiles/ctags-patterns-for-javascript/ctagsrc
--regex-javascript=/^[ \t]*module\.exports[ \t]*=[ \t]*function[ \t]\{1,\}\([a-z][A-Za-z0-9_$]\{1,\}\)/\1/F,Function,Functions/b

... and can confirm it works well! This was the one thing missing for me to have full tag support, as far as I can tell, for JS in my vim. Thanks! I'll send a PR to add to the file in case that's helpful.

filmaj added a commit to filmaj/ctags-patterns-for-javascript that referenced this issue Apr 21, 2019
@filmaj filmaj linked a pull request Apr 21, 2019 that will close this issue
filmaj added a commit to filmaj/ctags-patterns-for-javascript that referenced this issue Apr 22, 2019
@cilindrox
Copy link

Thanks for this - tossing in another possible scenario for the module.exports:

exports = module.exports = /*<function or object>*/;

LMK if there's anything I can do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants