@lidofinance/eslint-config
v0.46.0
Published
Automated, non-opinionated ESLint config foundation
Downloads
1,337
Readme
Lido ESint config
Automated, non-opinionated ESLint config foundation
❗ Please note that this ESLint config is still 0.x and is subject to significant changes; it is mainly used by internal Lido teams.
Installation
npm install --dev @lidofinance/eslint-config
# and plugins
npm install --dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-import-resolver-typescript eslint-plugin-eslint-comments eslint-plugin-import eslint-plugin-jest eslint-plugin-promise eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-sonarjs eslint-plugin-unicorn @next/eslint-plugin-next
If using TypeScript, alter tsconfig.json
line includes
to include everything, like that:
"include": ["**/*","**/.*"]
ℹ️ Modern module resolution ESLint patch by Rush team is intentionally not used, as it conflicts with same patch in
@next/eslint-plugin
.
Configuration
Style rules are intentionally not provided; bring your own code style, whatever it is - prettier, airbnb, xo or standard.
// .eslintrc.js.js
{
"root": true,
"extends": [
// note: use every other config BEFORE @lidofinance config,
// EXCEPT prettier; prettier is bundled with multiple
// disable rules that should be turned off to avoid conflicts
//"airbnb",
"@lidofinance",
//"prettier"
]
}
What's inside
@lidofinance/eslint-config
is feature-packed config that ships with some logic.
Following assumptions are done:
- ES version target is latest (2022); if you need other, change
env
in.eslintrc
- code is always server-ready
- code is client-ready if
react
package is present - there is no magic resolution mechanism and usage of webpack loaders; only explicit file paths and
tsconfig.json
paths
are considered - latest version of TypeScript (4.6.x) and ESLint (^8.13) are used
For performance, developer experience and accuracy reasons some rules will turn on if following conditions will happen:
React
package is declared inpackage.json
react
,react-hooks
rules will be used
Next
package is declared inpackage.json
next
plugin rules will be used- react rule
react/react-in-jsx-scope
will turn off
Jest
package is declared inpackage.json
jest
plugin rules will be used- some rules will be disabled (like "avoid code duplication" and "do not use any") for test-specific file patterns
Typescript
package is declared inpackage.json
:typescript-eslint
rules will be enabled- parser will be switched to typescript-eslint
- if
tsconfig.json
is present, type-level lint rules will be enabled - if
compilerOptions.strict
istrue
, additional anti-any rules will be enabled