Skip to content

Commit add013e

Browse files
authored
task: update docs for ama rules (#293)
* Added ama rules monorepo setup and update details * Update getting started to give overview and link out to config file * Update legacy docs
1 parent 43253e2 commit add013e

3 files changed

Lines changed: 55 additions & 26 deletions

File tree

website/docs/ama/config-file.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ The library does not perform any accessibility checks on the production build!
1616

1717
:::
1818

19-
2019
## Log Levels
2120

2221
**AMA** guidelines are categorised as:
@@ -52,9 +51,56 @@ The possible log levels are:
5251
Rules marked with <No /> are considered bad practices and cannot be turned off!
5352
:::
5453

55-
## Customising the Log Levels
54+
## Customizing the Log Levels
55+
56+
A JSON file called `ama.config.json` should have been automatically generated in the project's root folder (If it didn't simply create it). This file is used to customize the log rules, then specify the custom log level for the wanted key. `accessibilityLabelExceptions` can also be specified in this file. Any changes to this file will automatically be picked up by AMA's config and applied to the applications warnings and errors in Dev mode. (You will need to restart your application to see the changes applied)
57+
58+
:::warning
59+
If you are running a monorepo setup this file won't automatically generate and you will have two options customize AMA's config.
60+
61+
<details>
62+
<summary>Options for monorepos (Expand me)</summary>
63+
64+
You have two options to add `userDefinedRules` to AMA's config:
65+
66+
- You can create a symlink to the `ama.rules.json` file in the root of your project _(recommended)_
67+
- You can create a new `ama.rules.json` file in the root of your project and copy this file over the `ama.rules.json` file in `@react-native-ama/internal` package every time you make changes to it.
68+
(This will also need to be done every time you update or delete and reinstall AMA node_modules)
69+
70+
**Option 1:** _(recommended)_
71+
72+
To create a symlink to the `ama.rules.json` file in the root of your project, run the following command:
73+
74+
```bash
75+
76+
# In the root of your App or root of your project create a symlink to the ama.rules.json file
77+
# Adjust the file path as needed depending on where the ama.rules.json file is located in your monorepo relative to the root of your project
78+
ln -s node_modules/@react-native-ama/internal/ama.rules.json ./ama.rules.json
79+
```
5680

57-
Create a JSON file called `ama.config.json` in the project's root folder to customise the log rules, then specify the custom log level for the wanted key.
81+
**Option 2:**
82+
83+
To create a new `ama.rules.json` file in the root of your project, run the following command:
84+
85+
```bash
86+
# In the root of your App or root of your project
87+
# Adjust the file path as needed depending on where the ama.rules.json file is located in your monorepo relative to the root of your project
88+
cp node_modules/@react-native-ama/internal/ama.rules.json ./ama.rules.json
89+
```
90+
91+
Don't forget if you make changes to the `ama.rules.json` file in the root you will need to copy the changes over to the `ama.rules.json` file in the `@react-native-ama/internal` package of your project.
92+
93+
```bash
94+
# In the root of your App or root of your project
95+
# Adjust the file path as needed depending on where the ama.rules.json file is located in your monorepo relative to the root of your project
96+
cp ama.rules.json node_modules/@react-native-ama/internal/ama.rules.json
97+
98+
# Restart your application to see the changes
99+
```
100+
101+
</details>
102+
103+
:::
58104

59105
### Example
60106

website/docs/ama/getting-started.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,7 @@ npm install @react-native-ama/core
2828

2929
### Config File
3030

31-
When you install the `@react-native-ama/core` package, `the ama.rules.json` file should be generated automatically. If this didn't happen you can run the following from the root of your project:
32-
33-
```bash
34-
# Create ama.rules.json with an empty JSON object if it doesn't exist
35-
echo "{}" >> ama.rules.json
36-
37-
# Navigate to the internal directory
38-
cd node_modules/@react-native-ama/internal
39-
40-
# Create symlinks in src and dist directories
41-
ln -s ../../../ama.rules.json src/ama.rules.json
42-
ln -s ../../../ama.rules.json dist/ama.rules.json
43-
44-
# Go back to the root directory
45-
cd -
46-
```
31+
When you install the `@react-native-ama/core` package, `the ama.rules.json` file should be generated automatically in the root of your project. This file can be used to customize AMA Log Levels and Exceptions. If you are running a monorepo setup this file won't automatically generate and you will have two options customize AMA's config.
4732

4833
See more on configuring **AMA** rules and severity [here](./config-file.md).
4934

website/versioned_docs/version-0.7.x/introduction/getting-started.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Install _react-native-ama_ using either `yarn` or `npm`:
1515
npm install react-native-ama
1616
```
1717

18-
1918
### Dependencies
2019

2120
Some component relies on [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) and/or [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler),
@@ -37,8 +36,8 @@ The installation command should have automatically generated the `ama.rules.json
3736
```bash
3837

3938
echo "{}" >> ama.rules.json
40-
cd node_modules/react-native-ama
41-
ln -s ../../ama.rules.json .
39+
40+
ln -s node_modules/react-native-ama/ama.rules.json ama.rules.json
4241
```
4342

4443
### Jest
@@ -50,10 +49,9 @@ When running a test, if jest fails with the following error:
5049
add those lines to the `.jest.config.js` file:
5150

5251
```js
53-
5452
jest.mock('react-native-ama/dist/commonjs/internal/logger.js', () => {
55-
return {
56-
getContrastCheckerMaxDepth: () => 5,
57-
};
53+
return {
54+
getContrastCheckerMaxDepth: () => 5,
55+
};
5856
});
5957
```

0 commit comments

Comments
 (0)