Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

potentially fixable with the `--fix` option

I am creating a app with nuxt.js but everytime I launch the app, gives me the error of eslint and saying "potentially fixable with the --fix option."

I did the command npm run lint -- --fix and it works but then If I do another change in any vue file it comes again the same error and I have to do it again

Any idea of how to fix that?

like image 560
Ricardo Moreira Avatar asked Jan 13 '19 21:01

Ricardo Moreira


People also ask

What is the -- fix option?

Aug 7, 2020. ESLint's --fix option tells ESLint to fix whatever errors in your code that it knows how to fix.

What ESLint-- fix does?

npx eslint --fix . It fixes all files.

How do I fix ESLint errors at once?

If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ).


2 Answers

Use the below configuration into nuxt config file:

 build: {       extend(config, ctx) {         config.module.rules.push({           enforce: 'pre',           test: /\.(js|vue)$/,           loader: 'eslint-loader',           exclude: /(node_modules)/,           options: {             fix: true           }         })     }   } 

Important part is:

options: {   fix: true } 
like image 115
Mahamudul Hasan Avatar answered Sep 17 '22 14:09

Mahamudul Hasan


Extend the build in the nuxt.config.js file

build: {   extend(config, ctx) {     config.module.rules.push({       enforce: "pre",       test: /\.(js|vue)$/,       loader: "eslint-loader",       exclude: /(node_modules)/,       options: {         fix: true       }     })   } } 
like image 38
Nilanshu Jaiswal Avatar answered Sep 17 '22 14:09

Nilanshu Jaiswal