在Visual Studio代码

时间:2017-07-01 10:22:32

标签: typescript visual-studio-code tslint

我的项目是打字稿,我正在为vscode使用tslint扩展名。

我已禁用 no-var-keyword prefer-const ,因为js文件的目标也是IE9用户。并且它不支持let关键字,因此我在整个项目中使用var

如果我在if块中创建变量然后在else中使用它,则tslint不会给出任何错误。

if(someVariable){
    var val="abc";
    // Some other code
}
else{
    val="def";
    // Some other code
}

这应该给出一些错误/警告,但它没有,是否有任何选项可以启用它?

以下是我的tslint.json

{
"defaultSeverity": "error",
"extends": [
    "tslint:recommended"
],
"jsRules": {
    "no-eval": true,
    "no-unsafe-finally": true
},
"rules": {
    "indent": [
        true,
        "tab"
    ],
    "variable-name": [
        true,
        "ban-keywords",
        "check-format",
        "allow-leading-underscore"
    ],
    "prefer-const": false,
    "no-var-keyword": false,
    "only-arrow-functions": [false],
    "space-before-function-paren": [
        true,
        {
            "anonymous": "always",
            "named": "never",
            "asyncArrow": "always"
        }
    ],
    "curly": [true, "as-needed"],
    "no-empty": false,
    "one-variable-per-declaration": [false],
    "one-line": [true, "check-catch", "check-finally", "check-open-brace", "check-whitespace"]
},
"rulesDirectory": []

}

0 个答案:

没有答案