简体   繁体   English

删除一些 tslint 规则

[英]Remove some tslint rules

I need to remove below tslint rules from my tslint.json.我需要从我的 tslint.json 中删除以下 tslint 规则。

  1. file should end with a newline文件应以换行符结尾
  2. trailing whitespace尾随空格
  3. missing whitespace缺少空格
  4. " should be ' “ 应该 '

In order to remove white-spaces, I removed check-type by looking at this issue .为了删除空格,我通过查看这个issue删除了check-type

But still I'm getting errors when I run ng lint command on cli.但是当我在 cli 上运行ng lint命令时仍然出现错误。 Anyone knows how to remove above rules from my tslint.json file?任何人都知道如何从我的 tslint.json 文件中删除上述规则?

tslint.json tslint.json

    {
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "arrow-return-shorthand": true,
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      false,
      "check-space"
    ],
    "curly": true,
    "eofline": true,
    "forin": true,
    "import-blacklist": [
      true,
      "rxjs",
      "rxjs/Rx"
    ],
    "import-spacing": true,
    "indent": [
      false,
      "spaces"
    ],
    "interface-over-type-literal": true,
    "label-position": true,
    "max-line-length": [
      true,
      200
    ],
    "member-access": false,
    "member-ordering": [
      true,
      {
        "order": [
          "static-field",
          "instance-field",
          "static-method",
          "instance-method"
        ]
      }
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-super": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-inferrable-types": [
      true,
      "ignore-params"
    ],
    "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-unused-expression": 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": [
      false,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],
    "directive-selector": [
      true,
      "attribute",
      "app",
      "camelCase"
    ],
    "component-selector": [
      true,
      "element",
      "app",
      "kebab-case"
    ],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "invoke-injectable": true
  }
}

1.file should end with a new line 1.file 应该以新行结尾

"eofline": true,

2.trailing whitespace 2.尾随空格

"no-trailing-whitespace": false,

3.Missing Whitespace 3.缺少空格

"whitespace": [
  false,
  "check-branch",
  "check-decl",
  "check-operator",
  "check-separator",
  "check-type"
],

4." should be ' 4." 应该是 '

"quotemark": [
  true,
  "single"
],

Here's how I do it in my root folder where my tslint.json file is:这是我在我的 tslint.json 文件所在的根文件夹中执行此操作的方法:

But first change "no-trailing-whitespace": true , to false in tslint.json但首先在 tslint.json 中将"no-trailing-whitespace": true更改为false

tslint only warns you. tslint 只会警告你。 Prettier enforces it. Prettier 强制执行它。 You might want to check out the prettier docs.您可能想查看更漂亮的文档。 It took me a while to fine tune mine.我花了一段时间来微调我的。 Now I just use it in everyone of my application across the board.现在我只是在我的每个应用程序中都使用它。

  1. In my .editorconfig file I have the following which comes with every new Angular app:在我的.editorconfig文件中,每个新的 Angular 应用程序都有以下内容:
 # Editor configuration, see http://editorconfig.org root = true [*] charset = utf-8 indent_style = space indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true [*.md] max_line_length = off trim_trailing_whitespace = false
  1. Use prettier.使用更漂亮。 With a.prettierrc file:使用 .prettierrc 文件:
 { "arrowParens": "avoid", "bracketSpacing": true, "endOfLine": "auto", "htmlWhitespaceSensitivity": "strict", "semi": true, "singleQuote": true, "tabWidth": 2, "trailingComma": "all", "useTabs": false }
  1. In folder vscode in extensions.json (with this whenever you start vs code it will prompt you to install the recommendation:extensions.json文件夹中的vscode中(每当您启动 vs code 时,它都会提示您安装建议:
 // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp // List of extensions which should be recommended for users of this workspace. { "recommendations": [ "Angular.ng-template", "DavidAnson.vscode-markdownlint", "eamodio.gitlens", "EditorConfig.EditorConfig", "esbenp.prettier-vscode", "mike-co.import-sorter", "ms-vscode.vscode-typescript-tslint-plugin" ], "unwantedRecommendations": [ "amatiasq.sort-imports", "eg2.tslint", "HookyQR.beautify" ] }
  1. package.json add these then do npm install : package.json添加这些然后执行npm install
 "prettier": "1.18.2", "protractor": "5.4.2", "tslint-config-prettier": "1.18.0", "tslint-consistent-codestyle": "1.16.0", "tslint-plugin-prettier": "2.0.1",
  1. In tslint.json (using the following, if you don't add #4 above you will get a warning that they are missing and the annoying yellow code underlines:在 tslint.json 中(使用下面的代码,如果你没有在上面添加#4,你会得到一个警告,指出它们丢失了,并且恼人的黄色代码下划线:
 { "defaultSeverity": "error", "extends": [ "tslint:latest", "tslint-config-prettier", "tslint-consistent-codestyle" ], "rules": {...

Remove in your tsLint:在您的 tsLint 中删除:

"no-trailing-whitespace": true,

"whitespace": [ false, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ],

"quotemark": [ true, "single" ],

"eofline": true,

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

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