I recently removed the tslint from my angular project - I read it was depreciated, so thought I best get my hands dirty and switch to eslint.
So I removed the tslint files, ran ng add @angular-eslint/schematics to install the lint schematics, installed the Airbnb typescript linter, and amended the ng lint task to run like so...
"lint": "eslint -c .eslintrc.js --ext .ts ./src/app"
I added a .eslintrc.js file and populated it with the following
module.exports = {
root: true,
extends: [
'airbnb-typescript/base',
'plugin:@angular-eslint/recommended'
],
ignorePatterns: [
'node_modules/',
'build/',
'dist/',
'e2e/'
],
rules: {
'comma-dangle': ['error', 'only-multiline'],
'max-len': ['error', {code: 120, tabWidth: 4}],
'no-underscore-dangle': 'off',
'no-await-in-loop': 'off',
'import/prefer-default-export': 'off',
'no-param-reassign': ['error', {props: false}],
'strict': ['error', 'global'],
'func-names': 'off', // I use a lot of unnamed functions
'global-require': 'off',
'class-methods-use-this': 'off', // Disabled for Angular Controllers,
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
ts: 'never',
}
]
},
plugins: [
'@angular-eslint/eslint-plugin'
],
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
}
}
everything worked really well... but when I run ng lint I get the following error...
1:1 error Definition for rule '@typescript-eslint/space-infix-ops' was not found @typescript-eslint/space-infix-ops 1:1 error Definition for rule '@typescript-eslint/object-curly-spacing' was not found @typescript-eslint/object-curly-spacing
This is strange as I don't include rules for these in the .eslintrc.js file. I then ran an npm update hoping that may solve the issue but it doesn't. I'm currently looking through StackOverflow for an answer but if anyone has a direct answer please let me know what to do, any help is appreciated.
I'm unsure if this helps but this is the contents on my package.json
"@angular-devkit/build-angular": "^0.1102.3",
"@angular-eslint/builder": "1.2.0",
"@angular-eslint/eslint-plugin": "1.2.0",
"@angular-eslint/eslint-plugin-template": "1.2.0",
"@angular-eslint/schematics": "1.2.0",
"@angular-eslint/template-parser": "1.2.0",
"@angular/animations": "^11.2.4",
"@angular/cli": "^11.2.3",
"@angular/common": "^11.2.4",
"@angular/compiler": "^11.2.4",
"@angular/compiler-cli": "^11.2.4",
"@angular/core": "^11.2.4",
"@angular/forms": "^11.2.4",
"@angular/http": "~7.0.0",
"@angular/language-service": "^11.2.4",
"@angular/platform-browser": "^11.2.4",
"@angular/platform-browser-dynamic": "^11.2.4",
"@angular/router": "^11.2.4",
"@compodoc/compodoc": "^1.1.11",
"@types/jasmine": "^2.8.17",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^8.10.66",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"codelyzer": "~4.5.0",
"core-js": "^2.6.9",
"eslint": "^7.6.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-prettier": "^3.3.1",
"is-docker": "^1.1.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"material-design-icons": "^3.0.1",
"ng-packagr": "^11.2.4",
"ngx-highlightjs": "^4.1.3",
"prettier": "^2.2.1",
"protractor": "^5.4.4",
"roboto-fontface": "^0.10.0",
"rxjs": "~6.6.6",
"scss-bundle": "^2.5.1",
"tsickle": "^0.33.1",
"tslint": "~5.11.0",
"typescript": "~4.1.5",
"zone.js": "~0.11.4"