You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
6
2
7
3
If you find a useful rule that you feel every project at BAM should use, feel free to open a PR.
8
4
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
12
6
13
-
### Adding new rules
14
-
15
-
Adding new rules is quite simple:
7
+
Creating new rules is quite simple:
16
8
17
9
1. Create a new rule from the template:
18
10
@@ -21,7 +13,7 @@ Adding new rules is quite simple:
21
13
yo eslint:rule
22
14
```
23
15
24
-
1.Add it to the default shared config:
16
+
1.Optionally, add it to some shareable configs (for example `recommended`):
25
17
26
18
```js
27
19
// recommended.js
@@ -41,9 +33,15 @@ Adding new rules is quite simple:
41
33
yarn test
42
34
```
43
35
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.
45
39
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):
47
45
48
46
```js
49
47
module.exports= {
@@ -52,25 +50,23 @@ module.exports = {
52
50
...
53
51
"@some-scope/eslint-config",
54
52
],
55
-
...
56
53
}
57
54
```
58
55
59
56
The package containing your shareable configuration should be added as a dependency by running `yarn add your-package`.
60
57
61
-
### Adding a plugin
58
+
### Adding a plugin to your shareable config
62
59
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:
64
61
65
62
```js
66
63
module.exports= {
67
64
...
68
65
plugins: [
69
66
...
70
-
"your-plugin",
67
+
"some-plugin",
71
68
],
72
-
...
73
69
}
74
70
```
75
71
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`.
|`@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
+
```
44
43
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:
46
53
47
54
<!-- begin auto-generated rules list -->
48
55
@@ -52,8 +59,24 @@ Don't forget to add the overrides to check only the test files.
52
59
53
60
<!-- end auto-generated rules list -->
54
61
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
+
55
76
## How to customize?
56
77
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)
58
81
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