tslint 配置 tslint.json

tslint 配置

{
    "extends": "tslint:recommended",
    "defaultSeverity": "warn",
    "rules": {
        "quotemark":[true, "single","avoid-escape"], //引号的使用规则
        "no-var-keyword":true, // 禁用 var
        "variable-name":[true, "ban-keywords", "check-format", "allow-leading-underscore"], //变量名规则
        "ordered-imports":false, //import 不排序
        "object-literal-sort-keys":false, //和前面那条类似
        "semicolon":[true, "always", "ignore-interfaces"], //分号的使用规则
        "indent":[true, "spaces", 4], //使用4空格进行缩进
        "interface-name":false, // 强制接口 "I" 开头
        "typedef-whitespace": false, //在类型定义的时候,是否允许使用空格, 使用false,表示不对此项进行校验,不启用此项的校验
        "whitespace": false, //空格的校验
        "member-access": [true, "no-public"], //类成员的显示可见性声明,即显示定义一个类的成员是否可见,即对类成员定义public | static 等
        "one-line": false, //要求指定的标记与它们之前的表达式位于同一行
        "no-console": true, //是否允许使用console
        "only-arrow-functions":false,
        "arrow-parens":false,
        "ban-types": [true, ["Object", "Use {} instead."], ["String"]],
        "max-line-length": [true, {"limit": 200, "ignore-pattern": "^import |^export {(.*?)}|class [a-zA-Z]+ implements |//"}],
        "max-classes-per-file":[true, 1], // 单个文件最多几个类
        "trailing-comma": [true, { //对尾随逗号的校验
            "multiline": {
                "objects": "ignore",
                "arrays": "never",
                "functions": "never",
                "typeLiterals": "ignore"
            },
            "esSpecCompliant": true //是否允许尾随逗号出现在剩余变量中
        }],
        "no-shadowed-variable": [
            true,
            {
              "class": true,
              "enum": true,
              "function": true,
              "interface": false,
              "namespace": true,
              "typeAlias": false,
              "typeParameter": false
            }
          ]
    },
    "rulesDirectory": []
}

 

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Are you human? Click the Pineapple...