简体   繁体   English

将 angular 更新到 v14 后,TSlint 规则变为 ESlint

[英]TSlint rules to ESlint after update angular to v14

after upgrading angular to v14 I also install ESlint .angular 升级到 v14后,我还安装了 ESlint

Until now, I use TSlint with some custom rules, config... here is my tslint.json (in root)到目前为止,我将TSlint与一些自定义规则、配置一起使用……这是我的 tslint.json(在 root 中)

{
  "extends": ["tslint-config-airbnb"],
  "rules": {
    "align": {
      "options": ["parameters", "statements"]
    },
    "array-type": false,
    "arrow-return-shorthand": true,
    "curly": true,
    "deprecation": {
      "severity": "warning"
    },
    "component-class-suffix": true,
    "contextual-lifecycle": true,
    "directive-class-suffix": true,
    "directive-selector": [true, "attribute", "", "camelCase", "kebab-case"],
    "component-selector": [true, "attribute", "", "kebab-case"],
    "eofline": true,
    "import-blacklist": [true, "rxjs/Rx"],
    "import-spacing": true,
    "indent": {
      "options": ["spaces"]
    },
    "max-classes-per-file": false,
    "max-line-length": [true, 140],
    "member-ordering": [
      true,
      {
        "order": [
          "static-field",
          "instance-field",
          "static-method",
          "instance-method"
        ]
      }
    ],
    "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
    "no-empty": false,
    "no-inferrable-types": [true, "ignore-params"],
    "no-non-null-assertion": true,
    "no-redundant-jsdoc": true,
    "no-switch-case-fall-through": true,
    "no-var-requires": false,
    "object-literal-key-quotes": [true, "as-needed"],
    "quotemark": [true, "single"],
    "semicolon": {
      "options": ["always"]
    },
    "space-before-function-paren": {
      "options": {
        "anonymous": "never",
        "asyncArrow": "always",
        "constructor": "never",
        "method": "never",
        "named": "never"
      }
    },
    "typedef-whitespace": {
      "options": [
        {
          "call-signature": "nospace",
          "index-signature": "nospace",
          "parameter": "nospace",
          "property-declaration": "nospace",
          "variable-declaration": "nospace"
        },
        {
          "call-signature": "onespace",
          "index-signature": "onespace",
          "parameter": "onespace",
          "property-declaration": "onespace",
          "variable-declaration": "onespace"
        }
      ]
    },
    "variable-name": {
      "options": [
        "ban-keywords",
        "check-format",
        "allow-pascal-case",
        "allow-leading-underscore"
      ]
    },
    "whitespace": {
      "options": [
        "check-branch",
        "check-decl",
        "check-operator",
        "check-separator",
        "check-type",
        "check-typecast"
      ]
    },
    "no-conflicting-lifecycle": true,
    "no-host-metadata-property": true,
    "no-input-rename": true,
    "no-inputs-metadata-property": true,
    "no-output-native": true,
    "no-output-on-prefix": true,
    "no-output-rename": true,
    "no-outputs-metadata-property": true,
    "template-banana-in-box": true,
    "template-no-negated-async": true,
    "use-lifecycle-interface": true,
    "use-pipe-transform-interface": true,
    "trailing-comma": false
  },
  "rulesDirectory": ["codelyzer"]
}

I follow this guide to migrate to ESlint , but after this command我按照这个指南迁移到ESlint ,但是在这个命令之后

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

here is my output这是我的 output 在此处输入图像描述

But I didn't get any of my "tslint" rules in ".eslintrc.json"但是我没有在“.eslintrc.json”中得到任何“tslint”规则

{
  "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"
      ],
      "rules": {}
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {}
    }
  ]
}

In my package.json in devDep I have在 devDep 的 package.json 我有

    "@angular-eslint/builder": "14.1.2",
    "@angular-eslint/eslint-plugin": "14.1.2",
    "@angular-eslint/eslint-plugin-template": "14.1.2",
    "@angular-eslint/schematics": "14.1.2",
    "@angular-eslint/template-parser": "14.1.2",
    "@typescript-eslint/eslint-plugin": "5.37.0",
    "@typescript-eslint/parser": "5.37.0",
    "eslint": "^8.23.1",

Is there any way to "convert" my TS rules to ESrules?有什么方法可以将我的 TS 规则“转换”为 ESrules?

Thnx In advice谢谢建议

eslint/schematics:convert-tslint-to-eslint apparently does not recreate the eslintrc file if it is already created (and I had it after ng add @angular-eslint/schematics ) eslint/schematics:convert-tslint-to-eslint显然不会重新创建 eslintrc 文件,如果它已经创建(我在ng add @angular-eslint/schematics之后有了它)

I removed basic eslintrc file ( eslint/schematics:convert-tslint-to-eslint will create a new one with the rules from tslint, unless you ignore them) and got new eslintrc with modified tslint rules.我删除了基本的 eslintrc 文件( eslint/schematics:convert-tslint-to-eslint将使用来自 tslint 的规则创建一个新文件,除非你忽略它们)并获得具有修改后的 tslint 规则的新 eslintrc。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Angular(v14) 中更新@ViewChildren(或@ContentChildren)的 styles - How to update the styles of @ViewChildren (Or @ContentChildren) in Angular(v14) v14 中 Angular 编译器的替代品是什么? - What is the replacement for the Angular Compiler in v14? Angular 从 v12 迁移到 v14 - Angular migration from v12 to v14 Safari 中带有 Angular (v14) 应用程序的空白页面 - Blank page with Angular (v14) app in Safari 在架构中找不到“tsconfig”-将 tslint 迁移到 eslint (Angular v11) - 'tsConfig' is not found in schema - Migrating tslint to eslint (Angular v11) 如何手动更新 Angular 以使用 eslint 并删除 tslint - How to manually update Angular to use eslint and remove tslint Nx Angular TSLint 到 ESLint 迁移后的 Lint 错误 - Nx Angular Lint Error after TSLint to ESLint Migration Angular 12 从 tslint 切换到 eslint 后模板 linting 不起作用 - Angular 12 template linting not working after switchting from tslint to eslint Angular 使用@angular-builders/custom-webpack 将 v13 迁移到 v14 - Angular migration v13 to v14 using @angular-builders/custom-webpack 找不到模块“@angular/cdk/dialog”- Angular 将 v13 升级到 v14 问题 - Cannot find module '@angular/cdk/dialog' - Angular upgrade v13 to v14 issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM