简体   繁体   中英

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.

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.

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 .

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:

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

...then you can run it via npm run check


To provide a quick way to yourself to fix most coding style typos, add a fix script to your package.json :

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

...and run via 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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