TSLINT:不允许调用'_.isNull'



我有一个通过以下导入语句使用 lodash 的 Angular 2 项目。

import * as _ from 'lodash';

我有一些代码可以访问 lodash isNull 函数

onClick(){
    var type = _.isNull(id) ? 'new' : 'update';
    this.modelChange.fire(this.modelName, type, { id: id, name: this.nameControl.value});
}

TSLint 抛出此警告,我不确定如何解决它。

[39, 20]:不允许调用"_.isNull"。

这是我的tslint.json

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-attribute-parameter-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "no-forward-ref" :true,
    "no-trailing-whitespace": false,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "pipe-naming": [true, "camelCase", "my"],
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "ban": [true,
      ["_", "extend"],
      ["_", "isNull"],
      ["_", "isDefined"]
    ],
    "class-name": true,
    "comment-format": [false,
      "check-space",
      "check-lowercase"
    ],
    "curly": true,
    "eofline": true,
    "forin": true,
    "indent": [true, 2],
    "interface-name": true,
    "jsdoc-format": true,
    "label-position": true,
    "max-line-length": [false, 140],
    "member-ordering": [true,
      "public-before-private",
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-empty": true,
    "no-eval": true,
    "no-string-literal": false,
    "no-switch-case-fall-through": true,
    "trailing-comma": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-use-before-declare": true,
    "no-var-requires": true,
    "one-line": [true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "quotemark": [true, "single"],
    "radix": true,
    "semicolon": true,
    "triple-equals": [true, "allow-null-check"],
    "typedef": [true,
      "callSignature",
      "indexSignature",
      "parameter",
      "propertySignature",
      "variableDeclarator"
    ],
    "typedef-whitespace": [true,
      ["callSignature", "noSpace"],
      ["catchClause", "noSpace"],
      ["indexSignature", "space"]
    ],
    "variable-name": false,
    "whitespace": [true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ]
  }
}

检查tslint.json中的禁止规则。那里有一个isNull条目.这就是为什么您有一个绒毛警告。

最新更新