如何运行@angular-eslint/schematics:convert-tslint-to-eslint [英] How to run @angular-eslint/schematics:convert-tslint-to-eslint

查看:100
本文介绍了如何运行@angular-eslint/schematics:convert-tslint-to-eslint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 angular 中的说明将 Angular 项目从 TSLint 切换到 ESLint-eslint Github 存储库.

我运行了 ng add @angular-eslint/schematics,它向我的 package.json 添加了以下依赖项:

I ran ng add @angular-eslint/schematics which added the following dependencies to my package.json:

    "@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",
    "@typescript-eslint/eslint-plugin": "4.3.0",
    "@typescript-eslint/parser": "4.3.0",
    "eslint": "7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",

另外,运行 npm install 以确保这些都已安装.

Also, ran npm install to ensure these are all installed.

现在我被指示运行:

ng g @angular-eslint/schematics:convert-tslint-to-eslint --remove-tslint-if-no-more-tslint-targets --ignore-existing-tslint-config

然而,这会导致错误:

Unknown option: '--remove-tslint-if-no-more-tslint-targets'
Unknown option: '--ignore-existing-tslint-config'

当我删除这些选项时,出现另一个错误:

When I remove these options, I get another error:

Invalid rule result: Instance of class Promise.

这个 angular-eslint 示意图似乎没有正确安装.但是,我对这些原理图完全是新手.我一定在这里遗漏了一些明显的东西.

It seems like this angular-eslint schematic was not installed properly. However, I'm a complete novice regarding these schematics. I must be missing something obvious here.

使用@angular/cli 10.2.3.

Using @angular/cli 10.2.3.

推荐答案

这取决于项目的 Angular 版本,因为它安装不同版本的 @angular-eslint/schematics不同的角度版本

It depends on the Angular version of your project because it install a different version of @angular-eslint/schematics for different angular versions

步骤将是:

A.将@angular-eslint 添加到您的项目中:

ng add @angular-eslint/schematics

B.如果你有一个 Angular 12 项目,你就大功告成了!对于 Angular 11,运行以下命令:

ng g @angular-eslint/schematics:convert-tslint-to-eslint --remove-tslint-if-no-more-tslint-targets

(仅当您想忽略旧的 tslint 配置时才使用:--ignore-existing-tslint-config 标志)

(Use: --ignore-existing-tslint-config flag only if you want to ignore old tslint configuration)

如果您使用的是 Angular 9 或 10,则会安装旧版本的原理图,并且转换命令略有不同.在转换为 ESLint 之前,您可能希望优先升级 Angular.但是如果你真的想先升级linting,使用这个命令:

If you are on Angular 9 or 10, an older version of the schematic gets installed and the convert command differs slightly. You may want to prioritize upgrading Angular before converting to ESLint. But if you really want to upgrade linting first, use this command:

ng g @angular-eslint/schematics:convert-tslint-to-eslint <project-name-here>

详细的关于 tslint 到 eslint 迁移的博客

这篇关于如何运行@angular-eslint/schematics:convert-tslint-to-eslint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆