Home > Back-end >  how to allow semicolon in Eslint?? Anybody know please help me out
how to allow semicolon in Eslint?? Anybody know please help me out

Time:08-27

i just install Eslint to pretify my code , but it give me error of Extra semicolon in the end anybody know how to disable this rule?? i think semicolon in the end is nenecessary.

.eslintrc.json

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "plugin:react/recommended",
        "standard-with-typescript"
    ],
    "overrides": [
    ],
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module",
        "project":"./tsconfig.json"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "semi": [2, "always"],
       
        "quotes":[
        "error",
        "double",
        {
            "avoidEscape":true
        }
    ],
    "@typescript-eslint/quotes":[
        "error",
        "double",
        {
            "avoidEscape":true
        }
    ]
    }
}

ERROR

CodePudding user response:

The error is from the @typescript-eslint/semi rule (different from just semi). Disable the semi rule and set the options on the typescript rule instead:

{
  "semi": "off",
  "@typescript-eslint/semi": [2, "always"],
}

CodePudding user response:

Add "no-extra-semi":"off" to rules:

{
   "env":{
      "browser":true,
      "es2021":true
   },
   "extends":[
      "plugin:react/recommended",
      "standard-with-typescript"
   ],
   "overrides":[
      
   ],
   "parserOptions":{
      "ecmaVersion":"latest",
      "sourceType":"module",
      "project":"./tsconfig.json"
   },
   "plugins":[
      "react"
   ],
   "rules":{
      "no-extra-semi":"off",
      "quotes":[
         "error",
         "double",
         {
            "avoidEscape":true
         }
      ],
      "@typescript-eslint/quotes":[
         "error",
         "double",
         {
            "avoidEscape":true
         }
      ]
   }
}
  • Related