javascript - 找不到配置中指定的以下规则的实现

标签 javascript eslint tslint eslintrc eslint-plugin-vue

我正在使用下面的方法将我的 tslint 转换为 eslint

引用:https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint#usage

这是我的 tslint.json 文件:

https://github.com/kumaresan-subramani/ESlint-tester/blob/main/tslint.json

我的 eslint.json 文件

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "plugins": [
        "@typescript-eslint",
        "@typescript-eslint/tslint"
    ],
    "parserOptions": {
        "project": "tsconfig.json"
    },
    "rules": {
        "@typescript-eslint/tslint/config": ["warn", {
          "lintFile": "./tslint.json", // path to tslint.json of your project
          "rules": {},
          "rulesDirectory": [
            "node_modules/tslint-eslint-rules/dist/rules"
          ]
        }]
      },
    "reportUnusedDisableDirectives": true

}

在给出下面的命令时我遇到了一个错误

yarn run eslint src

错误

D:\today\ESlint-tester>yarn run eslint src
yarn run v1.21.1
$ D:\today\ESlint-tester\node_modules\.bin\eslint src

Could not find implementations for the following rules specified in the configuration:
    chai-vague-errors
    no-redundant-jsdoc
    missing-optional-annotation
    no-backbone-get-set-outside-model
    no-banned-terms
    no-cookies
    no-delete-expression
    no-document-write
    no-document-domain
    no-disable-auto-sanitization
    no-duplicate-parameter-names
    no-empty-interfaces
    no-exec-script
    no-function-constructor-with-string-args
    no-function-expression
    no-for-in
    no-multiline-string
    no-multiple-var-decl
    no-unnecessary-bind
    no-unnecessary-semicolons
    no-octal-literal
    no-sparse-arrays
    no-string-based-set-immediate
    no-string-based-set-interval
    no-unused-imports
    no-with-statement
    prefer-array-literal
    promise-must-complete
    react-no-dangerous-html
    use-named-parameter
    max-func-body-length
    no-empty-line-after-opening-brace
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.

最佳答案

您正在使用 typescript-eslint这是一个:

ESLint plugin [that] wraps a TSLint configuration and lints the whole source using TSLint.

但是报错信息:

Could not find implementations for the following rules specified in the configuration:

来自 TSLint 本身。原因是您的 tslint.json 中的规则与您的 TSLint 版本不兼容。

您必须更改 TSLint 版本或通过查看 TSLint ChangeLog 调整规则.请注意,typescript-eslint 需要 5.x 或 6.x TSLint 版本(参见其 package.json )。

您还可以检查这个 SO 问题:Update TSLint Errors : Could not find implementations for the following rules specified in the configuration

关于javascript - 找不到配置中指定的以下规则的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65318057/

相关文章:

javascript - 为什么我的ajax成功数据没有显示在Angular JS中

javascript - angularjs:ng-click 不工作

javascript - 将 attr 函数与 href 一起使用时出错

javascript - 从 package.json 作为脚本运行时出现 ESLint 错误

javascript - 歌曲结束时随机播放 - javascript html5

javascript - 使用 typescript jsx 的 ESLint 配置

javascript - 在多行 if 语句中使用前导或尾随 bool 运算符的原因

typescript - VSCode - TSLint 错误 ENOTDIR 无效的 cwd

angular - 使用开关时 tslint 提示 "statements must be filtered with an if statement"

angular - 如何使用 tslint 在特定文件中导入黑名单