My JavaScript Styleguide for ESLint.
npm install @edwmurph/eslint-config --save-dev
Use npm scripts to lint JS, e.g. npm run lint
:
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
alternatively if you are using the Vue config, you'll also need to tell eslint to look for .vue
files:
"scripts": {
"lint": "eslint . --ext .js,.vue",
"lint:fix": "eslint . --fix --ext .js,.vue"
}
Add an .eslintrc.js
file at the root of the repo extending the eslint config for the target project type
module.exports = {
root: true,
extends: [
'@edwmurph/eslint-config',
// uncomment this if you are building a chrome extension
// '@edwmurph/eslint-config/webextensions'
]
};
module.exports = {
root: true,
extends: [
'@edwmurph/eslint-config/gatsby',
// uncomment this if you are building a chrome extension
// '@edwmurph/eslint-config/webextensions'
]
};
module.exports = {
root: true,
extends: [
'@edwmurph/eslint-config/react',
// uncomment this if you are building a chrome extension
// '@edwmurph/eslint-config/webextensions'
]
};
module.exports = {
root: true,
extends: [
'@edwmurph/eslint-config/nextjs',
// uncomment this if you are building a chrome extension
// '@edwmurph/eslint-config/webextensions'
]
};
module.exports = {
root: true,
extends: [
'@edwmurph/eslint-config/vue',
// uncomment this if you are building a chrome extension
// '@edwmurph/eslint-config/webextensions'
]
};
also for vue configs you need to update your lint scripts to look for vue files:
"scripts": {
"lint": "eslint . --ext .js,.vue",
"lint:fix": "eslint . --fix --ext .js,.vue"
}
also currently eslint@8 is not compatible with @vue/[email protected] so you may temporarilly need to workaround this by also installing an older verison of eslint via:
npm install -d [email protected]