I'm trying to convert to @typescript-eslint
but the documentation seems sorely lacking. For example, I'm getting errors like this:
Line 58: Expected a semicolon @typescript-eslint/member-delimiter-style
I want to enforce no semicolons or commas. I found the documentation for that rule. https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-delimiter-style.md
But it doesn't seem to give any examples of how to configure it in a real eslint file! Anyone know how?
Usage. Add @typescript-eslint/parser to the parser field and @typescript-eslint to the plugins section of your . eslintrc configuration file, then configure the rules you want to use under the rules section.
There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file. Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.
ESLint is a JavaScript linter that you can use to lint either TypeScript or JavaScript code.
Using a .eslintrc.js configuration file you have to add this to the "rules" section:
"rules": {
"@typescript-eslint/member-delimiter-style": ["error", {
multiline: {
delimiter: 'none', // 'none' or 'semi' or 'comma'
requireLast: true,
},
singleline: {
delimiter: 'semi', // 'semi' or 'comma'
requireLast: false,
},
}]
}
Worked for me for the "@typescript-eslint/explicit-function-return-type" parameter. Options are from the rules project site on github
Thanks to maxkoryukov for improving my original answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With