Skip to content

Commit 2f5bfc4

Browse files
authored
Update uilib eslint plugin readme
1 parent dc57c9e commit 2f5bfc4

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

eslint-rules/README.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,63 @@ Then configure the rules you want to use under the rules section.
4343

4444
## Supported Rules
4545

46-
* Fill in provided rules here
47-
48-
49-
46+
#### uilib/no-hard-coded-color
47+
```js
48+
// Your app valid colors
49+
const validColors = {
50+
blue: '#459FED',
51+
red: '#F2564D',
52+
green: '#00CD8B',
53+
yellow: '#FFB600',
54+
}
5055

56+
// Lint will catch all hard coded color values in the code and replace with valid colors if exist
57+
// `#459FED` will turn to `Colors.blue`
58+
{
59+
"rules": {
60+
"uilib/no-hard-coded-color": ['error', {validColors}]
61+
}
62+
}
63+
```
5164

65+
### uilib/component-deprecation_warn, uilib/component-deprecation_error
66+
```js
67+
68+
// deprecation message to warn you consumers about
69+
const deprecationWarnings = [
70+
{
71+
"component": "ActivityIndicator",
72+
"source": "react-native",
73+
"message": "Please avoid using react-native ActivityIndicator, use the 'Loader' component instead"
74+
},
75+
{
76+
"component": "OldComponent",
77+
"source": "react-native-ui-lib",
78+
"message": "Please use the 'NewComponent' instead. Auto fix available.",
79+
"fix": { "componentName": "NewComponent" }
80+
},
81+
];
82+
83+
const deprecationErrors = [
84+
{
85+
"component": "Button", /// The component
86+
"source": "react-native-ui-lib", // The source you import the component from
87+
"message": "",
88+
"props": [
89+
{
90+
"prop": "title", // the prop to depreciate
91+
"message": "Please use `label` prop instead of `title` prop", // custom message to the user
92+
"fix": { "propName": "label" } // provice auto fix
93+
}
94+
]
95+
},
96+
];
97+
98+
// Two phases: warn & error to allow phasing your migration process
99+
{
100+
"rules": {
101+
'uilib/component-deprecation_warn': ['warn', {deprecations: deprecationWarnings, dueDate: 'Thursday 31 January'}],
102+
'uilib/component-deprecation_error': ['error', {deprecations: deprecationErrors , dueDate: 'Thursday 31 January'
103+
}
104+
}
105+
```

0 commit comments

Comments
 (0)