ESLint Auto Fix on Nuxt.js

A quick solution to automatically lint-fix your files upon save on Nuxt.js using the eslint module.

Published on April 7, 2020

Regardless what the documentation says, you can automatically lint your files just by including the module’s option within your nuxt configuration file, no extra loaders or anything!

Note: You must have @nuxtjs/eslint-module installed, otherwise this won’t work.

Modify your configuration so it looks like this:

// nuxt.config.js

export default {
  buildModules: ['@nuxtjs/eslint-module'],
  eslint: {
    fix: true
  }
}

Now whenever you save your code it will automatically be fixed (not everything can be fixed automatically) by the eslint module, you can for example ignore indentation, new-lines and white space while typing, because it will be fixed anyway upon save.

Thanks for reading and cya in the next post!

how-todevnuxt

Marlos Pomin
Full Stack Developer & Retoucher based in Brazil, also a casual pentester.