Conflicting rules: comma-spacing & array-bracket-spacing
See original GitHub issueTell us about your environment
- ESLint Version: 4.13.1
- Node Version: 6.12.2
- npm Version: 3.10.10
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
{
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"brace-style": [
"error",
"1tbs"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"space-in-parens": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"array-bracket-spacing": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"never"
],
"no-unused-vars": [
"error",
{
"args": "none"
}
],
"strict": [
"error",
"global"
],
"array-bracket-newline": [
"error",
{
"multiline": true
}
],
"implicit-arrow-linebreak": [
"error",
"beside"
]
}
}
"comma-spacing": ["error", {"before": false, "after": true}]
"array-bracket-spacing": ["error", "never"]
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
let [, b,] = [1, 2, 3];
eslint .
What did you expect to happen?
For the linting to succeed because it followed the comma-spacing rule but then I realized the conflict. If run with --fix
, it is not fixed because of the conflicting rules.
What actually happened? Please include the actual, raw output from ESLint.
array-bracket-spacing
requires there to be no space before the close bracket in the destruction but comma-spacing
requires there to be a space after the final comma in the destruction. Therefore, a conflict occurs.
~/conflict.js
3:9 error A space is required after ',' comma-spacing
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
comma-spacing - ESLint - Pluggable JavaScript Linter
comma-spacing ... This rule enforces consistent spacing before and after commas in variable ... to avoid conflicts with the array-bracket-spacing rule ...
Read more >How to replace Prettier by ESLint rules ? | by Florian Briand
It can address things like rewriting code where lines are over 80 characters, handling trailing commas or semicolons, … ESLint, as a linter, ......
Read more >eslint/eslint - Gitter
Is eslint allowed to have conflicting rules? ... array-bracket-spacing requires there to be no space before the close bracket in the destruction but ......
Read more >comma-spacing - Rules - ESLint中文文档
Enforces spacing around commas (comma-spacing) ... adjacent null elements; an initial null element, to avoid conflicts with the array-bracket-spacing rule ...
Read more >Prettier doesn't format based on my eslint config - Stack Overflow
eslintrc.js and my default formatter (Eslint-prettier) doesn't format according to my eslint rules. For example: when i type npm run eslint ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure if this would be a bug or enhancement request, but I think it would make sense for array-bracket-spacing to control here and for comma-spacing to focus on commas between items in a list only (rather than commas between the last list item and the closing token).
You can just omit the trailing comma, no?