Since tslint will be deprecated soon, I'm trying to convert tslint rules to eslint.
These are all my rules for tslint.
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"arrow-parens": false,
"interface-name": false,
"interface-over-type-literal": false,
"max-classes-per-file": false,
"max-line-length": false,
"member-access": false,
"member-ordering": false,
"no-angle-bracket-type-assertion": false,
"no-consecutive-blank-lines": [true, 2],
"no-var-requires": false,
"object-literal-shorthand": false,
"object-literal-sort-keys": false,
"quotemark": [true, "single", "avoid-template", "avoid-escape"],
"trailing-comma": "never"
},
"rulesDirectory": []
}
I've auto generated the tslint to eslint conversion by using npx tslint-to-eslint-config
.
And this is auto converted eslint rules
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"off",
"as-needed"
],
"camelcase": "error",
"comma-dangle": "error",
"complexity": "off",
"constructor-super": "error",
"dot-notation": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"id-match": "error",
"max-classes-per-file": "off",
"max-len": "off",
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "error",
"no-debugger": "error",
"no-empty": "error",
"no-eval": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-multiple-empty-lines": [
"error",
{
"max": 2
}
],
"no-new-wrappers": "error",
"no-shadow": [
"error",
{
"hoist": "all"
}
],
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "off",
"one-var": [
"error",
"never"
],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"radix": "error",
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"jsdoc-format": true,
"no-reference-import": true
}
}
]
}
}
When I ran npx eslint .
, I get tons of error with @typescript-eslint/parser
0:0 error Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: dist/templates.js.
The file must be included in at least one of the projects provided
I'm pretty new to using tslint or eslint, and I'm not sure how to exactly fix this issue. Just wondering if I'm missing something crucial for this?
Thanks so much in advance!
Here's what's happening:
tsconfig.json
file to read in a collection of source filestsconfig.json
This causes a crash because TypeScript information is being requested about a file that TypeScript doesn't know about.
Make sure your ESLint file is set to only run on files included in your tsconfig.json
, and this error should go away.