Search code examples
javascriptwebpackvue.jseslintstandardjs

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 :)


Solution

  • 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"
      }
    }