ESLint
The library provides default ESLint configurations.
Default
Under the hood this is mostly AirBnB ESLint config, with just a few rules modified, and Babel parser, module resolver configured (in the way compatible with Babel presets provided by this library).
To include it into ESLint config:
{
"extends": "./node_modules/@dr.pogodin/react-utils/config/eslint/default.json"
}
The modified rules are:
- jsx-a11y/anchor-is-valid is configured to be compatible with Link components.
- no-plusplus is disabled,
thus allowing unary
++
and--
operators in JS(X) code. - react/jsx-one-expression-per-line is disabled, thus allowing for multiple JSX expressions in the same line, which allows for a way more readable markup in many cases.
- react/jsx-uses-react
and
react/react-in-jsx-scope
are disabled, as the latest ReactJS versions do not require to explicitly
import
React
into JSX files.
Jest
NOTE: Since v1.26.0 it should be included in addition to the default or Typescript config!
This configuration slightly extends default config to be used to lint JS code intended for Jest test environment.
To include it into ESLint config:
{
"extends": "./node_modules/@dr.pogodin/react-utils/config/eslint/jest.json"
}
On top of default configuration this config:
- Enables
browser
andjest
environment targets, and addsjest
ESLint plugin. - Disables global-require, import/no-dynamic-require, and import/no-extraneous-dependencies rules to allow in tests local and conditional requires, as well as requires of development dependencies.
- Disables no-console rule, allowing console use in tests.