Perfective ESLint Config
@perfective/eslint-config
provides
a shareable ESLint configuration
that is used for the development of the @perfective
packages.
These rules are primarily configured for TypeScript projects.
In addition to the core ESLint rules,
@typescript-eslint
,
and ESlint Stylistic plugin rules,
@perfective/eslint-config
includes configurations for the ESLint plugins:
eslint-plugin-array-func
;eslint-plugin-cypress
(optional);eslint-plugin-eslint-comments
;eslint-plugin-import
;eslint-plugin-jest
(optional);eslint-plugin-jest-dom
(optional);eslint-plugin-jsdoc
;eslint-plugin-n
;eslint-plugin-prefer-arrow
;eslint-plugin-promise
;eslint-plugin-rxjs
(optional);eslint-plugin-security
;eslint-plugin-simple-import-sort
;eslint-plugin-testing-library
(optional);eslint-plugin-unicorn
.
To simplify configuring ESLint support in the IDEs and editors,
the severity of all fixable rules is a warning
.
In addition, it allows distinguishing errors that have to be fixed manually
from issues that will be fixed automatically.
Setup
@perfective/eslint-config
only support ES module syntax.
If your project uses CommonJS by default
you need to use eslint.config.mjs
file instead of eslint.config.js
to run it in ESM mode.
Install
@perfective/eslint-config
as a dev dependency:npm install --save-dev \ @perfective/eslint-config
Required peer dependencies are installed automatically.
Import
perfectiveEslintConfig
toeslint.config.js
.import { perfectiveEslintConfig } from '@perfective/eslint-config'; const eslintConfig = perfectiveEslintConfig(); export default eslintConfig;
Optional Install optional peer dependencies to add tool-specific linting rules.
npm install --save-dev \ eslint-plugin-cypress \ eslint-plugin-jest \ eslint-plugin-jest-dom \ eslint-plugin-rxjs-x \ eslint-plugin-testing-library
Import configurations to
eslint.config.js
.import { perfectiveEslintConfig } from '@perfective/eslint-config'; // Optional dependencies. import { cypressConfig } from '@perfective/eslint-config/cypress'; import { jestConfig } from '@perfective/eslint-config/jest'; import { jestDomConfig } from '@perfective/eslint-config/jest-dom'; import { rxjsConfig } from '@perfective/eslint-config/rxjs'; import { testingLibraryConfig } from '@perfective/eslint-config/testing-library'; const eslintConfig = perfectiveEslintConfig([ cypressConfig, jestConfig, jestDomConfig, rxjsConfig, testingLibraryConfig, ]); export default eslintConfig;
Optional Customize configuration rules in
eslint.config.js
import { perfectiveEslintConfig, typescriptFiles } from '@perfective/eslint-config'; const eslintConfig = perfectiveEslintConfig([ // ...Optional configurations... { // These rules are overridden to all files rules: { '@stylistic/js/indent': ['warn', 2], }, }, { // These rules are overridden to TypeScript files only files: typescriptFiles, rules: { '@stylistic/ts/indent': ['warn', 2], }, }, ]); export default eslintConfig;
Read full documentation
in the repo.