typescript - Sublime Text 3 Typescript 不允许缩进和单引号

标签 typescript sublimetext3 sublimelinter

嗨,我正在使用 sublime 3 用 typescript 语言构建一个 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
}

}

这些问题实际上并不影响项目,但错误迹象确实让我很恼火。有人有解决办法吗?

最佳答案

您需要告诉 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

关于typescript - Sublime Text 3 Typescript 不允许缩进和单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41371096/

相关文章:

javascript - 在 Angularjs+Typescript 中将 GZip Json 字符串解压缩为普通 Json 字符串

javascript - 配置 SublimeLinter 以忽略尾随空格

node.js - 如何从数据库中清除过期的 token ?

dojo - 接口(interface)上的 typescript 类型?

google-chrome - Sublime Text 3 + Markdown Preview/Chrome 不渲染数学方程

python - Sublime Text 3 的 REPL 错误

go - "go run"使用 sublime text 3 进入无限循环

sass - 如何忽略Sublime Linter SCSS(Sass)中的特定规则?

sublimetext - sublimelinter-php 和 sublimelinter-phpcs 有什么区别?

typescript - TypeScript 中的递归泛型