eslint-config-vocovo
v2.0.0
Published
A reasonable lint standard for VoCoVo javascript projects. Uses ESLint and Prettier
Downloads
1,348
Readme
eslint-config-vocovo
This VoCoVo linting standard expects developers to use Prettier for code formatting, and ESLint for code smell. This config uses Prettier both inside and outside ESLint. ESLint is only concerned with Javascript, but Prettier can format many different languages. The detail below explains how to use Prettier to good effect in both situations.
Installation in your project
You will need to have eslint
and prettier
installed to use this: npm install --save-dev eslint prettier
.
Install with:
npm install --save-dev eslint-config-vocovo
Add
"extends": ["vocovo"]
to your.eslintrc
file to enable the config
For formatting independent of ESLint
If you choose to run prettier on its own you will need to give prettier a config. Typically this is done with a .prettierrc
file into which you add rules.
Manually defining/maintaining prettier rules in your own project risks it falling out of sync with this config, so one way to use this project's .prettierrc
file without defining rules manually is to add a "prettier"
key within your package.json
thus:
"prettier": "eslint-config-vocovo/prettierrc"
Configuring VSCode so linting and auto-fixing work
- Install Prettier for VSCode
- Install ESLint for VSCode
- Open the VSCode settings (Code -> Preferences -> Settings) in json mode, using the
{}
symbol in the top right of the setting screen. then, ensure you have at least the following defined:
{
// ESLint auto-fixes JS by using Prettier in the background. ESLint requires one of two possible settings
// depending on the VSCode ESLint plugin version: eslint.autoFixOnSave or editor.codeActionsOnSave.
// When using Prettier on non-JS files, Prettier expects to see editor.formatOnSave.
// Thus both settings are necessary.
// INSTRUCTIONS FOR VSCODE ESLINT PLUGING 1.X (delete as applicable)
"eslint.autoFixOnSave": true,
// INSTRUCTIONS FOR VSCODE ESLINT PLUGING 2.X (delete as applicable)
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
// We enable this here, but _disable_ it (below) on the files we want ESLint to handle.
"editor.formatOnSave": true,
// Turn it OFF for JS and JSX, we will do this via eslint
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
// We want to use vanilla Prettier (i.e not via ESLint) for other languages like CSS and HTML.
// But we turn it off for JS since we are doing it through Eslint
"prettier.disableLanguages": ["javascript", "javascriptreact"]
}
Maintenance
All contributions are welcome and encouraged. If this standard doesn't suit your purposes it would be better that we modify this standard so it does, rather than overriding it within each project.
Publishing
To publish a version:
- Create a PR which bumps the version number and get it reviewed and merged
- Create a release on Github with the new version as the tag and title (no description needed), the release should target
main
- Authorise your NPM account either with
npm login
(if you have an account) or by using thePublish token
listed at the bottom of theNPM - Machine User
entry in 1Password. The publish token should be set in an environment variableNPM_PUBLISH_TOKEN
. If you use the publish token, you will need to use the two factor code in 1Password when publishing. - Checkout
main
, make sure the branch is up to date, and runnpm publish
.