使用最新版本的 typescript 和 eslint 时出错

Jac*_*ack 4 node.js typescript eslint typescript-eslint

当我运行时eslint .出现错误:

\n
Error: .eslintrc.js \xc2\xbb eslint-config-standard-with-typescript:\n    Configuration for rule "@typescript-eslint/restrict-plus-operands" is invalid:\n    Value {"skipCompoundAssignments":false} should NOT have additional properties.\n
Run Code Online (Sandbox Code Playgroud)\n

我在配置中禁用了“@typescript-eslint/restrict-plus-operands”规则:

\n
rules: {\n  ...\n  '@typescript-eslint/restrict-plus-operands': 'off',\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但它不起作用,我得到同样的错误。

\n

有什么问题?

\n

软件包版本:

\n
"@typescript-eslint/eslint-plugin": "^5.62.0",\n"@typescript-eslint/parser": "^6.4.1",\n"eslint": "^8.48.0",\n"eslint-config-prettier": "^9.0.0",\n"eslint-config-standard-with-typescript": "^39.0.0",\n"eslint-plugin-import": "^2.28.1",\n"eslint-plugin-n": "^16.0.2",\n"eslint-plugin-prettier": "^5.0.0",\n"eslint-plugin-promise": "^6.1.1",\n"typescript": "^5.2.2",\n
Run Code Online (Sandbox Code Playgroud)\n

节点 v14.18.2

\n

npm v6.14.15

\n

UPD

\n

将“@typescript-eslint/eslint-plugin”更新到6.4.1版本后,出现了新的错误:

\n
/node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager/dist/referencer/ClassVisitor.js:123\n        withMethodDecorators ||=\n                             ^^^\nSyntaxError: Unexpected token '||='\n
Run Code Online (Sandbox Code Playgroud)\n

Mat*_*ler 14

对运营商的支持||=已在节点 v15 中落地。

因此,这个问题预计会在 v14 中出现,并且可以在更高版本(15+)中修复