Sublime Text 3 Typescript选项卡缩进和单引号不允许

时间:2016-12-28 23:22:52

标签: typescript sublimetext3 sublimelinter

您好我使用sublime 3以打字稿语言构建node.js服务器。编辑总是给我两个没有意义的错误。一个是它要求我使用双引号而不是单引号。另一个是它只允许双倍空格作为缩进。

以下是它的样子: issue screen shot

这是我的SublimeLinter用户设置:

{
"user": {
    "debug": false,
    "delay": 0.25,
    "error_color": "D02000",
    "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
    "gutter_theme_excludes": [],
    "lint_mode": "background",
    "linters": {
        "jshint": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "tslint": {
            "@disable": false,
            "args": [],
            "excludes": [],
            "indent": 4
        }
    },
    "mark_style": "outline",
    "no_column_highlights_line": true,
    "passive_warnings": false,
    "paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "python_paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "rc_search_limit": 3,
    "shell_timeout": 10,
    "show_errors_on_save": false,
    "show_marks_in_minimap": true,
    "syntax_map": {
        "html (django)": "html",
        "html (rails)": "html",
        "html 5": "html",
        "javascript (babel)": "javascript",
        "magicpython": "python",
        "php": "html",
        "python django": "python",
        "pythonimproved": "python"
    },
    "warning_color": "DDB700",
    "wrap_find": true
}

}

问题实际上并没有影响项目,但错误迹象确实让我烦恼不已。有没有人有任何想法来解决它?

1 个答案:

答案 0 :(得分:2)

您需要告诉SublimeLinter-contrib-tslint不要报告这些警告。最简单的方法是将tslint.json文件添加到您的计算机,然后将SublimeLinter.sublime-settings文件更改为如下所示。

<强> tslint.json

{
    "rules": {
        "indent": false,
        "quotemark": false,
    }
}

<强> SublimeLinter.sublime定形

{
"user": {
    "debug": false,
    "delay": 0.25,
    "error_color": "D02000",
    "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
    "gutter_theme_excludes": [],
    "lint_mode": "background",
    "linters": {
        "jshint": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "tslint": {
            "@disable": false,
            "args": [],
            "excludes": [],
            "indent": 4,
            "config_filename": "tsconfig.json"
        }
    },
    "mark_style": "outline",
    "no_column_highlights_line": true,
    "passive_warnings": false,
    "paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "python_paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "rc_search_limit": 3,
    "shell_timeout": 10,
    "show_errors_on_save": false,
    "show_marks_in_minimap": true,
    "syntax_map": {
        "html (django)": "html",
        "html (rails)": "html",
        "html 5": "html",
        "javascript (babel)": "javascript",
        "magicpython": "python",
        "php": "html",
        "python django": "python",
        "pythonimproved": "python"
    },
    "warning_color": "DDB700",
    "wrap_find": true
}

注意:添加的"config_filename": "tsconfig.json"键值应指向配置文件的绝对路径

您也可以删除SublimeLinter-contrib-tslint包。

有关包的更多信息,您还可以查看存储库README文件。 https://github.com/lavrton/SublimeLinter-contrib-tslint