Eslint not fixing Vue files
-
Hi,
I have some components made already but definitely decided to move to Quasar.
I was not writing accordingly to current standards so I need to clean up code now…I have cleaned all JS files by runing Eslint fix by PHPStorm but I can’t run for Vue files.
I was trying to find solution to run fix on Vue files from npm script.
I did add:
"lint-fix": "eslint --fix --ext .js,.vue src"
It is throwing all errors, but not fixing them as it suppose to do.I would really appreciate help with that.
-
Does this help? https://github.com/vuejs/vue-loader/issues/155
-
Adding this since it is one of the top search results and the link above doesn’t directly answer the question of how to automatically fix style errors with elint.
As of Aug 2020, all I had to do was add options: {fix: true,} to the eslint-loader webpack config in quasar.conf.js. Here’s the full section:
// https://quasar.dev/quasar-cli/handling-webpack extendWebpack (cfg) { cfg.module.rules.push({ enforce: 'pre', test: /\.(js|vue)$/, loader: 'eslint-loader', exclude: /node_modules/, options: { fix: true, } }) }
-
If you choose prettier with the creation of your Quasar project it will auto fix your code too.( without the need to add the option)