简体   繁体   English

如何切换到不同的ESLint样式指南?

[英]How can I switch to a different ESLint style guide?

I started a new Vue project with vue-cli and Webpack and configured ESLint to Airbnb's style guide. 我开始与VUE-CLI和的WebPack和配置ESLintAirbnb的风格指南新Vue公司的项目。

How can I change this choice to a Standard style? 如何将此选项更改为标准样式? I am getting really tired of the surplus in commas and semicolons, and want to give it Standard JS a try. 我对逗号和分号的过剩感到非常厌倦,并希望尝试使用标准JS

I am working alone at this project right now, so do not worry about team complains :) 我现在正在这个项目独自工作,所以不要担心团队抱怨:)

Just install StandardJS via npm install standard --save-dev . 只需通过npm install standard --save-dev安装StandardJS即可

Then run through the rules just to quickly get a feel of it. 然后执行规则只是为了快速了解它。

Finally, create a script in your package.json to run StandardJS, when you need it: 最后, 在package.json中创建一个脚本,以便在需要时运行StandardJS:

{
  "scripts": {
    "check": "standard"
  }
}

...then you can run it via npm run check ...然后你可以通过npm run check运行它


To provide a quick way to yourself to fix most coding style typos, add a fix script to your package.json : 要为自己提供快速修复大多数编码风格拼写错误的方法, 请在package.json中添加修复脚本

{
  "scripts": {
    "check": "standard",
    "fix": "standard --fix"
  }
}

...and run via npm run fix ...并通过npm run fix


To get a more nicer representation of coding style errors, install snazzy via npm install snazzy --save-dev , then modify your package.json like so: 为了获得编码风格的错误的更多更好的代表性 ,通过安装时髦 npm install snazzy --save-dev ,然后修改您的package.json像这样:

{
  "scripts": {
    "check": "standard --verbose | snazzy",
    "fix": "standard --fix"
  }
}

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

相关问题 如何将 eslint airbnb 风格指南合并成一个文件以复制到 package.json 中? - How can I concatinate the eslint airbnb style guide into one file to copy into package.json? ESLint 问题:标准指南,还是流行的风格指南 - ESLint Question: Standard guide, or a popular style guide Eslint样式指南无法在Visual Studio代码中检测到 - Eslint style guide not detect in visual studio code 如何使Airbnb的JavaScript样式eslint指南与React,ES6一起在vim中工作? - How to get Airbnb's JavaScript style eslint guide working in vim with react, es6? 在ESlint中强制执行“换行样式”规则有多重要? 我可以关掉它吗? - How important is to enforce the “linebreak-style” rule in ESlint? Can I just turn it off? 带有 Airbnb 风格指南的 ESLint 不适用于所有规则 - ESLint with Airbnb style guide does not work for all rules 我如何为“linebreak-style”编写 ESLint 规则,根据 Windows 或 Unix 进行更改? - How can I write a ESLint rule for "linebreak-style", changing depending on Windows or Unix? 如何使用 Airbnb JavaScript 风格指南设置 Prettier - How do I set up Prettier with Airbnb JavaScript Style Guide 如何运行Airbnb javascript样式指南中的代码? - How do I run the code in the Airbnb javascript style guide? 我如何更改eslint解决设置 - How I can change eslint resolve settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM