简体   繁体   中英

"ng lint --fix" is not able to fix my files, but can still identify all the errors expected to be fixed

I'm trying to fix lint issues on files that are automatically generated by openapi-generator .

Here is an example of file I want to fix:

在此处输入图片说明

To fix those errors, I'm using this command:

ng lint openapi --fix

The problem is that tslint is able to fix only some errors on these files (the ones created by openapi-generator), for example the rule " trailing-comma " is well corrected, when the rules " max-line-length " and " import-spacing " are not fixed. However these errors are detected as you can see:

在此处输入图片说明

The "openapi" project is defined like that:

在此处输入图片说明

In tslint.json file I defined those rules:

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "trailing-comma": [
      true,
      {
        "multiline": "always",
        "singleline": "never"
      }
    ],
    "arrow-return-shorthand": true,
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "eofline": true,
    "forin": true,
    "import-blacklist": [
      true
    ],
    "import-spacing": true,
    "indent": [
      true,
      "spaces",
      2
    ],
    "interface-over-type-literal": true,
    "label-position": true,
    "max-line-length": [
      true,
      120
    ],
    "member-access": false,
    "no-arg": true,
    "no-console": [
      true,
      "debug",
      "log",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-super": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-misused-new": true,
    "no-non-null-assertion": true,
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unnecessary-initializer": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "prefer-const": true,
    "quotemark": [
      true,
      "single"
    ],
    "radix": true,
    "semicolon": [
      true,
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "typeof-compare": true,
    "unified-signatures": true,
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],
    "directive-selector": [
      true,
      "attribute",
      "ngx",
      "camelCase"
    ],
    "component-selector": [
      true,
      "element",
      "ngx",
      "kebab-case"
    ],
    "ban": [
      true,
      "eval",
      "fit",
      "fdescribe",
      {
        "name": "$",
        "message": "please don't"
      }
    ],
    "no-inputs-metadata-property": true,
    "no-outputs-metadata-property": true,
    "no-output-rename": true,
    "use-lifecycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "no-unused-variable": true
  }
}

我们可以尝试运行“ npm run lint -- --fix这将在我们的项目中自动解决所有可能的lint错误

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM