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
- Configuring VSCode so linting and auto-fixing work
- Maintenance
- Publishing
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
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"
- 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"]
}
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.
In github.com go to personal settings -> developer settings -> personal access tokens / tokens (classic). (you should be in https://github.com/settings/tokens) Click Generate new token -> Generate new token (classic) Give it a name, select options
workflow
write:packages
read:public_key
Copy the new key.
Add this to your project's .npmrc
//npm.pkg.github.com/:_authToken=${NPM_GITHUB_TOKEN}
@vocovo:registry=https://npm.pkg.github.com
These connect by having your new key as an env variable named NPM_GITHUB_TOKEN
!
- Create a PR which bumps the version number and get it reviewed and merged
- Git will already create tags
- Create a release on Github with the new version as the tag and title (no description needed), the release should target
main
- Checkout
main
, make sure the branch is up to date, and runnpm publish
. - In whatever project that uses this new version run
npm i
ornpm update
...- This project will also require
.npmrc
to hold the auth token
- This project will also require