简体   繁体   English

同步VSCode linting和vue-cli linting

[英]Synchronising VSCode linting with vue-cli linting

I've created a new project with the Vue CLI with options like Typescript and Airbnb linter enabled, which works fine itself, but now I want this linting to show in the VSCode editor, not just as execution errors when the project is served. 我已经使用Vue CLI创建了一个新项目,并启用了Typescript和Airbnb linter等选项,它们本身也可以正常工作,但是现在我希望这种棉絮在VSCode编辑器中显示,而不仅仅是在服务项目时出现执行错误。 This seems to have got me down a rabbit hole of installing different extension that all have different config files, that all have their own particularities, up to the point where I can't satisfy the linter because of problems like single quotes or double quotes that it wants to bounce back and forth between using. 这似乎使我陷入了安装不同扩展名的麻烦,这些扩展名都有不同的配置文件,它们都有各自的特殊性,直到由于单引号或双引号之类的问题而令我不满意为止。它想在使用之间来回跳动。

I'm under the impression that there isn't a good way to get the rules of the linter for the Vue server concurrent (from the same ruleset) with the ones that the extensions for VSCode use. 我给人的印象是,没有一种好方法(与同一个规则集)同时获取VSCode扩展使用的Vue服务器的linter规则。 I'm trying to use the Airbnb linting rules and even if I independently install the ruleset for VSCode and via NPM separately, they still don't align. 我正在尝试使用Airbnb规则,即使我分别为VSCode和通过NPM独立安装规则集,它们仍然无法对齐。

Any advice on remedying this/getting VSCode to replicate the serve linter's ruleset? 关于纠正此问题/获取VSCode以复制服务linter的规则集的任何建议吗?

Turns out that all of my VSCode extensions apart from ESLint needed to be uninstalled (Despite me trying to use Typescript [which has TSLint] and Vue components [which have their own, yet again separate linter]) 事实证明,除了ESLint之外,我所有的VSCode扩展都需要卸载(尽管我试图使用Typescript [具有TSLint]和Vue组件[具有自己的,又是独立的linter])

Just needed this user/workspace config: 只需此用户/工作区配置:

"eslint.validate": [
    {
        "language": "vue",
        "autoFix": true
    },
    {
        "language": "html",
        "autoFix": true
    },
    {
        "language": "javascript",
        "autoFix": true
    },
    {
        "language": "typescript",
        "autoFix": true
    }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM