最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ESLint turn off semicolon rule - Stack Overflow

programmeradmin1浏览0评论

When I search for turning off semicolon, I get "semi": 0 or similar I tried to putting it, but still my linter puts semicolon on lines.

Below is my .eslintrc and I am perplexed which rule is putting semicolon.

{
  "parserOptions": {
    "ecmaVersion": 8,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true
    },
    "sourceType": "module"
  },

  "plugins": [
    "react"
  ],

  "rules": {
    "jsx-quotes": ["error", "prefer-single"],
    "react/jsx-boolean-value": "error",
    "react/jsx-curly-spacing": ["error", "never"],
    "react/jsx-equals-spacing": ["error", "never"],
    "react/jsx-indent": ["error", 2],
    "react/jsx-indent-props": ["error", 2],
    "react/jsx-no-duplicate-props": "error",
    "react/jsx-no-undef": "error",
    "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
    "react/jsx-uses-react": "error",
    "react/jsx-uses-vars": "error",
    "react/self-closing-comp": "error",
    "no-console": 0,
    "semi": 0
  }
}

When I search for turning off semicolon, I get "semi": 0 or similar I tried to putting it, but still my linter puts semicolon on lines.

Below is my .eslintrc and I am perplexed which rule is putting semicolon.

{
  "parserOptions": {
    "ecmaVersion": 8,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true
    },
    "sourceType": "module"
  },

  "plugins": [
    "react"
  ],

  "rules": {
    "jsx-quotes": ["error", "prefer-single"],
    "react/jsx-boolean-value": "error",
    "react/jsx-curly-spacing": ["error", "never"],
    "react/jsx-equals-spacing": ["error", "never"],
    "react/jsx-indent": ["error", 2],
    "react/jsx-indent-props": ["error", 2],
    "react/jsx-no-duplicate-props": "error",
    "react/jsx-no-undef": "error",
    "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
    "react/jsx-uses-react": "error",
    "react/jsx-uses-vars": "error",
    "react/self-closing-comp": "error",
    "no-console": 0,
    "semi": 0
  }
}
Share Improve this question edited Dec 1, 2019 at 2:57 eugene asked Nov 30, 2019 at 15:39 eugeneeugene 41.7k76 gold badges276 silver badges532 bronze badges 8
  • Are you using Visual Studio Code? If so you probably need to configure it so it can understand what your es-lint says. – Izio Commented Nov 30, 2019 at 15:41
  • 2 Make sure prettier also has the "semi": false rule set – Volper Commented Nov 30, 2019 at 15:42
  • Your IDE can use separate .eslintrc file, I working from terminal and often see problems with eslint after commits from other devs. Run eslint as npm script in terminal and check if it still looking for semi rule. – Ivan Cherviakov Commented Nov 30, 2019 at 15:48
  • Linting and formatting are not the same thing, are you using prettier to format in VSCode? – cinnaroll45 Commented Nov 30, 2019 at 15:57
  • I run eslint --print-config my-file.js and it has ` "semi": [ 0 ]` I'm on emacs, – eugene Commented Dec 1, 2019 at 2:59
 |  Show 3 more comments

1 Answer 1

Reset to default 15

Try to add this rule: "semi": [ "error", "never" ]

If still not fixed, the problem may be that prettier(if you installed) or editor is controlling it.

Go at vscode settings and add

"eslint.autoFixOnSave": true,
发布评论

评论列表(0)

  1. 暂无评论