This is our configuration for linting JavaScript and TypeScript. It's a shared config for ESLint. See here for documentation on shared configs.
To use the config in another project, first install the dependency (and eslint):
npm install --save-dev eslint @spielworksdev/eslint-config
Then write a config file (for Typescript projects):
# .eslintrc.yml
extends:
- '@spielworksdev'
This will make the config usable in any NPM script running the linter.
If the project is a Javascript project, use
# .eslintrc.yml
extends:
- '@spielworksdev/eslint-config/javascript'
You might need to set the env
key as well depending on your project.
env:
node: true
browser: true
If your project has multiple environments, multiple .eslintrc.yml
files might be necessary.
This could be the case for CDK and tests.
If your project uses CDK and is not otherwise a Node.js project, add a file cdk/.eslintrc.yml
with the content
env:
node: true
While working on the shared config itself it is useful to work
with npm link
. This allows to use the local version of the config
in other projects without publishing.
First, in the directory of this project run
npm link
Then in another project that consumes the config, run
npm link --install-links @spielworksdev/eslint-config
The --install-links
parameter is required to install the
required peer dependencies.