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.

Conflicting rules: comma-spacing & array-bracket-spacing

See original GitHub issue

Tell 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"
    ]
  }
}

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

github_iconTop GitHub Comments

2reactions
platinumazurecommented, Dec 23, 2017

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).

1reaction
michaelficarracommented, Dec 27, 2017

You can just omit the trailing comma, no?

Read more comments on GitHub >

github_iconTop 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 >

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