max-len - ignoreStrings / ignoreTemplateLiterals too aggressive
See original GitHub issue- **ESLint Version: 3.16.1
- **Node Version:6.6.0
- **npm Version:3.10.3
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
{
"parser": "babel-eslint",
"extends": [
"airbnb"
],
"plugins": [
"no-unused-vars-rest"
],
"env": {
"browser": true,
"jest": true
},
"globals": {
"__DEV__": true,
"__PROD__": true,
"__DEBUG__": true,
"__COVERAGE__": true,
"__BASENAME__": true
},
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack/webpack.config.js"
}
}
},
"rules": {
"arrow-parens": [2, "always"],
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
}],
"import/no-extraneous-dependencies": [2, {"devDependencies": ["**/*.test.js", "**/*.stories.js"]}],
"no-console": 2,
"react/jsx-boolean-value": [2, "always"],
"react/jsx-filename-extension": [2, {"extensions": [".js", ".jsx"]}]
}
}
What did you do? Please include the actual source code causing the issue. Created line
const date = this.props.intl.formatDate(new Date(), { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: 'UTC' });
which has about 180 signs.
What did you expect to happen?
Show error, as default setting is set to 100 signs. Yet no error.
What actually happened?
No error was shown, because “ignoreStrings”/“ignoreTemplateLiterals” is set to true. That’s fantastic settings, as partitioning template literals isn’t quite good code for me. But now this setting is too aggressive and ignores line like the one inserted before. There are strings, but I don’t think that’s enough not to parse this line.
Unfortunatelly I have no idea how to make it less aggressive, so that lines that contains ie. objects with string values could still be parsed. 😦
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:8 (8 by maintainers)
Top GitHub Comments
Thank you for your issue!
I’m not very familiar with the ignoreStrings / ignoreTemplateLiterals implementation. My guess is that it looks for any
Literal
orTemplateLiteral
nodes in the line and if found, disables the maxlen warning for that line. I wonder if it would make sense to fine-tune it to only disable the warning if the last token is aLiteral
orTemplateLiteral
…Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.