I am looking for an exception to the no-undef
rule that will permit undeclared globals matching a naming rule. In this case, a regex like [A-Z][a-z]*Model
should be allowed, so "CustomerModel" and "PatientModel" would all be allowed, because it's too cumbersome to place /* global CustomerModel */ in every unit and too cumbersome to list every *Model
global even in the eslint global configuration.
I would like to have a rule like this:
"rules": {
"no-undef": [2, "[A-Z][a-z]*Model"],
Where the above syntax is invented by me and I hope obviously means "only complain when the above reg-expression name is not matched."
Alternatively if there is a way to specify regular expression matching in the .eslintrc file globals list.
/[A-Z][a-z]*Model/
regex syntax work? – ssuberequire
, so you can often use a JS file instead of JSON. It's great for returning different configs if you do theenv == PROD
thing from Rails, but obviously allows real RegExps as well. It's just a matter of whether the consuming tool will recognize and use them. – ssube