Skip to content

Commit 840441b

Browse files
authored
Docs/update documentation (#24)
* docs: update README * docs: update contributing
1 parent a2e4fa2 commit 840441b

2 files changed

Lines changed: 63 additions & 44 deletions

File tree

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
# ESLint plugin for BAM
2-
3-
This project is an ESLint plugin that gathers all the rules, plugins and parsers that should be used in any new BAM project. Here is the documentation on how to contribute to this plugin
4-
5-
## How to improve?
1+
# Contribute
62

73
If you find a useful rule that you feel every project at BAM should use, feel free to open a PR.
84

9-
Use the documentation on how to create a shareable configuration [here](https://eslint.org/docs/latest/developer-guide/shareable-configs).
10-
11-
Here is a small summary:
5+
## Creating new rules
126

13-
### Adding new rules
14-
15-
Adding new rules is quite simple:
7+
Creating new rules is quite simple:
168

179
1. Create a new rule from the template:
1810

@@ -21,7 +13,7 @@ Adding new rules is quite simple:
2113
yo eslint:rule
2214
```
2315

24-
1. Add it to the default shared config:
16+
1. Optionally, add it to some shareable configs (for example `recommended`):
2517

2618
```js
2719
// recommended.js
@@ -41,9 +33,15 @@ Adding new rules is quite simple:
4133
yarn test
4234
```
4335

44-
### Extending new shareable configurations
36+
## Creating new shareable configuration
37+
38+
Creating a shareable config is simple, you just have to create a new config file in the `lib/configs` directory and modify it.
4539

46-
Extending new shareable configurations is quite simple, you just have to modify `index.js` and add your shareable configuration to the `extends` array (the order of configurations is important):
40+
## Modifying a shareable configuration
41+
42+
### Extending from other shareable configs
43+
44+
Extending new shareable configurations is quite simple, you just have to modify the config file and add your shareable configuration to the `extends` array (the order of configurations is important):
4745

4846
```js
4947
module.exports = {
@@ -52,25 +50,23 @@ module.exports = {
5250
...
5351
"@some-scope/eslint-config",
5452
],
55-
...
5653
}
5754
```
5855

5956
The package containing your shareable configuration should be added as a dependency by running `yarn add your-package`.
6057

61-
### Adding a plugin
58+
### Adding a plugin to your shareable config
6259

63-
Adding a plugin is quite simple, you just have to modify `index.js` and add your plugin to the `plugins` array:
60+
Adding a plugin is quite simple, you just have to modify your config file and add your plugin to the `plugins` array:
6461

6562
```js
6663
module.exports = {
6764
...
6865
plugins: [
6966
...
70-
"your-plugin",
67+
"some-plugin",
7168
],
72-
...
7369
}
7470
```
7571

76-
The package containing your plugin should be added as a [peer dependency](https://classic.yarnpkg.com/en/docs/dependency-types/) by running `yarn add --peer your-plugin`.
72+
The package containing your plugin should be added as a [peer dependency](https://classic.yarnpkg.com/en/docs/dependency-types/) by running `yarn add --peer eslint-plugin-some-plugin`.

packages/eslint-plugin/README.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@
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-
## Shared config
5+
## Quick Setup
66

7-
The plugin exports multiple configs that can be used in your `.eslintrc` config file:
8-
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 |
13-
14-
You should install the correct version for each package. You can see the list using:
15-
16-
```bash
17-
npm info "@bam.tech/esling-plugin" peerDependencies
18-
```
19-
20-
With **npm 5+** you can automatically install all the peer dependencies by running:
7+
Install the plugin and its peer dependencies:
218

229
```bash
23-
npx install-peerdeps @bam.tech/eslint-config -D
10+
yarn add --dev @bam.tech/eslint-plugin
11+
npx install-peerdeps --dev @bam.tech/eslint-plugin
2412
```
2513

26-
## How to use?
27-
28-
In your `.eslintrc` config file, extend the exported configurations:
14+
Then update your `.eslintrc` config file:
2915

3016
```json
3117
// .eslintrc
3218
{
33-
"extends": "plugin:@bam.tech/eslint-plugin/recommended",
19+
"extends": "plugin:@bam.tech/recommended",
3420
"overrides": [
3521
{
3622
"files": ["*.test.tsx"],
@@ -40,9 +26,30 @@ In your `.eslintrc` config file, extend the exported configurations:
4026
}
4127
```
4228

43-
Don't forget to add the overrides to check only the test files.
29+
## Shareable configurations
30+
31+
This plugin exports multiple configurations that can be used in your `.eslintrc` config file:
32+
33+
| Name | Description |
34+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
35+
| `@bam.tech/recommended` | The recommended config for all projects |
36+
| `@bam.tech/tests` | The recommended config for test files. By default this applies to every file: put it in an `overrides` to filter on your test files. |
37+
38+
These configs need some peer dependencies. You can list them with:
39+
40+
```bash
41+
npm info "@bam.tech/esling-plugin" peerDependencies
42+
```
4443

45-
## Rules implemented in this plugin
44+
If you use **npm >= 5** you can automatically install them by running:
45+
46+
```bash
47+
npx install-peerdeps @bam.tech/eslint-config -D
48+
```
49+
50+
## Eslint rules
51+
52+
This plugin exports some custom rules that you can optionally use in your project:
4653

4754
<!-- begin auto-generated rules list -->
4855

@@ -52,8 +59,24 @@ Don't forget to add the overrides to check only the test files.
5259

5360
<!-- end auto-generated rules list -->
5461

62+
To use a rule, just declare it in your `.eslintrc`:
63+
64+
```json
65+
// .eslintrc
66+
{
67+
"plugins": ["@bam.tech"],
68+
"rules": {
69+
"@bam.tech/require-named-effect": "error"
70+
}
71+
}
72+
```
73+
74+
> _Tip: if your config is already extended from a `@bam.tech` config, you don't need to declare the plugin._
75+
5576
## How to customize?
5677

57-
You can still customize your ESLint config by adding configurations, plugins and rules to your `.eslintrc` config file.
78+
You can still customize your ESLint config by adding other configurations, plugins and rules to your `.eslintrc` config file.
79+
80+
## [Contribute](./CONTRIBUTING.md)
5881

59-
If you find a useful rule that you feel every project at BAM should use, feel free to contribute, [here is a link](./CONTRIBUTING.md) where you'll find explanations on how to do so.
82+
If you find a useful rule that you feel every project at BAM should use, feel free to [contribute](./CONTRIBUTING.md).

0 commit comments

Comments
 (0)