Skip to content

Commit 283b448

Browse files
authored
Refactor/configs directory (#21)
* refactor: create configs directory & add reco & tests * fix: link to eslint-plugin README * docs: update plugin README * refactor: use requireIndex to import configs * docs: update README * docs: add config description and npm command to list peer deps
1 parent 7a0a502 commit 283b448

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There is also an example app under `packages/example-app` whose goal is to demon
1212

1313
## Using the configurations
1414

15-
- [Using ESLint plugin](./packages/eslint/README.md)
15+
- [Using ESLint plugin](./packages/eslint-plugin/README.md)
1616

1717
## Installing the project
1818

packages/eslint-plugin/README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,46 @@
22

33
This project is an ESLint plugin that gathers all the rules, plugins and parsers that should be used in any new BAM project.
44

5-
## How to use the recommended config?
5+
## Shared config
66

7-
In your app, run
7+
The plugin exports multiple configs that can be used in your `.eslintrc` config file:
88

9-
```bash
10-
yarn add --dev @bam.tech/eslint-config @typescript-eslint/eslint-plugin eslint eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-native prettier
11-
```
9+
| Name | Description |
10+
| ------------------------------------- | ----------------------------------------- |
11+
| `@bam.tech/eslint-plugin/recommended` | The recommended config for all projects |
12+
| `@bam.tech/eslint-plugin/tests` | The recommended config for all test files |
1213

13-
In your `.eslintrc` config file, extend the exported recommended configuration:
14+
You should install the correct version for each package. You can see the list using:
1415

15-
```json
16-
// .eslintrc
17-
{
18-
"extends": "plugin:@bam.tech/eslint-plugin/recommended"
19-
}
16+
```bash
17+
npm info "@bam.tech/esling-plugin" peerDependencies
2018
```
2119

22-
## How to use the config for tests ?
20+
With **npm 5+** you can automatically install all the peer dependencies by running:
2321

2422
```bash
25-
yarn add --dev eslint-plugin-jest eslint-plugin-jest-formatting eslint-plugin-testing-library
23+
npx install-peerdeps @bam.tech/eslint-config -D
2624
```
2725

28-
In your `.eslintrc` config file, extend the exported recommended configuration (don't forget to add the overrides to check only the test files)
26+
## How to use?
27+
28+
In your `.eslintrc` config file, extend the exported configurations:
2929

3030
```json
31+
// .eslintrc
32+
{
33+
"extends": "plugin:@bam.tech/eslint-plugin/recommended",
3134
"overrides": [
3235
{
3336
"files": ["*.test.tsx"],
3437
"extends": "plugin:@bam.tech/tests"
3538
}
3639
]
40+
}
3741
```
3842

43+
Don't forget to add the overrides to check only the test files.
44+
3945
## Rules implemented in this plugin
4046

4147
<!-- begin auto-generated rules list -->
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
"use strict";
22

33
const requireIndex = require("requireindex");
4-
const recommended = require("./recommended");
5-
const tests = require("./tests");
64

75
module.exports = {
8-
configs: {
9-
recommended,
10-
tests,
11-
},
6+
configs: requireIndex(__dirname + "/configs"),
127
rules: requireIndex(__dirname + "/rules"),
138
};

0 commit comments

Comments
 (0)