question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

max-len ignorePattern should set 'i' and 'u' flags on the RegEx

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ljharbcommented, Jan 18, 2019

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)

1reaction
aladdin-addcommented, Feb 19, 2019

there is a proposal: https://github.com/eslint/eslint/issues/11318 (not accepted yet), might address the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Patterns and flags - The Modern JavaScript Tutorial
A regular expression consists of a pattern and optional flags: g , i , m , u , s , y . ·...
Read more >
How to set ignorecase flag for part of regular expression in ...
3 Answers 3 · 1. match clearly isn't the right method -- and if you switch to search , since you don't loop...
Read more >
RegEx flags in patterns are not honored when checking ...
Spectral does not complain about the flags (or slashes) themselves but does not honor them when checking examples. Expected behavior. Honor ...
Read more >
Chapter 3, "Linux Commands"
This chapter presents the Linux user, programmer, and system administration commands. Each entry is labeled with the command name on the outer edge...
Read more >
re — Regular expression operations — Python 3.11.1 ...
A regular expression (or RE) specifies a set of strings that matches it; the functions in this ... Flags should be used first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found