试试这个https://stackoverflow.com/a/65552444/14764759
tslint 到 eslint 配置
代码风格:Prettier 覆盖率:100% TypeScript:严格的 NPM 版本 Circle CI 加入聊天https://gitter.im/tslint-to-eslint-config/community 代码风格:Prettier
将您的 TSLint 配置转换为最接近合理的 ESLint 等效项。
TSLint 已弃用。使用 tslint-to-eslint-config 加快将项目迁移到 ESLint。
考虑查看相关文档:
ESLint itself
typescript-eslint, which allows TypeScript files to be linted by ESLint
用法
npx tslint-to-eslint-config
tslint-to-eslint-config 命令读取任何现有的 linter、TypeScript 和包配置文件,然后基于它们创建一个 .eslintrc.js 结果。
对于任何具有相应 ESLint 等效项的 TSLint 规则,这些等效项将在新配置中使用。没有 ESLint 等效项的 TSLint 规则将使用 eslint-plugin-tslint 包装。
Requires Node 10+ (LTS) and TSLint 5.18+
常见问题解答
我们强烈建议您在计划从 TSLint 转换为 ESLint 之前阅读 docs/FAQs.md。
CLI 标志
这些标志中的每一个都是可选的:
comments: TypeScript configuration or file glob path(s) to convert TSLint rule flags to ESLint within.
config: Path to print the generated ESLint configuration file to.
editor: Path to an editor configuration file to convert linter settings within.
eslint: Path to an ESLint configuration file to read settings from.
package: Path to a package.json file to read dependencies from.
prettier: Add eslint-config-prettier to the plugins list.
tslint: Path to a TSLint configuration file to read settings from.
typescript: Path to a TypeScript configuration file to read TypeScript compiler options from.
cmets
npx tslint-to-eslint-config --cmets
默认:无
表示从 TSLint 规则标志转换为 ESLint 内联 cmets。诸如 // tslint:disable: tslint-rule-name 之类的注释将被转换为等价物,例如 // eslint-disable eslint-rule-name。
如果不带参数传递,则尊重 TypeScript 配置中的排除、文件和包含。
如果传递以 .json 结尾的单个文件路径,则将其视为 TypeScript 配置文件,其中描述了要转换的文件。
npx tslint-to-eslint-config --cmets tsconfig.json
如果传递了任何其他参数,这些参数将被视为要转换的文件路径的全局路径:
npx tslint-to-eslint-config --cmets 'src/**/*.ts'
配置
npx tslint-to-eslint-config --config .eslintrc.json
默认:.eslintrc.js
将生成的 ESLint 配置文件打印到的路径。
此路径的文件扩展名将用于确定创建文件的格式:
.js file paths will be written module.exports = ... JavaScript
Other file paths will default to JSON
编辑器
npx tslint-to-eslint-config --editor ./path/to/.vscode/settings.json
默认值:.vscode/settings.json
编辑器配置文件的路径,用于在其中转换设置设置。 TSLint 的任何 VS Code 样式编辑器设置都将转换为它们的 ESLint 等效项。
eslint
npx tslint-to-eslint-config --eslint ./path/to/eslintrc.js
默认值:--config 的值
要从中读取设置的 ESLint 配置文件的路径。生成的 ESLint 配置文件将包含从该文件导入的任何设置。
包
npx tslint-to-eslint-config --package ./path/to/package.json
默认:package.json
要从中读取依赖项的 package.json 文件的路径。这将有助于通知生成的 ESLint 配置文件的 env 设置。
更漂亮
npx tslint-to-eslint-config --prettier
默认值:假
将 eslint-config-prettier 添加到 ESLint 插件列表中。我们强烈建议您使用 Prettier 进行代码格式化。
当 --prettier 未启用时:
If the output configuration already doesn't enable any formatting rules, it'll extend from eslint-config-prettier.
Otherwise, a CLI message will suggest running with --prettier.
tslint
npx tslint-to-eslint-config --tslint ./path/to/tslint.json
默认:tslint.json
要从中读取设置的 TSLint 配置文件的路径。该文件通过管道传输到 TSLint 的 --print-config 以生成要在生成的 ESLint 配置文件中启用的规则列表。
打字稿
npx tslint-to-eslint-config --typescript ./path/to/tsconfig.json
默认:tsconfig.json
要从中读取 TypeScript 编译器选项的 TypeScript 配置文件的路径。这将有助于通知生成的 ESLint 配置文件的 env 设置。
节点API
您可以通过其导出的函数以编程方式使用 tslint-to-eslint-config。有关详细信息,请参阅文档/API。
从“tslint-to-eslint-config”导入 { convertLintConfig };
const 结果 = 等待 convertLintConfig();
发展
查看一般开发文档。