2017-04-05 54 views
-2

我有通过下面的import语句使用lodash的角2项目TSLINT:调用“_.isNull”不准

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" 
    ] 
    } 
} 

回答

4

检查禁令规则在tslint.json。有一个入口isNull。这就是为什么你有一个linting警告。