Recommended ESLint presets by Code PushUp.
Stack | Config | Description |
---|---|---|
@code-pushup | Default config, suitable for any JavaScript/TypeScript project. | |
@code-pushup/eslint-config/typescript | Config for strict TypeScript projects. | |
@code-pushup/eslint-config/node | Config for Node.js projects. | |
@code-pushup/eslint-config/angular | Config for Angular projects. | |
@code-pushup/eslint-config/angular-ngrx | Config for Angular projects using NgRx library. | |
@code-pushup/eslint-config/graphql | Config for GraphQL servers implemented in Node.js. | |
@code-pushup/eslint-config/jest | Config for projects using Jest for testing. | |
@code-pushup/eslint-config/vitest | Config for projects using Vitest for testing. | |
@code-pushup/eslint-config/cypress | Config for projects using Cypress for testing. | |
@code-pushup/eslint-config/storybook | Config for projects using Storybook for UI components. |
Some configs extend other configs, as illustrated below. So, for example, adding "extends": ["@code-pushup/eslint-config/angular"]
implicitly includes @code-pushup/eslint-config/typescript
and @code-pushup
as well.
graph BT;
index("@code-pushup")
typescript("@code-pushup/eslint-config/typescript")
node("@code-pushup/eslint-config/node")
angular("@code-pushup/eslint-config/angular")
angular-ngrx("@code-pushup/eslint-config/angular-ngrx")
graphql("@code-pushup/eslint-config/graphql")
typescript --extends--> index
node --extends--> index
angular --extends--> typescript
angular-ngrx --extends--> angular
graphql --extends--> node
To use the default config, follow these steps:
-
You must first install all the required peer dependencies (if you haven't already):
npm install -D eslint @typescript-eslint/{eslint-plugin,parser} eslint-plugin-{functional,import,promise,sonarjs,unicorn}
-
Install
@code-pushup/eslint-config
with:npm install -D @code-pushup/eslint-config
-
Add default config to
extends
section in your ESLint configuration file (usually called.eslintrc.json
or.eslintrc.js
):{ "extends": ["@code-pushup"] }
Depending on your tech stack, you may wish to extend other configs as well (listed above). This will require installing additional peer dependencies. For more details, refer to setup docs for the configs you're interested in using.
All peer dependencies used by @code-pushup/eslint-config
are listed below, along with their supported versions. Only the default config's dependencies are required, others are optional.
NPM package | Version | Required | |
---|---|---|---|
eslint | ^8.0.0 |
✅ | |
@typescript-eslint/eslint-plugin | ^6.0.0 || ^7.0.0 |
✅ | |
@typescript-eslint/parser | ^6.0.0 || ^7.0.0 |
✅ | |
eslint-plugin-functional | ^6.0.0 |
✅ | |
eslint-plugin-import | ^2.25.0 |
✅ | |
eslint-import-resolver-typescript | ^3.0.0 |
||
eslint-plugin-promise | ^6.0.0 |
✅ | |
eslint-plugin-sonarjs | >=0.22.0 |
✅ | |
eslint-plugin-unicorn | >=48.0.0 |
✅ | |
@angular-eslint/eslint-plugin | ^17.0.0 || ^18.0.0 |
||
@angular-eslint/eslint-plugin-template | ^17.0.0 || ^18.0.0 |
||
@angular-eslint/template-parser | ^17.0.0 || ^18.0.0 |
||
@graphql-eslint/eslint-plugin | ^3.0.0 |
||
@ngrx/eslint-plugin | ^17.0.0 || ^18.0.0 |
||
eslint-plugin-cypress | ^2.0.0 |
||
eslint-plugin-deprecation | ^2.0.0 || ^3.0.0 |
||
eslint-plugin-jest | ^27.0.0 || ^28.0.0 |
||
eslint-plugin-jest-formatting | ^3.0.0 |
||
eslint-plugin-n | ^16.0.0 |
||
eslint-plugin-rxjs | ^5.0.0 |
||
eslint-plugin-storybook | >=0.6.0 |
||
eslint-plugin-vitest | >=0.3.0 |
For non-production code, some rules are disabled (or downgraded from errors to warnings).
This applies to file paths matching any of the following globs:
*.spec.?(c|m)[jt]s?(x)
*.test.?(c|m)[jt]s?(x)
**/__tests__/**/*.?(c|m)[jt]s?(x)
**/__mocks__/**/*.?(c|m)[jt]s?(x)
*.cy.?(c|m)[jt]s?(x)
*.stories.?(c|m)[jt]s?(x)
*.e2e.?(c|m)[jt]s?(x)
*.mock.?(c|m)[jt]s?(x)
*.mocks.?(c|m)[jt]s?(x)
**/test/**/*.?(c|m)[jt]s?(x)
**/tests/**/*.?(c|m)[jt]s?(x)
**/mocks/**/*.?(c|m)[jt]s?(x)
**/testing-utils/**/*.?(c|m)[jt]s?(x)
**/test-utils/**/*.?(c|m)[jt]s?(x)
**/fixtures/**/*.?(c|m)[jt]s?(x)
*.config.?(c|m)[jt]s
.prettierrc.?(c|m)[jt]s
codegen.?(c|m)[jt]s
test-setup.?(c|m)[jt]s
Node.js installation is a prerequisite (LTS version). Install dependencies with NPM:
npm install
To execute tests:
npm test
To generate documentation:
npm run docs