Eslint rule configs for Javascript and Vue.js projects.
To install, add it with eslint
to your dev dependencies.
# With yarn
yarn add -D eslint @fireworkweb/eslint-config
# With npm
npm install --dev eslint @fireworkweb/eslint-config
Currently there are two configs available: js
for pure javascript projects, vue
for Vue.js projects and react
for React projects. The vue
and react
configs already includes the js
config.
After installing, create a .eslintrc.js
file and add this to your config (add only one):
module.exports = {
extends: [
// for javascript project
'@fireworkweb/eslint-config/js',
// for vue project
'@fireworkweb/eslint-config/vue',
// for react project
'@fireworkweb/eslint-config/react',
],
};
Also, you should add this script to your package.json
:
{
// ...
"scripts": {
// ...
"lint": "eslint --ext js,vue,jsx ."
}
}
You should customize the extensions (--ext
parameter) to fit your needs.
Then you can run yarn lint
or npm run lint
. To automatically fix some of the errors, you can add --fix
to the lint command.
You can customize any rules (js, vue), react) as this example:
module.exports = {
extends: [
'@fireworkweb/eslint-config/js',
],
rules: {
'no-console': 'off',
},
};
You can also (and probably will) add any specific global variable:
// for vue project
module.exports = {
extends: [
'@fireworkweb/eslint-config/vue',
],
globals: {
Vue: true, // if you set window.Vue
_: true, // lodash/underscore
Nova: true, // Laravel Nova
},
};
MIT.
@gabrielboliveira |
@nkabz |
---|