I'm trying to ignore import statements with the ESLint "max-len" rule and some ES6 code. My rule set is written in a config in index.js
and the config for the rule itself looks like this:
'max-len': [
2,
80,
4,
{
ignoreUrls: true,
ignorePattern: /^import\s.+\sfrom\s.+;$/
}
],
Lines exceeding 80 characters still trigger errors given the RegExp I've provided. Is there something I'm not understanding about the rule itself?
I've also tried simpler RegExps and passing RegExp strings such as:
'^import.*'
Found here: http://eslint.org/docs/rules/max-len
This rule has a number or object option: "code" (default 80 ) enforces a maximum line length. "tabWidth" (default 4 ) specifies the character width for tab characters. "comments" enforces a maximum line length for comments; defaults to value of code.
I was having trouble with this as well, but @loganfsmyth's suggestion worked for me. I'm using v3.14.0 and all my rules are in an .eslintrc
file:
{
...
"rules": {
"max-len": [1, 80, 2, {
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
"ignoreUrls": true
}],
...
},
}
Similar to loganfsmyth's comment and ericgio's answer, but without double-escaping, this worked for me with yaml:
rules:
...
max-len:
- error
- code: 80
tabWidth: 2
ignorePattern: ^import\s.+\sfrom\s.+;$
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With