简体   繁体   English

Angular & eslint - 未找到规则“@typescript-eslint/space-infix-ops”的定义

[英]Angular & eslint - Definition for rule '@typescript-eslint/space-infix-ops' was not found

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.我最近从我的 angular 项目中删除了 tslint - 我读到它已贬值,所以我想我最好把手弄脏并切换到 eslint。

So I removed the tslint files, ran ng add @angular-eslint/schematics to install the lint schematics, installed the airbnb typescript linter, amended the ng lint task to run like so...所以我删除了 tslint 文件,运行ng add @angular-eslint/schematics来安装 lint 原理图,安装了 airbnb typescript linter,修改了ng lint任务以像这样运行......

"lint": "eslint -c .eslintrc.js --ext .ts ./src/app"

I added a .eslintrc.js file and populated it with the following我添加了一个.eslintrc.js文件并用以下内容填充它

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...一切都很好......但是当我运行ng lint时,我收到以下错误......

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未找到规则“@typescript-eslint/space-infix-ops”的 1:1 错误定义 @typescript-eslint/space-infix-ops 规则“@typescript-eslint/object-curly-spacing”的 1:1 错误定义' 没有找到 @typescript-eslint/object-curly-spacing

This is strange as I don't include rules for these in the .eslintrc.js file?这很奇怪,因为我没有在.eslintrc.js文件中包含这些规则? I then ran npm update hoping that may solve the issue but it doesn't?然后我运行 npm 更新希望可以解决问题,但它没有? 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.我目前正在通过 stackoverflow 寻找答案,但如果有人有直接答案,请让我知道该怎么做,我们将不胜感激。

I'm unsure if this helps but this is the contents on my package.json我不确定这是否有帮助,但这是我的 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"

I managed to resolve this by forcing the version "@typescript-eslint/eslint-plugin": "^4.17.0" - just using npm update didn't seem to work我设法通过强制版本"@typescript-eslint/eslint-plugin": "^4.17.0"解决了这个问题 - 仅使用 npm 更新似乎不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM