Skip to content

Commit b09e75d

Browse files
authored
feat(eslint-plugin): no-unnecessary-condition (#116)
Closes #115 <!-- We use conventional commits to automate the release process. Please read the [Readme](https://github.com/bamlab/react-native-project-config/blob/main/README.md) for more information. Please follow the commit message format described in the link above. Lerna will automatically generate the changelog for each package based on the commit messages since the last version. --> - Add the no-unnecessary-condition rule - Improve the readme for starting up the project
1 parent 048b3bf commit b09e75d

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ There is also an example app under `packages/example-app` whose goal is to demon
1919

2020
- clone the project: `git clone https://github.com/bamlab/react-native-project-config`,
2121
- install the dependencies: `yarn install`,
22+
- build the eslint-plugin: `yarn workspace @bam.tech/eslint-plugin build`
23+
24+
✅ Check : in the example-app in eslint-breaking-examples you should see the eslint errors.
2225

2326
## Modifying the project
2427

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Save without formatting: [⌘ + K] > [S]
2+
3+
// This should trigger one error breaking eslint-plugin-react-native:
4+
// @typescript-eslint/no-unnecessary-condition
5+
6+
export const bar = (arg: string) => {
7+
// arg can never be nullish, so ?. is unnecessary
8+
return arg?.length;
9+
};

packages/eslint-plugin/docs/Testing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ The example-app folder is located at the root of `react-native-project-config`.
1010
The goal of each file of example-app is to simulate the behavior of a rule or a set of rules, so that you can visually check it or by running the `yarn lint` command.
1111
When you add or remove a rule from the recommended config, please modify (or add/remove) the corresponding file in the example-app folder.
1212

13+
## Adding a new rule
14+
15+
In order to add a new rule, you must add it to the packages eslint-plugin, and then build it (it is in typescript) before seeing the changes in the example-app with the command:
16+
17+
```bash
18+
yarn workspace @bam.tech/eslint-plugin build
19+
```
20+
1321
## Real example testing
1422

1523
In order to test that your rule will be properly deployed, use another project, in which you install the eslint-plugin from your local files.

packages/eslint-plugin/lib/configs/recommended.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const recommendedConfig = defineConfig({
7676
"no-return-await": "off", // Disable the base rule as it can report incorrect errors
7777
"@typescript-eslint/return-await": "error",
7878
"@typescript-eslint/no-floating-promises": "error",
79+
"@typescript-eslint/no-unnecessary-condition": "error",
7980
},
8081
},
8182
],

0 commit comments

Comments
 (0)