rdio / jsfmt

For formatting, searching, and rewriting JavaScript.
http://rdio.github.io/jsfmt/
Other
1.69k stars 71 forks source link

using a custom wildcard matching function #167

Open sylvainpolletvillard opened 8 years ago

sylvainpolletvillard commented 8 years ago

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 commented 8 years ago

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:

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

sylvainpolletvillard commented 8 years ago

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.