max-len ignorePattern should set 'i' and 'u' flags on the RegEx
See original GitHub issueI think the ignorePattern
flag on max-len
should set both the unicode and case-insensitive flags. This would simplify the process of writing a RegEx to match things like TODO-style comments and other special characters.
What rule do you want to change?
max-len
Does this change cause the rule to produce more or fewer warnings? Fewer
How will the change be implemented? (New option, new default behavior, etc.)? New default behavior.
Please provide some example code that this change will affect:
'max-len': [
'warn',
{
code: 100,
ignorePattern: '((?:\\/\\/|\\/\\*)\\s*eslint-|(?:\\/\\/|\\/\\*)\\s*(?:@?(?:todo|TODO|fix|FIX|bug|BUG)))',
},
],
What does the rule currently do for this code?
If you want to use the ignorePattern
option, you must specify all possible permutations of upper and lower case characters
What will the rule do after it’s changed? The example above could be written as:
'max-len': [
'warn',
{
code: 100,
ignorePattern: '((?:\\/\\/|\\/\\*)\\s*eslint-|(?:\\/\\/|\\/\\*)\\s*(?:@?(?:todo|fix|bug)))',
},
],
Are you willing to submit a pull request to implement this change? Certainly
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
What about adding
ignorePatternFlags: ["u", "i"]
? Then it’d default to[]
, and users could provide any regex flags they want (it’d ofc have to be an array of'gimsuy'.split()
to be valid)there is a proposal: https://github.com/eslint/eslint/issues/11318 (not accepted yet), might address the issue.