@atlaskit/eslint-plugin-platform 2.7.0 → 2.7.2
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/CHANGELOG.md +14 -0
- package/dist/cjs/index.js +4 -9
- package/dist/cjs/rules/constants.js +1 -1
- package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +7 -7
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/cjs/rules/ensure-no-private-dependencies/index.js +48 -66
- package/dist/cjs/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/cjs/rules/feature-gating/no-alias/index.js +2 -2
- package/dist/cjs/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/cjs/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/cjs/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/cjs/rules/no-sparse-checkout/index.js +1 -1
- package/dist/cjs/rules/prefer-crypto-random-uuid/index.js +87 -0
- package/dist/cjs/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/cjs/rules/util/context-compat.js +4 -2
- package/dist/es2019/index.js +4 -9
- package/dist/es2019/rules/constants.js +1 -1
- package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +7 -7
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/es2019/rules/ensure-no-private-dependencies/index.js +10 -9
- package/dist/es2019/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/es2019/rules/feature-gating/no-alias/index.js +2 -2
- package/dist/es2019/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/es2019/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/es2019/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/es2019/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/es2019/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/es2019/rules/no-sparse-checkout/index.js +1 -1
- package/dist/es2019/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/es2019/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/es2019/rules/util/context-compat.js +4 -2
- package/dist/esm/index.js +4 -9
- package/dist/esm/rules/constants.js +1 -1
- package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +7 -7
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/esm/rules/ensure-no-private-dependencies/index.js +48 -65
- package/dist/esm/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/esm/rules/feature-gating/no-alias/index.js +2 -2
- package/dist/esm/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/esm/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/esm/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/esm/rules/no-sparse-checkout/index.js +1 -1
- package/dist/esm/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/esm/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/esm/rules/util/context-compat.js +4 -2
- package/dist/types/index.d.ts +6 -20
- package/dist/types/rules/util/handle-ast-object.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +6 -32
- package/dist/types-ts4.5/rules/util/handle-ast-object.d.ts +1 -1
- package/package.json +2 -5
- package/afm-cc/tsconfig.json +0 -24
- package/afm-jira/tsconfig.json +0 -24
- package/build/tsconfig.json +0 -17
- package/dist/cjs/rules/ensure-feature-flag-prefix/index.js +0 -75
- package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -79
- package/dist/es2019/rules/ensure-feature-flag-prefix/index.js +0 -65
- package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -62
- package/dist/esm/rules/ensure-feature-flag-prefix/index.js +0 -69
- package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -75
- package/dist/types/rules/ensure-feature-flag-prefix/index.d.ts +0 -3
- package/dist/types/rules/ensure-valid-platform-yarn-protocol-usage/index.d.ts +0 -3
- package/src/__tests__/utils/_tester.tsx +0 -26
- package/src/index.tsx +0 -254
- package/src/rules/compiled/README.md +0 -3
- package/src/rules/compiled/expand-background-shorthand/README.md +0 -23
- package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +0 -160
- package/src/rules/compiled/expand-background-shorthand/index.tsx +0 -43
- package/src/rules/compiled/expand-border-shorthand/README.md +0 -51
- package/src/rules/compiled/expand-border-shorthand/__tests__/rule.test.ts +0 -211
- package/src/rules/compiled/expand-border-shorthand/index.ts +0 -103
- package/src/rules/compiled/expand-spacing-shorthand/README.md +0 -38
- package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +0 -448
- package/src/rules/compiled/expand-spacing-shorthand/index.ts +0 -240
- package/src/rules/constants.tsx +0 -20
- package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +0 -24
- package/src/rules/ensure-atlassian-team/index.ts +0 -51
- package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +0 -200
- package/src/rules/ensure-critical-dependency-resolutions/index.tsx +0 -172
- package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +0 -65
- package/src/rules/ensure-feature-flag-prefix/index.tsx +0 -81
- package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +0 -115
- package/src/rules/ensure-feature-flag-registration/index.tsx +0 -106
- package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +0 -199
- package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -188
- package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +0 -212
- package/src/rules/ensure-no-private-dependencies/index.ts +0 -64
- package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +0 -39
- package/src/rules/ensure-publish-valid/index.ts +0 -81
- package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +0 -298
- package/src/rules/ensure-test-runner-arguments/index.tsx +0 -121
- package/src/rules/ensure-test-runner-nested-count/__tests__/unit/rule.test.tsx +0 -308
- package/src/rules/ensure-test-runner-nested-count/index.tsx +0 -82
- package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +0 -159
- package/src/rules/ensure-valid-bin-values/index.ts +0 -70
- package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +0 -147
- package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +0 -67
- package/src/rules/feature-gating/README.md +0 -8
- package/src/rules/feature-gating/inline-usage/README.md +0 -53
- package/src/rules/feature-gating/inline-usage/__tests__/rule.test.tsx +0 -106
- package/src/rules/feature-gating/inline-usage/index.tsx +0 -135
- package/src/rules/feature-gating/no-alias/README.md +0 -29
- package/src/rules/feature-gating/no-alias/__tests__/rule.test.tsx +0 -76
- package/src/rules/feature-gating/no-alias/index.tsx +0 -80
- package/src/rules/feature-gating/no-module-level-eval/README.md +0 -53
- package/src/rules/feature-gating/no-module-level-eval/__tests__/test.tsx +0 -133
- package/src/rules/feature-gating/no-module-level-eval/index.tsx +0 -54
- package/src/rules/feature-gating/no-module-level-eval-nav4/README.md +0 -8
- package/src/rules/feature-gating/no-module-level-eval-nav4/__tests__/test.tsx +0 -130
- package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +0 -73
- package/src/rules/feature-gating/no-preconditioning/README.md +0 -69
- package/src/rules/feature-gating/no-preconditioning/__tests__/rule.test.tsx +0 -164
- package/src/rules/feature-gating/no-preconditioning/index.tsx +0 -138
- package/src/rules/feature-gating/prefer-fg/README.md +0 -3
- package/src/rules/feature-gating/prefer-fg/__tests__/rule.test.tsx +0 -83
- package/src/rules/feature-gating/prefer-fg/index.tsx +0 -110
- package/src/rules/feature-gating/static-feature-flags/README.md +0 -3
- package/src/rules/feature-gating/static-feature-flags/__tests__/test.tsx +0 -135
- package/src/rules/feature-gating/static-feature-flags/index.tsx +0 -103
- package/src/rules/feature-gating/use-recommended-utils/README.md +0 -67
- package/src/rules/feature-gating/use-recommended-utils/__tests__/rule.test.tsx +0 -78
- package/src/rules/feature-gating/use-recommended-utils/index.tsx +0 -57
- package/src/rules/feature-gating/utils.tsx +0 -48
- package/src/rules/no-direct-document-usage/index.tsx +0 -111
- package/src/rules/no-duplicate-dependencies/__tests__/unit/rule.test.ts +0 -116
- package/src/rules/no-duplicate-dependencies/index.ts +0 -79
- package/src/rules/no-invalid-feature-flag-usage/__tests__/unit/rule.test.tsx +0 -69
- package/src/rules/no-invalid-feature-flag-usage/index.tsx +0 -128
- package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +0 -18
- package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +0 -39
- package/src/rules/no-pre-post-installs/__tests__/unit/rule.test.ts +0 -41
- package/src/rules/no-pre-post-installs/index.ts +0 -35
- package/src/rules/no-set-immediate/index.tsx +0 -43
- package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +0 -48
- package/src/rules/no-sparse-checkout/index.tsx +0 -54
- package/src/rules/use-entrypoints-in-examples/README.md +0 -27
- package/src/rules/use-entrypoints-in-examples/__tests__/rule.test.tsx +0 -34
- package/src/rules/use-entrypoints-in-examples/index.tsx +0 -43
- package/src/rules/util/__tests__/context-compat.test.ts +0 -122
- package/src/rules/util/compiled-utils.ts +0 -27
- package/src/rules/util/context-compat.ts +0 -41
- package/src/rules/util/file-exclusions.ts +0 -39
- package/src/rules/util/handle-ast-object.ts +0 -33
- package/src/rules/util/registration-utils.ts +0 -59
- package/tsconfig.app.json +0 -43
- package/tsconfig.dev.json +0 -40
- package/tsconfig.json +0 -23
- /package/dist/{types-ts4.5/rules/ensure-valid-platform-yarn-protocol-usage → types/rules/prefer-crypto-random-uuid}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-feature-flag-prefix → prefer-crypto-random-uuid}/index.d.ts +0 -0
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { tester } from '../../../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../../index';
|
|
3
|
-
|
|
4
|
-
describe('Warning about too many nested test runners', () => {
|
|
5
|
-
tester.run('ensure-test-runner-nested-count', rule, {
|
|
6
|
-
valid: [
|
|
7
|
-
{
|
|
8
|
-
code: `describe('1 FF', () => {
|
|
9
|
-
ffTest('uip.sample.color', () => {
|
|
10
|
-
const { getByText } = render(<SampleComponent />);
|
|
11
|
-
expect(getByText('SampleComponent')).toBeDefined();
|
|
12
|
-
});
|
|
13
|
-
});`,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
code: `describe('2 FFs', () => {
|
|
17
|
-
ffTest(
|
|
18
|
-
'uip.sample.color',
|
|
19
|
-
ff =>
|
|
20
|
-
ffTest(
|
|
21
|
-
'uip.sample.backgroundColor',
|
|
22
|
-
() => {
|
|
23
|
-
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
24
|
-
},
|
|
25
|
-
() => {
|
|
26
|
-
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
27
|
-
},
|
|
28
|
-
ff,
|
|
29
|
-
),
|
|
30
|
-
ff =>
|
|
31
|
-
ffTest(
|
|
32
|
-
'uip.sample.backgroundColor',
|
|
33
|
-
() => {
|
|
34
|
-
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
35
|
-
},
|
|
36
|
-
() => {
|
|
37
|
-
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
38
|
-
},
|
|
39
|
-
ff,
|
|
40
|
-
),
|
|
41
|
-
);
|
|
42
|
-
});`,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
code: `ffTest(
|
|
46
|
-
'uip.sample.color',
|
|
47
|
-
(ff) =>
|
|
48
|
-
ffTest(
|
|
49
|
-
'uip.sample.backgroundColor',
|
|
50
|
-
() => {},
|
|
51
|
-
() => {},
|
|
52
|
-
ff,
|
|
53
|
-
),
|
|
54
|
-
(ff) =>
|
|
55
|
-
ffTest(
|
|
56
|
-
'uip.sample.backgroundColor',
|
|
57
|
-
() => {},
|
|
58
|
-
() => {},
|
|
59
|
-
ff,
|
|
60
|
-
),
|
|
61
|
-
);`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
code: `ffTest(
|
|
65
|
-
'uip.sample.color',
|
|
66
|
-
(ff) =>
|
|
67
|
-
ffTest(
|
|
68
|
-
'uip.sample.backgroundColor',
|
|
69
|
-
(ff) =>
|
|
70
|
-
ffTest(
|
|
71
|
-
'uip.sample.display',
|
|
72
|
-
() => {},
|
|
73
|
-
() => {},
|
|
74
|
-
ff,
|
|
75
|
-
),
|
|
76
|
-
(ff) =>
|
|
77
|
-
ffTest(
|
|
78
|
-
'uip.sample.display',
|
|
79
|
-
() => {},
|
|
80
|
-
() => {},
|
|
81
|
-
ff,
|
|
82
|
-
),
|
|
83
|
-
ff,
|
|
84
|
-
),
|
|
85
|
-
(ff) =>
|
|
86
|
-
ffTest(
|
|
87
|
-
'uip.sample.backgroundColor',
|
|
88
|
-
() => {},
|
|
89
|
-
(ff) =>
|
|
90
|
-
ffTest(
|
|
91
|
-
'uip.sample.display',
|
|
92
|
-
() => {},
|
|
93
|
-
() => {},
|
|
94
|
-
ff,
|
|
95
|
-
),
|
|
96
|
-
ff,
|
|
97
|
-
),
|
|
98
|
-
);`,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
code: `
|
|
102
|
-
ffTest(
|
|
103
|
-
'uip.sample.color',
|
|
104
|
-
(ff) =>
|
|
105
|
-
ffTest(
|
|
106
|
-
'uip.sample.backgroundColor',
|
|
107
|
-
(ff) =>
|
|
108
|
-
ffTest(
|
|
109
|
-
'uip.sample.display',
|
|
110
|
-
() => {},
|
|
111
|
-
() => {},
|
|
112
|
-
ff,
|
|
113
|
-
),
|
|
114
|
-
(ff) =>
|
|
115
|
-
ffTest(
|
|
116
|
-
'uip.sample.display',
|
|
117
|
-
() => {},
|
|
118
|
-
() => {},
|
|
119
|
-
ff,
|
|
120
|
-
),
|
|
121
|
-
ff,
|
|
122
|
-
),
|
|
123
|
-
(ff) =>
|
|
124
|
-
ffTest(
|
|
125
|
-
'uip.sample.backgroundColor',
|
|
126
|
-
(ff) =>
|
|
127
|
-
ffTest(
|
|
128
|
-
'uip.sample.display',
|
|
129
|
-
(ff) =>
|
|
130
|
-
ffTest(
|
|
131
|
-
'uip.sample.opacity',
|
|
132
|
-
() => {},
|
|
133
|
-
() => {},
|
|
134
|
-
ff,
|
|
135
|
-
),
|
|
136
|
-
() => {},
|
|
137
|
-
ff,
|
|
138
|
-
),
|
|
139
|
-
(ff) =>
|
|
140
|
-
ffTest(
|
|
141
|
-
'uip.sample.display',
|
|
142
|
-
() => {},
|
|
143
|
-
(ff) =>
|
|
144
|
-
ffTest(
|
|
145
|
-
'uip.sample.opacity',
|
|
146
|
-
() => {},
|
|
147
|
-
() => {},
|
|
148
|
-
ff,
|
|
149
|
-
),
|
|
150
|
-
ff,
|
|
151
|
-
),
|
|
152
|
-
ff,
|
|
153
|
-
),
|
|
154
|
-
);`,
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
invalid: [
|
|
158
|
-
{
|
|
159
|
-
code: `
|
|
160
|
-
describe('5 FFs', () => {
|
|
161
|
-
ffTest(
|
|
162
|
-
'uip.sample.color',
|
|
163
|
-
(ff) =>
|
|
164
|
-
ffTest(
|
|
165
|
-
'uip.sample.backgroundColor',
|
|
166
|
-
(ff) =>
|
|
167
|
-
ffTest(
|
|
168
|
-
'uip.sample.display',
|
|
169
|
-
() => {},
|
|
170
|
-
() => {},
|
|
171
|
-
ff,
|
|
172
|
-
),
|
|
173
|
-
(ff) =>
|
|
174
|
-
ffTest(
|
|
175
|
-
'uip.sample.display',
|
|
176
|
-
() => {},
|
|
177
|
-
() => {},
|
|
178
|
-
ff,
|
|
179
|
-
),
|
|
180
|
-
ff,
|
|
181
|
-
),
|
|
182
|
-
(ff) =>
|
|
183
|
-
ffTest(
|
|
184
|
-
'uip.sample.backgroundColor',
|
|
185
|
-
(ff) =>
|
|
186
|
-
ffTest(
|
|
187
|
-
'uip.sample.display',
|
|
188
|
-
(ff) =>
|
|
189
|
-
ffTest(
|
|
190
|
-
'uip.sample.opacity',
|
|
191
|
-
(ff) =>
|
|
192
|
-
ffTest(
|
|
193
|
-
'uip.sample.font',
|
|
194
|
-
() => {},
|
|
195
|
-
() => {},
|
|
196
|
-
ff,
|
|
197
|
-
),
|
|
198
|
-
() => {},
|
|
199
|
-
ff,
|
|
200
|
-
),
|
|
201
|
-
() => {},
|
|
202
|
-
ff,
|
|
203
|
-
),
|
|
204
|
-
(ff) =>
|
|
205
|
-
ffTest(
|
|
206
|
-
'uip.sample.display',
|
|
207
|
-
() => {},
|
|
208
|
-
(ff) =>
|
|
209
|
-
ffTest(
|
|
210
|
-
'uip.sample.opacity',
|
|
211
|
-
() => {},
|
|
212
|
-
() => {},
|
|
213
|
-
ff,
|
|
214
|
-
),
|
|
215
|
-
ff,
|
|
216
|
-
),
|
|
217
|
-
ff,
|
|
218
|
-
),
|
|
219
|
-
);
|
|
220
|
-
});`,
|
|
221
|
-
errors: [
|
|
222
|
-
{
|
|
223
|
-
messageId: 'tooManyNestedTestRunner',
|
|
224
|
-
data: {
|
|
225
|
-
nestedTestRunner: 5,
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
code: `
|
|
232
|
-
ffTest(
|
|
233
|
-
'uip.sample.color',
|
|
234
|
-
(ff) =>
|
|
235
|
-
ffTest(
|
|
236
|
-
'uip.sample.backgroundColor',
|
|
237
|
-
(ff) =>
|
|
238
|
-
ffTest(
|
|
239
|
-
'uip.sample.display',
|
|
240
|
-
() => {},
|
|
241
|
-
() => {},
|
|
242
|
-
ff,
|
|
243
|
-
),
|
|
244
|
-
(ff) =>
|
|
245
|
-
ffTest(
|
|
246
|
-
'uip.sample.display',
|
|
247
|
-
() => {},
|
|
248
|
-
() => {},
|
|
249
|
-
ff,
|
|
250
|
-
),
|
|
251
|
-
ff,
|
|
252
|
-
),
|
|
253
|
-
(ff) =>
|
|
254
|
-
ffTest(
|
|
255
|
-
'uip.sample.backgroundColor',
|
|
256
|
-
(ff) =>
|
|
257
|
-
ffTest(
|
|
258
|
-
'uip.sample.display',
|
|
259
|
-
(ff) =>
|
|
260
|
-
ffTest(
|
|
261
|
-
'uip.sample.opacity',
|
|
262
|
-
(ff) =>
|
|
263
|
-
ffTest(
|
|
264
|
-
'uip.sample.font',
|
|
265
|
-
(ff) =>
|
|
266
|
-
ffTest(
|
|
267
|
-
'uip.sample.border',
|
|
268
|
-
() => {},
|
|
269
|
-
() => {},
|
|
270
|
-
ff,
|
|
271
|
-
),
|
|
272
|
-
() => {},
|
|
273
|
-
ff,
|
|
274
|
-
),
|
|
275
|
-
() => {},
|
|
276
|
-
ff,
|
|
277
|
-
),
|
|
278
|
-
() => {},
|
|
279
|
-
ff,
|
|
280
|
-
),
|
|
281
|
-
(ff) =>
|
|
282
|
-
ffTest(
|
|
283
|
-
'uip.sample.display',
|
|
284
|
-
() => {},
|
|
285
|
-
(ff) =>
|
|
286
|
-
ffTest(
|
|
287
|
-
'uip.sample.opacity',
|
|
288
|
-
() => {},
|
|
289
|
-
() => {},
|
|
290
|
-
ff,
|
|
291
|
-
),
|
|
292
|
-
ff,
|
|
293
|
-
),
|
|
294
|
-
ff,
|
|
295
|
-
),
|
|
296
|
-
);`,
|
|
297
|
-
errors: [
|
|
298
|
-
{
|
|
299
|
-
messageId: 'tooManyNestedTestRunner',
|
|
300
|
-
data: {
|
|
301
|
-
nestedTestRunner: 6,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
});
|
|
308
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import type { Rule } from 'eslint';
|
|
3
|
-
import type { SimpleCallExpression } from 'estree';
|
|
4
|
-
|
|
5
|
-
const NESTED_LIMIT: number = 4;
|
|
6
|
-
const TEST_RUNNER_IDENTIFIER = 'ffTest' as const;
|
|
7
|
-
|
|
8
|
-
const getDepthOfNestedRunner = (node: SimpleCallExpression & Rule.NodeParentExtension): number => {
|
|
9
|
-
// Calculate the depth of a binary tree, using a queue to track path
|
|
10
|
-
let queue: (typeof node)[] = [];
|
|
11
|
-
queue.push(node);
|
|
12
|
-
let depth = 0;
|
|
13
|
-
while (queue.length > 0) {
|
|
14
|
-
let nodeCount = queue.length;
|
|
15
|
-
while (nodeCount > 0) {
|
|
16
|
-
let currentNode = queue.shift() as typeof node;
|
|
17
|
-
if (
|
|
18
|
-
currentNode.arguments[1].type === 'ArrowFunctionExpression' &&
|
|
19
|
-
currentNode.arguments[1].body.type === 'CallExpression' &&
|
|
20
|
-
currentNode.arguments[1].body.callee.type === 'Identifier' &&
|
|
21
|
-
currentNode.arguments[1].body.callee.name === TEST_RUNNER_IDENTIFIER
|
|
22
|
-
) {
|
|
23
|
-
queue.push({
|
|
24
|
-
...currentNode.arguments[1].body,
|
|
25
|
-
parent: currentNode.parent,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (
|
|
29
|
-
currentNode.arguments[2]?.type === 'ArrowFunctionExpression' &&
|
|
30
|
-
currentNode.arguments[2].body.type === 'CallExpression' &&
|
|
31
|
-
currentNode.arguments[2].body.callee.type === 'Identifier' &&
|
|
32
|
-
currentNode.arguments[2].body.callee.name === TEST_RUNNER_IDENTIFIER
|
|
33
|
-
) {
|
|
34
|
-
queue.push({
|
|
35
|
-
...currentNode.arguments[2].body,
|
|
36
|
-
parent: currentNode.parent,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
nodeCount--;
|
|
40
|
-
}
|
|
41
|
-
depth++;
|
|
42
|
-
}
|
|
43
|
-
return depth;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const rule: Rule.RuleModule = {
|
|
47
|
-
meta: {
|
|
48
|
-
docs: {
|
|
49
|
-
recommended: false,
|
|
50
|
-
},
|
|
51
|
-
type: 'problem',
|
|
52
|
-
messages: {
|
|
53
|
-
tooManyNestedTestRunner:
|
|
54
|
-
'{{nestedTestRunner}} test runners are nested. Feature flags may need a clean-up',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
create(context) {
|
|
58
|
-
return {
|
|
59
|
-
// Find the most outside test runner, could be inside a describe or not
|
|
60
|
-
[`Program > * > CallExpression[callee.name=/${TEST_RUNNER_IDENTIFIER}/], CallExpression[callee.name=/describe/] > * > * > * > CallExpression[callee.name=/${TEST_RUNNER_IDENTIFIER}/]`]:
|
|
61
|
-
(node: Rule.Node) => {
|
|
62
|
-
if (node.type === 'CallExpression') {
|
|
63
|
-
// Calculate the depth of nested test runners, counting from the most outside
|
|
64
|
-
const depth = getDepthOfNestedRunner(node);
|
|
65
|
-
|
|
66
|
-
if (depth > NESTED_LIMIT) {
|
|
67
|
-
return context.report({
|
|
68
|
-
node,
|
|
69
|
-
messageId: 'tooManyNestedTestRunner',
|
|
70
|
-
data: {
|
|
71
|
-
nestedTestRunner: depth.toString(),
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return {};
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default rule;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { tester } from '../../../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../../index';
|
|
3
|
-
|
|
4
|
-
const cwd = process.cwd();
|
|
5
|
-
|
|
6
|
-
const mockValidBinPaths = [
|
|
7
|
-
`${cwd}/packages/foo/run-ts.bin`,
|
|
8
|
-
`${cwd}/packages/foo/scripts/run-ts.bin`,
|
|
9
|
-
`${cwd}/packages/foo/bar/run-ts.ts`,
|
|
10
|
-
`${cwd}/packages/foo/bar/scripts/run-ts.ts`,
|
|
11
|
-
`${cwd}/packages/baz/run-ts.js`,
|
|
12
|
-
`${cwd}/packages/baz/scripts/run-ts.js`,
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
jest.mock('fs', () => {
|
|
16
|
-
const actual = jest.requireActual('fs');
|
|
17
|
-
return {
|
|
18
|
-
...actual,
|
|
19
|
-
statSync: jest.fn((p: string) => ({
|
|
20
|
-
isFile: jest.fn(() => mockValidBinPaths.includes(p)),
|
|
21
|
-
isDirectory: jest.fn(() => actual.statSync(p).isDirectory()),
|
|
22
|
-
})),
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('test ensure-valid-bin-values rule', () => {
|
|
27
|
-
tester.run('ensure-valid-bin-values', rule, {
|
|
28
|
-
valid: [
|
|
29
|
-
// .bin files are valid
|
|
30
|
-
{
|
|
31
|
-
code: `const foo = {
|
|
32
|
-
"bin": {
|
|
33
|
-
"run-ts": "./run-ts.bin",
|
|
34
|
-
}
|
|
35
|
-
}`,
|
|
36
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: `const foo = {
|
|
40
|
-
"bin": {
|
|
41
|
-
"run-ts": "./scripts/run-ts.bin",
|
|
42
|
-
}
|
|
43
|
-
}`,
|
|
44
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
45
|
-
},
|
|
46
|
-
// .ts files are valid
|
|
47
|
-
{
|
|
48
|
-
code: `const foo = {
|
|
49
|
-
"bin": {
|
|
50
|
-
"run-ts": "./run-ts.ts",
|
|
51
|
-
}
|
|
52
|
-
}`,
|
|
53
|
-
filename: `${cwd}/packages/foo/bar/package.json`,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
code: `const foo = {
|
|
57
|
-
"bin": {
|
|
58
|
-
"run-ts": "./scripts/run-ts.ts",
|
|
59
|
-
}
|
|
60
|
-
}`,
|
|
61
|
-
filename: `${cwd}/packages/foo/bar/package.json`,
|
|
62
|
-
},
|
|
63
|
-
// .js files are valid
|
|
64
|
-
{
|
|
65
|
-
code: `const foo = {
|
|
66
|
-
"bin": {
|
|
67
|
-
"run-ts": "./run-ts.js",
|
|
68
|
-
}
|
|
69
|
-
}`,
|
|
70
|
-
filename: `${cwd}/packages/baz/package.json`,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
code: `const foo = {
|
|
74
|
-
"bin": {
|
|
75
|
-
"run-ts": "./scripts/run-ts.js",
|
|
76
|
-
}
|
|
77
|
-
}`,
|
|
78
|
-
filename: `${cwd}/packages/baz/package.json`,
|
|
79
|
-
},
|
|
80
|
-
// dist paths are valid
|
|
81
|
-
{
|
|
82
|
-
code: `const foo = {
|
|
83
|
-
"bin": {
|
|
84
|
-
"run-ts": "./dist/run-ts.js",
|
|
85
|
-
}
|
|
86
|
-
}`,
|
|
87
|
-
filename: `${cwd}/packages/baz/package.json`,
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
invalid: [
|
|
91
|
-
// Pointing to anything other than a file is invalid
|
|
92
|
-
{
|
|
93
|
-
code: `const foo = {
|
|
94
|
-
"bin": {
|
|
95
|
-
"run-ts": "./bin",
|
|
96
|
-
}
|
|
97
|
-
}`,
|
|
98
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
99
|
-
errors: [
|
|
100
|
-
{
|
|
101
|
-
messageId: 'invalidBinValue',
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
code: `const foo = {
|
|
107
|
-
"bin": {
|
|
108
|
-
"run-ts": "./scripts/index",
|
|
109
|
-
}
|
|
110
|
-
}`,
|
|
111
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
112
|
-
errors: [
|
|
113
|
-
{
|
|
114
|
-
messageId: 'invalidBinValue',
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
code: `const foo = {
|
|
120
|
-
"bin": {
|
|
121
|
-
"run-ts": "./scripts/bin",
|
|
122
|
-
}
|
|
123
|
-
}`,
|
|
124
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
125
|
-
errors: [
|
|
126
|
-
{
|
|
127
|
-
messageId: 'invalidBinValue',
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
code: `const foo = {
|
|
133
|
-
"bin": {
|
|
134
|
-
"run-ts": "./",
|
|
135
|
-
}
|
|
136
|
-
}`,
|
|
137
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
138
|
-
errors: [
|
|
139
|
-
{
|
|
140
|
-
messageId: 'invalidBinValue',
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
code: `const foo = {
|
|
146
|
-
"bin": {
|
|
147
|
-
"run-ts": "",
|
|
148
|
-
}
|
|
149
|
-
}`,
|
|
150
|
-
filename: `${cwd}/packages/foo/package.json`,
|
|
151
|
-
errors: [
|
|
152
|
-
{
|
|
153
|
-
messageId: 'invalidBinValue',
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
});
|
|
159
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { resolve, dirname } from 'path';
|
|
4
|
-
import type { Rule } from 'eslint';
|
|
5
|
-
import type { ObjectExpression } from 'estree';
|
|
6
|
-
import { getObjectPropertyAsObject } from '../util/handle-ast-object';
|
|
7
|
-
|
|
8
|
-
const cwd = process.cwd();
|
|
9
|
-
|
|
10
|
-
function checkIsAllBinValuesAreValid(node: ObjectExpression, packageDir: string) {
|
|
11
|
-
const binObj = getObjectPropertyAsObject(node, 'bin');
|
|
12
|
-
|
|
13
|
-
if (!binObj || !Array.isArray(binObj.properties)) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return binObj.properties.every((p) => {
|
|
18
|
-
if (p.type === 'Property' && p.value.type === 'Literal') {
|
|
19
|
-
try {
|
|
20
|
-
const binValue = String(p.value.value);
|
|
21
|
-
const pathToBin = resolve(cwd, packageDir, binValue);
|
|
22
|
-
// Ignore bin values that point to dist as these files don't always exist
|
|
23
|
-
if (binValue.startsWith('./dist/')) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return fs.statSync(pathToBin).isFile();
|
|
27
|
-
} catch (err) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// If it's not a property or doesn't have a literal value, consider it invalid
|
|
32
|
-
return false;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const rule: Rule.RuleModule = {
|
|
37
|
-
meta: {
|
|
38
|
-
type: 'problem',
|
|
39
|
-
docs: {
|
|
40
|
-
description: `Ensures bin values in package.json files are valid.`,
|
|
41
|
-
recommended: true,
|
|
42
|
-
},
|
|
43
|
-
hasSuggestions: false,
|
|
44
|
-
messages: {
|
|
45
|
-
invalidBinValue: `Invalid bin value. Ensure that the value points to a file and not a directory.`,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
create(context) {
|
|
49
|
-
const fileName = context.getFilename();
|
|
50
|
-
return {
|
|
51
|
-
ObjectExpression: (node: Rule.Node) => {
|
|
52
|
-
if (!fileName.endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const isAllBinValuesValid = checkIsAllBinValuesAreValid(node, dirname(fileName));
|
|
57
|
-
if (isAllBinValuesValid) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return context.report({
|
|
62
|
-
node,
|
|
63
|
-
messageId: 'invalidBinValue',
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default rule;
|