@kode-frontend/eslint-config
Version:
Shareable ESLint config enforcing best practices
129 lines (87 loc) • 2.43 kB
Markdown
Описание [на русском](https://github.com/appKODE/frontend-depend/blob/main/packages/eslint-config/docs/README-ru.md)
[![Version][version-badge]][package]
Add `@kode-frontend/eslint-config` dependency to your project.
```shell
npm install --save-dev @kode-frontend/eslint-config
yarn add -D @kode-frontend/eslint-config
pnpm install -D @kode-frontend/eslint-config
```
There are two configurations to extend this shared config.
Contains:
- React
- Typescript
- Jest
```json
// .eslintrc.cjs
{
"extends": ["@kode-frontend/eslint-config/web"]
}
```
Contains:
- React Native
- Typescript
- Jest
```json
// .eslintrc.cjs
{
"extends": ["@kode-frontend/eslint-config/native"]
}
```
You can optionally add sort configuration to the web and native configs.
```json
// .eslintrc.cjs
{
"extends": [
"@kode-frontend/eslint-config/{web/native}",
"@kode-frontend/eslint-config/sort"
]
}
```
It will sort the enums, interfaces, jsx props, maps, object types, objects, union types, and more. You can find more details in [this documentation]().
It can be useful to have a diff that is easier to read, or to have consistent code.
You can _override rules_ from the shared configuration, by setting your own values within the rules property:
```json
// .eslintrc.cjs
{
"extends": "@kode-frontend/eslint-config/{web,native}",
"rules": {
"react/jsx-newline": "warn"
}
}
```
You might also need to add the following to your ESLint config if you get an error about Jest not being able to detect the version:
```json
// .eslintrc.cjs
{
"settings": {
"jest": { "version": "detect" }
}
}
```
Some commonly used scripts in `package.json`.
```json
// package.json
{
"scripts": {
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --fix --ext ts,tsx"
}
}
```
If you get an error about "EEXIST: file already exists, mkdir \* info ..."
Just uninstall `@kode-frontend/eslint-config`.
[]: https://img.shields.io/npm/v/@kode-frontend/eslint-config.svg?style=flat-square
[]: https://www.npmjs.com/package/@kode-frontend/eslint-config