@hero-design/eslint-plugin 7.27.1 → 8.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-publish:npm.log +0 -0
- package/README.md +13 -2
- package/docs/rules/no-deprecated-component-prop.md +2 -2
- package/lib/index.js +10 -6
- package/lib/rules/no-deprecated-component-prop.js +23 -4
- package/package.json +2 -2
- package/tests/lib/rules/no-deprecated-component-prop.js +18 -2
- package/.turbo/turbo-lint.log +0 -2
- package/.turbo/turbo-test:ci.log +0 -10
|
File without changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @hero-design/eslint-plugin
|
|
2
2
|
|
|
3
|
-
Hero Design's eslint plugin
|
|
3
|
+
Hero Design's eslint plugin to ensure correct usage and deprecation of our packages.
|
|
4
|
+
We **strongly recommend** all of our consumers to use this plugin with our predefined `recommendedRn` config.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -26,7 +27,17 @@ Add `@hero-design` to the plugins section of your `.eslintrc` configuration file
|
|
|
26
27
|
}
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
Then
|
|
30
|
+
Then, you can either:
|
|
31
|
+
|
|
32
|
+
1. Use our pre-defined config by adding `plugin:@hero-design/recommendedRn` under `extends` section. This approach is **strongly recommended** as it requires no configurations.
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"extends": ["plugin:@hero-design/recommendedRn"]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
2. Configure the rules you want to use under the `rules` section. This approach should be **avoided** in most of the cases unless you have any specific needs.
|
|
30
41
|
|
|
31
42
|
```json
|
|
32
43
|
{
|
|
@@ -26,8 +26,8 @@ This rule receives option including package name and component props that are de
|
|
|
26
26
|
"components": [
|
|
27
27
|
{ "name": "Card", "props": ["variant"] },
|
|
28
28
|
{ "name": "Switch", "props": ["size"] },
|
|
29
|
-
{ "name": "Select", "props": ["onDimiss", "numberOfLines"] },
|
|
30
|
-
{ "name": "Select.Multi", "props": ["onDimiss", "numberOfLines"] },
|
|
29
|
+
{ "name": "Select", "props": ["onDimiss", "numberOfLines", "inputProps.required"] },
|
|
30
|
+
{ "name": "Select.Multi", "props": ["onDimiss", "numberOfLines", "inputProps.required"] },
|
|
31
31
|
],
|
|
32
32
|
},
|
|
33
33
|
```
|
package/lib/index.js
CHANGED
|
@@ -221,10 +221,18 @@ module.exports = {
|
|
|
221
221
|
{
|
|
222
222
|
package: '@hero-design/rn',
|
|
223
223
|
components: [
|
|
224
|
+
{ name: 'Alert', props: ['variant'] },
|
|
224
225
|
{ name: 'Card', props: ['variant'] },
|
|
225
226
|
{ name: 'Switch', props: ['size'] },
|
|
226
|
-
{
|
|
227
|
-
|
|
227
|
+
{
|
|
228
|
+
name: 'Select',
|
|
229
|
+
props: ['onDimiss', 'numberOfLines', 'inputProps.required'],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'Select.Multi',
|
|
233
|
+
props: ['onDimiss', 'numberOfLines', 'inputProps.required'],
|
|
234
|
+
},
|
|
235
|
+
{ name: 'Toast.Provider', props: ['position'] },
|
|
228
236
|
],
|
|
229
237
|
},
|
|
230
238
|
],
|
|
@@ -237,10 +245,6 @@ module.exports = {
|
|
|
237
245
|
name: 'Tag',
|
|
238
246
|
props: [{ name: 'intent', values: ['default'] }],
|
|
239
247
|
},
|
|
240
|
-
{
|
|
241
|
-
name: 'Alert',
|
|
242
|
-
props: [{ name: 'variant', values: ['default'] }],
|
|
243
|
-
},
|
|
244
248
|
{
|
|
245
249
|
name: 'Button',
|
|
246
250
|
props: [{ name: 'variant', values: ['basic-transparent'] }],
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
|
|
51
51
|
create(context) {
|
|
52
52
|
const components = context.options[0].components.map((c) => ({
|
|
53
|
-
props: c.props,
|
|
53
|
+
props: c.props.map((p) => p.split('.')),
|
|
54
54
|
identifiers: c.name.split('.'),
|
|
55
55
|
}));
|
|
56
56
|
let importedComponents = [];
|
|
@@ -130,15 +130,34 @@ module.exports = {
|
|
|
130
130
|
if (atb.type !== 'JSXAttribute') return;
|
|
131
131
|
|
|
132
132
|
const deprecatedProp = deprecatedComponent.props.find(
|
|
133
|
-
(p) => p === atb.name.name
|
|
133
|
+
(p) => p[0] === atb.name.name
|
|
134
134
|
);
|
|
135
|
-
|
|
135
|
+
|
|
136
|
+
if (deprecatedProp === undefined) return;
|
|
137
|
+
if (deprecatedProp.length === 1) {
|
|
136
138
|
context.report({
|
|
137
139
|
node: atb,
|
|
138
140
|
messageId: 'deprecatedProp',
|
|
139
|
-
data: { prop: deprecatedProp },
|
|
141
|
+
data: { prop: deprecatedProp.join('.') },
|
|
140
142
|
});
|
|
141
143
|
}
|
|
144
|
+
|
|
145
|
+
if (deprecatedProp.length === 2) {
|
|
146
|
+
if (atb.value.type !== 'JSXExpressionContainer') return;
|
|
147
|
+
if (atb.value.expression.type !== 'ObjectExpression') return;
|
|
148
|
+
|
|
149
|
+
let nestedDeprecatedProp = atb.value.expression.properties.find(
|
|
150
|
+
(p) => p.key.name === deprecatedProp[1]
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
if (nestedDeprecatedProp !== undefined) {
|
|
154
|
+
context.report({
|
|
155
|
+
node: nestedDeprecatedProp,
|
|
156
|
+
messageId: 'deprecatedProp',
|
|
157
|
+
data: { prop: deprecatedProp.join('.') },
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
142
161
|
});
|
|
143
162
|
},
|
|
144
163
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-rc.0",
|
|
4
4
|
"description": "Hero Design's eslint plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"eslint-plugin-eslint-plugin": "^5.0.0",
|
|
27
27
|
"eslint-plugin-node": "^11.1.0",
|
|
28
28
|
"jest": "^27.3.1",
|
|
29
|
-
"prettier-config-hd": "
|
|
29
|
+
"prettier-config-hd": "8.0.0-rc.0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
|
|
@@ -22,8 +22,14 @@ const config = {
|
|
|
22
22
|
components: [
|
|
23
23
|
{ name: 'Card', props: ['variant'] },
|
|
24
24
|
{ name: 'Box', props: ['padding', 'margin'] },
|
|
25
|
-
{
|
|
26
|
-
|
|
25
|
+
{
|
|
26
|
+
name: 'Select',
|
|
27
|
+
props: ['onDimiss', 'numberOfLines', 'inputProps.required'],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Select.Multi',
|
|
31
|
+
props: ['onDimiss', 'numberOfLines', 'inputProps.required'],
|
|
32
|
+
},
|
|
27
33
|
],
|
|
28
34
|
},
|
|
29
35
|
],
|
|
@@ -61,6 +67,9 @@ ruleTester.run('no-deprecated-component-prop', rule, {
|
|
|
61
67
|
{
|
|
62
68
|
code: 'import * as HD from "@hero-design/rn"; <HD.Select.Multi onClose={() => {}} />',
|
|
63
69
|
},
|
|
70
|
+
{
|
|
71
|
+
code: 'import * as HD from "@hero-design/rn"; <HD.Select.Multi onClose={() => {}} inputProps={{ numberOfLines: 2 }} />',
|
|
72
|
+
},
|
|
64
73
|
].map((test) => ({
|
|
65
74
|
...test,
|
|
66
75
|
...config,
|
|
@@ -103,6 +112,13 @@ ruleTester.run('no-deprecated-component-prop', rule, {
|
|
|
103
112
|
code: 'import * as HD from "@hero-design/rn"; <HD.Select.Multi onDimiss={() => {}} />',
|
|
104
113
|
errors: [{ messageId: 'deprecatedProp' }],
|
|
105
114
|
},
|
|
115
|
+
{
|
|
116
|
+
code: 'import * as HD from "@hero-design/rn"; <HD.Select.Multi onDimiss={() => {}} inputProps={{ required: true }} />',
|
|
117
|
+
errors: [
|
|
118
|
+
{ messageId: 'deprecatedProp' },
|
|
119
|
+
{ messageId: 'deprecatedProp' },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
106
122
|
].map((test) => ({
|
|
107
123
|
...test,
|
|
108
124
|
...config,
|
package/.turbo/turbo-lint.log
DELETED
package/.turbo/turbo-test:ci.log
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
[35m@hero-design/eslint-plugin:test:ci[0m: cache hit, replaying output [2ma90258f7b0211480[0m
|
|
2
|
-
[35m@hero-design/eslint-plugin:test:ci: [0m$ jest --runInBand --logHeapUsage
|
|
3
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mPASS tests/lib/rules/no-deprecated-component-prop-value.js (58 MB heap size)
|
|
4
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mPASS tests/lib/rules/no-deprecated-component-prop.js (71 MB heap size)
|
|
5
|
-
[35m@hero-design/eslint-plugin:test:ci: [0m
|
|
6
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mTest Suites: 2 passed, 2 total
|
|
7
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mTests: 30 passed, 30 total
|
|
8
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mSnapshots: 0 total
|
|
9
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mTime: 1.672 s, estimated 3 s
|
|
10
|
-
[35m@hero-design/eslint-plugin:test:ci: [0mRan all test suites.
|