当我尝试让 Angular/cli 为我生成一个新组件时,它所做的只是打印消息
\nthis.tree.readText is not a function\nRun Code Online (Sandbox Code Playgroud)\n并退出。
\n我正在使用 Ubuntu 22.04 并ng在控制台窗口中使用。\n我正在尝试在功能模块中生成新组件。ng我使用以下命令从功能模块目录开始:
ng g c components/my-new-component --change-detection OnPush\nRun Code Online (Sandbox Code Playgroud)\n工作目录类似于:
\n~/Develop/my-project/src/app/feature-module\nRun Code Online (Sandbox Code Playgroud)\n我期望在新文件夹中生成四个新文件
\n~/Develop/my-project/src/app/feature-module/components/my-new-component/\nRun Code Online (Sandbox Code Playgroud)\n以及模块文件
\n~/Develop/my-project/src/app/feature-module/feature-module.module.ts\nRun Code Online (Sandbox Code Playgroud)\n使用新生成的组件进行更新。
\n我在 Ubunut 20.04 上也遇到了这种情况。\n一位同事在他的 Mac(M1)上使用ng命令行时也遇到了同样的问题,但并没有真正受到阻碍,因为他使用 IntelliJ 并且有用于生成新组件的扩展,而不是使用命令行。
我尝试用谷歌搜索这个问题,但没有成功。我还尝试删除 node_modules 以及 package-lock.json 文件并重新安装所有包,但无济于事。
\n我正在使用以下节点/打字稿/角度版本:
\n _ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| …Run Code Online (Sandbox Code Playgroud) 我有一个用 Angular 制作的项目。
我想为 Angular*.html文件设置缩进规则。
我在我的.eslintrc:
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {
"indent": [2, 2]
}
}
Run Code Online (Sandbox Code Playgroud)
但这给了我以下错误:
TypeError: Cannot read property 'start' of undefined
Run Code Online (Sandbox Code Playgroud)
我不明白为什么。
我的全.eslintrc
TypeError: Cannot read property 'start' of undefined
Run Code Online (Sandbox Code Playgroud) 我有干净的(只有 eslint 和 prettier)Angular 16 项目和这个 package.json。我的 IDE 显示错误,屏幕截图位于帖子页脚上。在Angular版本较低的项目中,不存在这个错误。
{
"name": "my-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.0",
"@angular-eslint/builder": "16.0.1",
"@angular-eslint/eslint-plugin": "16.0.1",
"@angular-eslint/eslint-plugin-template": "16.0.1",
"@angular-eslint/schematics": "16.0.1",
"@angular-eslint/template-parser": "16.0.1",
"@angular/cli": "~16.0.0", …Run Code Online (Sandbox Code Playgroud) \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\n我已将 ESLint 规则集作为包下载并安装到我当前的项目中。我下载的规则集用于向项目环境添加对 Angular、TypeScript(当然还有 ECMAScript)的 ESLint 支持。我想创建一个 ESLint 配置,其中包含我需要从事该项目的开发人员遵守的“标准化代码风格”。
\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\n首先我添加了plugin:@typescript-eslint/recommended. 后来我决定做出改变,我转而使用plugin:@angular-eslint/recommended. 我认为Angular-eslint-recommended扩展了 TS-ESLint 插件的规则集:plugin:@typescript-eslint/recommended但实际上,它仅扩展了插件:@typescript-eslint。
问题:可以扩展多个规则集吗?扩展\n plugin:@typescript-eslint/recommended&plugin:@angular-eslint/recommended是否是我为 TS-Angular 项目提供适当的 Linting 支持所需的所有规则?
在.eslintrc.json上设置"@angular-eslint/template/eqeqeq": "off", 配置不适用于 Angular 13
.eslintrc.json
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"prettier"
],
"plugins": ["prettier"],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
// "prefix": "app",
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/directive-selector": [
"error",
{
// "prefix": "app",
"style": "camelCase",
"type": "attribute"
}
],
"@angular-eslint/template/eqeqeq": "off",
"@angular-eslint/no-host-metadata-property": "off",
"@angular-eslint/no-output-on-prefix": "off",
"@angular-eslint/no-output-native":"off"
// "@angular-eslint/template/eqeqeq":[
// "error",{ …Run Code Online (Sandbox Code Playgroud)