eslint-plugin/README.md

111 lines
2.3 KiB
Markdown
Raw Normal View History

2019-05-24 21:08:25 +05:30
# Ely.by ESLint rules
Set of ESLint rules used in development of Ely.by JS projects. Contains rules for pure JS, JSX, ReactJS and TS.
## Installation
2019-05-29 02:02:01 +05:30
First of all install Ely.by ESLint plugin and `eslint` peer dependency via NPM:
2019-05-24 21:08:25 +05:30
```sh
npm install @elyby/eslint-plugin eslint --save-dev
2019-05-29 02:02:01 +05:30
```
Or via yarn:
```sh
2019-05-24 21:08:25 +05:30
yarn add -D @elyby/eslint-plugin eslint
```
2019-05-29 02:02:01 +05:30
## Configuration
The configuration is divided into several parts. The `base` provides only pure js checks. To use it,
simply add the `plugin:@elyby/base` configuration to the `extends` block:
```json
{
"extends": [
"plugin:@elyby/config"
]
}
```
### React
The configuration for React requires additional dependencies. Install them first:
```sh
# NPM:
npm install eslint-plugin-react eslint-plugin-react-hooks --save-dev
# Yarn:
yarn add -D eslint-plugin-react eslint-plugin-react-hooks
```
Then add the `plugin:@elyby/react` configuration to the `extends` block:
2019-05-24 21:08:25 +05:30
2019-05-29 02:02:01 +05:30
```json
{
"extends": [
"plugin:@elyby/config",
"plugin:@elyby/react"
]
2019-05-24 21:08:25 +05:30
}
```
2019-05-29 02:02:01 +05:30
### TypeScript
Configuration for TypeScript also requires additional libraries:
```sh
# NPM:
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
# Yarn:
yarn add -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
```
Then add the `plugin:@elyby/react` configuration to the `extends` block:
```json
{
"extends": [
"plugin:@elyby/config",
"plugin:@elyby/typescript"
]
}
```
2019-05-24 21:08:25 +05:30
You may still wish to override some of our rules, as well as the rest of our eslint configuration settings.
For example, you can specify the preferred `env` for eslint:
2019-05-29 02:02:01 +05:30
```json
{
"env": {
"browser": true,
"es6": true
}
}
2019-05-24 21:08:25 +05:30
```
## Using our custom fixers
First of all, you must install Ely.by's ESLint plugin as described in the [installation chapter](#installation).
After that you can enable our custom rules with defining our plugin in `plugins` section:
2019-05-29 02:02:01 +05:30
```json
{
"plugins": [
"@elyby"
]
}
2019-05-24 21:08:25 +05:30
```
After that all custom rules will be available for use.
### List of supported rules
* [@elyby/jsx-closing-bracket-location](docs/rules/jsx-closing-bracket-location.md):
Validate closing bracket location in JSX
## License
Ely.by ESLint plugin is licensed under the [MIT License](LICENSE.md).