Global repo for how linting and code styling should be done for Synatic projects.
In the root of the project is a .eslintrc.json
file, this is where the majority of the rules, plugins and config will live and where you should primarily be making changes. The base file is for node projects that use mocha. You can test out changes to the base config by adding code to the ./lib-examples/
folder and your editor should be able to pick up any issues with the code which will allow you to refine the rules and verify that they work the way you would like them too.
Once you have the rules setup the way you would like to you can run the npm run copy
command and this will take the config in the .eslintrc.json
file and copy it to ./lib/index.js
where it will be used in other projects once published.
The library also supports more advanced configuration for other project types, for example projects that use jest can make use of both the base configuration file in the root together with the jest specific config in ./lib/jest.js
by having their project extend @synatic/eslint-config-synatic-node/lib/jest
. Currently there is no way to test these specific configurations in this project without copying them to the .eslintrc.json
file and testing them, but do not leave them there when committing or else they will apply to the shared base configuration.
Once you have made all the above changes and ran the npm run copy
command you can commit to git
run the npm version <major,minor,patch>
command to increment the version, push to develop and submit a PR as normal.
To add the shared configuration to your project you can do the following:
- run
npm i -D @synatic/eslint-config-synatic-node
in your project - create a
.eslintrc.json
file in your project - Add the following code:
{ "env": {}, "extends": ["@synatic/eslint-config-synatic-node"], "globals": {}, "parserOptions": {}, "overrides": [], "rules": {} }
- If you would prefer to use a different config from the base one, simply replace the
extends
in the above example with your desired one. - create a
.prettierrc.json
in your project and inside it add the code from this repositories version of the file as this will be the most up to date version - Install the peer dependencies listed in this project's
package.json
file, which can be found underpeerDependencies
- Ensure your package.json has the correct engine section, e.g.:
"engines": {
"node": ">=14.0.0",
"npm": ">=6.0.0"
},
- Ensure your package.json has the required scripts:
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"lint-errors": "eslint . --quiet",
"prettier": "prettier . --write"
- @synatic/eslint-config-synatic-node
- @synatic/eslint-config-synatic-node/lib/jest