Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to disable eslint rule semi?

Writer Mia Lopez

I have a TypeScript project linted with ESLint and typescript-eslint. Here's the rules property in .eslintrc.json:

"rules": { "semi": [ "error", "never" ], "@typescript-eslint/semi": ["error", "never"]
}

I have a tsx file, where the last line of the file is

export default Main 

When I run

npx eslint file.tsx

I get this error:

number last string.20 error Missing semicolon
@typescript-eslint/semi

Full .eslintrc.json:

{ "env": { "browser": true, "es2021": true }, "extends": [ "plugin:react/recommended", "xo" ], "overrides": [ { "extends": [ "xo-typescript" ], "files": [ "*.ts", "*.tsx" ] } ], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "plugins": [ "react", "@typescript-eslint" ], "rules": { "semi": [ "error", "never" ], "@typescript-eslint/semi": ["error", "never"] }
}

How to correctly disable semi rules?

2

2 Answers

Use "off":

{ "env": { "browser": true, "es2021": true }, "extends": [ "plugin:react/recommended", "xo" ], "overrides": [ { "extends": [ "xo-typescript" ], "files": [ "*.ts", "*.tsx" ] } ], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "plugins": [ "react", "@typescript-eslint" ], "rules": { "semi": "off", "@typescript-eslint/semi": "off" }
}
1

I don't know why the rules didn't work when using

 "extends": [ "xo" ],

so i reinstalled using the command

npx eslint --init

only this time at the end chose

"extends": [ "plugin:react/recommended", "standard-with-typescript" ],

so the whole file ".eslintrc.json" looks like

{ "env": { "browser": true, "es2021": true }, "extends": [ "plugin:react/recommended", "standard-with-typescript" ], "overrides": [ ], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module", "project": "./tsconfig.json" }, "plugins": [ "react" ], "rules": { "eol-last": 0, "no-multiple-empty-lines": [ "error", { "max": 1, "maxEOF": 0 } ], "@typescript-eslint/space-before-function-paren": [ "error", { "anonymous": "never", "named": "never", "asyncArrow": "never" } ], "@typescript-eslint/no-floating-promises": 0 }
}

in these rules by default is ignored semi.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.