如何运行@angular-eslint/schematics:convert-tslint-to-eslint

如何解决如何运行@angular-eslint/schematics:convert-tslint-to-eslint

我正在尝试按照 angular-eslint github repo 中的说明将 Angular 项目从 TSLint 切换到 ESLint。

我运行了 ng add @angular-eslint/schematics,它向我的 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 以确保这些都已安装。

现在我被指示运行:

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'

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

Invalid rule result: Instance of class Promise.

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

使用@angular/cli 10.2.3。

解决方法

如果您要迁移现有项目,则应该运行其中之一

ng g @angular-eslint/schematics:convert-tslint-to-eslint

ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT_NAME_GOES_HERE}}

代替

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

根据指南https://github.com/angular-eslint/angular-eslint#step-2---run-the-convert-tslint-to-eslint-schematic-on-a-project

,

这取决于您项目的 Angular 版本,

步骤将是:

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 标志)

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

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

Detailed blog for tslint to eslint migration

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?