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

using a custom wildcard matching function #167

Open
sylvainpolletvillard opened this issue Sep 29, 2015 · 2 comments
Open

using a custom wildcard matching function #167

sylvainpolletvillard opened this issue Sep 29, 2015 · 2 comments

Comments

@sylvainpolletvillard
Copy link

Hello,

I want to use jsfmt to search for t("label") calls in some JavaScript files, but it looks like t is considered to be a wildcard:

function isWildcard(node) { return node.type == "Identifier" && /^[a-z]$/.test(node.name); }

Is it possible to configure / override this isWildcard function ?
Thanks

@jimfleming
Copy link
Contributor

Hmm, good point. I guess Go users don't run into this (single-letter wildcards is a nice convention borrowed from gofmt). Some initial thoughts below but this will require some discussion to change:

  • Maybe a postfix like a* would be a wildcard? Though that might conflict with a*=1.
  • We could inline the regex into the query like jsfmt -s "/^[a-z]$/ -> b".
  • A simple quick-fix might be to add a flag for disabling wildcards entirely (i.e. --no-wildcards).

EDIT: We could also exclude some letters from matching as a wildcard: --not-wildcard=t

@sylvainpolletvillard
Copy link
Author

Thank you for your prompt response.

Any of these solutions will do the job (except the --no-wildcards, as I need them here). My personal preference would be to be able to explicitely pass a list of wildcards instead of the default naming convention.

sylvainpolletvillard added a commit to sylvainpolletvillard/jsfmt that referenced this issue Oct 14, 2015
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

No branches or pull requests

2 participants