Skip to content

Commit 137f1dc

Browse files
doc: add some documentation (#3)
1 parent fa0edb6 commit 137f1dc

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,26 @@ This repo uses [lerna](https://lerna.js.org/) to maintain, version and publish v
1010

1111
There is also an example app under `packages/example-app` whose goal is to demonstrate how to import and use the configuration packages.
1212

13-
## Commands
13+
## Using the configurations
14+
15+
- [Using ESLint configuration](./packages/eslint/README.md)
16+
17+
## Installing the project
18+
19+
- clone the project: `git clone https://github.com/bamlab/react-native-project-config`,
20+
- install the dependencies: `yarn install`,
21+
22+
## Modifying the project
23+
24+
To have a complete understanding on how to modify the project, see [Lerna's documentation](https://lerna.js.org/docs/introduction).
25+
26+
Here are some useful commands:
27+
28+
- creating a new package named `package-my-config`: `yarn lerna create package-my-config`,
29+
- rename the directory of a package: `mv package-my-config new-directory-name && yarn lerna bootstrap`,
30+
- run a script `do-something` that exists in at least one package: `yarn lerna run do-something` (this will try to run the script in all packages in which it is defined).
31+
32+
## Running commands
1433

1534
- `yarn lerna run start`: run the 'start' script in all packages (currently only present in `example-app`),
1635
- `yarn lerna run lint`: run the 'lint' script in all packages (currently only present in `example-app`).

packages/eslint/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ESLint config for BAM
2+
3+
This project is an ESLint config that gathers all the rules, plugins and parsers that should be used in any new BAM project.
4+
5+
## How to use?
6+
7+
In your app, run `yarn add --dev @bam.tech/eslint-config @typescript-eslint/eslint-plugin eslint`.
8+
9+
In your `.eslintrc` config file, extend the exported configuration:
10+
11+
```json
12+
// .eslintrc
13+
{
14+
"extends": "@bam.tech/eslint-config"
15+
}
16+
```
17+
18+
## How to customize?
19+
20+
You can still customize your ESLint config by adding configurations, plugins and rules to your `.eslintrc` config file.
21+
22+
## How to improve?
23+
24+
If you find a useful rule that you feel every project at BAM should use, feel free to open a PR.
25+
26+
Use the documentation on how to create a shareable configuration [here](https://eslint.org/docs/latest/developer-guide/shareable-configs).
27+
28+
Here is a small summary:
29+
30+
### Adding new rules
31+
32+
Adding new rules is quite simple, you just have to modify `index.js` and add your rule to the `rules` object:
33+
34+
```js
35+
module.exports = {
36+
...
37+
rules: {
38+
...
39+
"my-new-rule": "error",
40+
},
41+
...
42+
}
43+
```
44+
45+
### Extending new shareable configurations
46+
47+
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):
48+
49+
```js
50+
module.exports = {
51+
...
52+
extends: [
53+
...
54+
"@some-scope/eslint-config",
55+
],
56+
...
57+
}
58+
```
59+
60+
The package containing your shareable configuration should be added as a dependency by running `yarn add your-package`.
61+
62+
### Adding a plugin
63+
64+
Adding a plugin is quite simple, you just have to modify `index.js` and add your plugin to the `plugins` array:
65+
66+
```js
67+
module.exports = {
68+
...
69+
plugins: [
70+
...
71+
"your-plugin",
72+
],
73+
...
74+
}
75+
```
76+
77+
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`.

0 commit comments

Comments
 (0)