@atlaskit/eslint-plugin-platform 0.0.6 → 0.0.7
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 +6 -0
- package/dist/cjs/rules/ensure-test-runner-arguments/index.js +19 -8
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/rules/ensure-test-runner-arguments/index.js +19 -8
- package/dist/es2019/version.json +1 -1
- package/dist/esm/rules/ensure-test-runner-arguments/index.js +19 -8
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
- package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +77 -0
- package/src/rules/ensure-test-runner-arguments/index.tsx +29 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 0.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0cab60b90c3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0cab60b90c3) - Add fix to eslint rule on the arguments of nested test runner
|
|
8
|
+
|
|
3
9
|
## 0.0.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -13,11 +13,12 @@ var rule = {
|
|
|
13
13
|
recommended: false
|
|
14
14
|
},
|
|
15
15
|
type: 'problem',
|
|
16
|
+
fixable: 'code',
|
|
16
17
|
messages: {
|
|
17
18
|
onlyInlineFeatureFlag: 'Only pass in feature flag as string literal, please replace {{identifierName}} with its value.',
|
|
18
19
|
onlyInlineTestFunction: 'Only pass in test functions/cases in an inline manner. Test functions/cases should be passed in directly, instead of as variables. Please replace {{identifierName}} with its own definition.',
|
|
19
|
-
passDownExistingFeatureFlagParam: '
|
|
20
|
-
passDownExistingFeatureFlagArgument: '
|
|
20
|
+
passDownExistingFeatureFlagParam: 'An argument symbolising existing FFs needs to be passed down as param when calling nested test runner. See examples in the package which declares this function.',
|
|
21
|
+
passDownExistingFeatureFlagArgument: 'An argument symbolising existing FFs needs to be passed in as argument when calling nested test runner. See examples in the package which declares this function.',
|
|
21
22
|
passDownExistingFeatureFlagNamesMatch: 'Argument names not matching when passing down existing feature flags. See examples in the package which declares this function.'
|
|
22
23
|
}
|
|
23
24
|
},
|
|
@@ -64,25 +65,35 @@ var rule = {
|
|
|
64
65
|
// Not pass in ff to the function that calls test runner
|
|
65
66
|
if (!node.parent.params[0] || node.parent.params[0].type !== 'Identifier') {
|
|
66
67
|
return context.report({
|
|
67
|
-
node: node,
|
|
68
|
-
messageId: 'passDownExistingFeatureFlagParam'
|
|
68
|
+
node: node.parent,
|
|
69
|
+
messageId: 'passDownExistingFeatureFlagParam',
|
|
70
|
+
fix: function fix(fixer) {
|
|
71
|
+
var parentNodeRange = node.parent.range;
|
|
72
|
+
return [fixer.replaceTextRange([parentNodeRange[0], parentNodeRange[0] + 2], 'ff'), node.arguments[3] ? fixer.replaceText(node.arguments[3], 'ff') : fixer.insertTextAfter(node.arguments[2], ', ff')];
|
|
73
|
+
}
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
// Not pass in ff to test runner as 4th argument
|
|
78
|
+
var paramName = node.parent.params[0].name;
|
|
73
79
|
if (!node.arguments[3] || node.arguments[3].type !== 'Identifier') {
|
|
74
80
|
return context.report({
|
|
75
81
|
node: node,
|
|
76
|
-
messageId: 'passDownExistingFeatureFlagArgument'
|
|
82
|
+
messageId: 'passDownExistingFeatureFlagArgument',
|
|
83
|
+
fix: function fix(fixer) {
|
|
84
|
+
return node.arguments[3] ? fixer.replaceText(node.arguments[3], paramName) : fixer.insertTextAfter(node.arguments[2], ", ".concat(paramName));
|
|
85
|
+
}
|
|
77
86
|
});
|
|
78
87
|
}
|
|
79
88
|
// Pass in the above two, but names don't match
|
|
80
|
-
var paramName = node.parent.params[0].name;
|
|
81
89
|
var arguName = node.arguments[3].name;
|
|
82
90
|
if (paramName !== arguName) {
|
|
83
91
|
return context.report({
|
|
84
|
-
node: node,
|
|
85
|
-
messageId: 'passDownExistingFeatureFlagNamesMatch'
|
|
92
|
+
node: node.parent,
|
|
93
|
+
messageId: 'passDownExistingFeatureFlagNamesMatch',
|
|
94
|
+
fix: function fix(fixer) {
|
|
95
|
+
return fixer.replaceText(node.arguments[3], paramName);
|
|
96
|
+
}
|
|
86
97
|
});
|
|
87
98
|
}
|
|
88
99
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -5,11 +5,12 @@ const rule = {
|
|
|
5
5
|
recommended: false
|
|
6
6
|
},
|
|
7
7
|
type: 'problem',
|
|
8
|
+
fixable: 'code',
|
|
8
9
|
messages: {
|
|
9
10
|
onlyInlineFeatureFlag: 'Only pass in feature flag as string literal, please replace {{identifierName}} with its value.',
|
|
10
11
|
onlyInlineTestFunction: 'Only pass in test functions/cases in an inline manner. Test functions/cases should be passed in directly, instead of as variables. Please replace {{identifierName}} with its own definition.',
|
|
11
|
-
passDownExistingFeatureFlagParam: '
|
|
12
|
-
passDownExistingFeatureFlagArgument: '
|
|
12
|
+
passDownExistingFeatureFlagParam: 'An argument symbolising existing FFs needs to be passed down as param when calling nested test runner. See examples in the package which declares this function.',
|
|
13
|
+
passDownExistingFeatureFlagArgument: 'An argument symbolising existing FFs needs to be passed in as argument when calling nested test runner. See examples in the package which declares this function.',
|
|
13
14
|
passDownExistingFeatureFlagNamesMatch: 'Argument names not matching when passing down existing feature flags. See examples in the package which declares this function.'
|
|
14
15
|
}
|
|
15
16
|
},
|
|
@@ -57,25 +58,35 @@ const rule = {
|
|
|
57
58
|
// Not pass in ff to the function that calls test runner
|
|
58
59
|
if (!node.parent.params[0] || node.parent.params[0].type !== 'Identifier') {
|
|
59
60
|
return context.report({
|
|
60
|
-
node,
|
|
61
|
-
messageId: 'passDownExistingFeatureFlagParam'
|
|
61
|
+
node: node.parent,
|
|
62
|
+
messageId: 'passDownExistingFeatureFlagParam',
|
|
63
|
+
fix: function (fixer) {
|
|
64
|
+
const parentNodeRange = node.parent.range;
|
|
65
|
+
return [fixer.replaceTextRange([parentNodeRange[0], parentNodeRange[0] + 2], 'ff'), node.arguments[3] ? fixer.replaceText(node.arguments[3], 'ff') : fixer.insertTextAfter(node.arguments[2], ', ff')];
|
|
66
|
+
}
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
// Not pass in ff to test runner as 4th argument
|
|
71
|
+
const paramName = node.parent.params[0].name;
|
|
66
72
|
if (!node.arguments[3] || node.arguments[3].type !== 'Identifier') {
|
|
67
73
|
return context.report({
|
|
68
74
|
node,
|
|
69
|
-
messageId: 'passDownExistingFeatureFlagArgument'
|
|
75
|
+
messageId: 'passDownExistingFeatureFlagArgument',
|
|
76
|
+
fix: function (fixer) {
|
|
77
|
+
return node.arguments[3] ? fixer.replaceText(node.arguments[3], paramName) : fixer.insertTextAfter(node.arguments[2], `, ${paramName}`);
|
|
78
|
+
}
|
|
70
79
|
});
|
|
71
80
|
}
|
|
72
81
|
// Pass in the above two, but names don't match
|
|
73
|
-
const paramName = node.parent.params[0].name;
|
|
74
82
|
const arguName = node.arguments[3].name;
|
|
75
83
|
if (paramName !== arguName) {
|
|
76
84
|
return context.report({
|
|
77
|
-
node,
|
|
78
|
-
messageId: 'passDownExistingFeatureFlagNamesMatch'
|
|
85
|
+
node: node.parent,
|
|
86
|
+
messageId: 'passDownExistingFeatureFlagNamesMatch',
|
|
87
|
+
fix: function (fixer) {
|
|
88
|
+
return fixer.replaceText(node.arguments[3], paramName);
|
|
89
|
+
}
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
92
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -6,11 +6,12 @@ var rule = {
|
|
|
6
6
|
recommended: false
|
|
7
7
|
},
|
|
8
8
|
type: 'problem',
|
|
9
|
+
fixable: 'code',
|
|
9
10
|
messages: {
|
|
10
11
|
onlyInlineFeatureFlag: 'Only pass in feature flag as string literal, please replace {{identifierName}} with its value.',
|
|
11
12
|
onlyInlineTestFunction: 'Only pass in test functions/cases in an inline manner. Test functions/cases should be passed in directly, instead of as variables. Please replace {{identifierName}} with its own definition.',
|
|
12
|
-
passDownExistingFeatureFlagParam: '
|
|
13
|
-
passDownExistingFeatureFlagArgument: '
|
|
13
|
+
passDownExistingFeatureFlagParam: 'An argument symbolising existing FFs needs to be passed down as param when calling nested test runner. See examples in the package which declares this function.',
|
|
14
|
+
passDownExistingFeatureFlagArgument: 'An argument symbolising existing FFs needs to be passed in as argument when calling nested test runner. See examples in the package which declares this function.',
|
|
14
15
|
passDownExistingFeatureFlagNamesMatch: 'Argument names not matching when passing down existing feature flags. See examples in the package which declares this function.'
|
|
15
16
|
}
|
|
16
17
|
},
|
|
@@ -57,25 +58,35 @@ var rule = {
|
|
|
57
58
|
// Not pass in ff to the function that calls test runner
|
|
58
59
|
if (!node.parent.params[0] || node.parent.params[0].type !== 'Identifier') {
|
|
59
60
|
return context.report({
|
|
60
|
-
node: node,
|
|
61
|
-
messageId: 'passDownExistingFeatureFlagParam'
|
|
61
|
+
node: node.parent,
|
|
62
|
+
messageId: 'passDownExistingFeatureFlagParam',
|
|
63
|
+
fix: function fix(fixer) {
|
|
64
|
+
var parentNodeRange = node.parent.range;
|
|
65
|
+
return [fixer.replaceTextRange([parentNodeRange[0], parentNodeRange[0] + 2], 'ff'), node.arguments[3] ? fixer.replaceText(node.arguments[3], 'ff') : fixer.insertTextAfter(node.arguments[2], ', ff')];
|
|
66
|
+
}
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
// Not pass in ff to test runner as 4th argument
|
|
71
|
+
var paramName = node.parent.params[0].name;
|
|
66
72
|
if (!node.arguments[3] || node.arguments[3].type !== 'Identifier') {
|
|
67
73
|
return context.report({
|
|
68
74
|
node: node,
|
|
69
|
-
messageId: 'passDownExistingFeatureFlagArgument'
|
|
75
|
+
messageId: 'passDownExistingFeatureFlagArgument',
|
|
76
|
+
fix: function fix(fixer) {
|
|
77
|
+
return node.arguments[3] ? fixer.replaceText(node.arguments[3], paramName) : fixer.insertTextAfter(node.arguments[2], ", ".concat(paramName));
|
|
78
|
+
}
|
|
70
79
|
});
|
|
71
80
|
}
|
|
72
81
|
// Pass in the above two, but names don't match
|
|
73
|
-
var paramName = node.parent.params[0].name;
|
|
74
82
|
var arguName = node.arguments[3].name;
|
|
75
83
|
if (paramName !== arguName) {
|
|
76
84
|
return context.report({
|
|
77
|
-
node: node,
|
|
78
|
-
messageId: 'passDownExistingFeatureFlagNamesMatch'
|
|
85
|
+
node: node.parent,
|
|
86
|
+
messageId: 'passDownExistingFeatureFlagNamesMatch',
|
|
87
|
+
fix: function fix(fixer) {
|
|
88
|
+
return fixer.replaceText(node.arguments[3], paramName);
|
|
89
|
+
}
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
92
|
}
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-platform",
|
|
3
3
|
"description": "The essential plugin for use with Atlassian frontend platform tools",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "UIP - Platform Integration Trust (PITa)",
|
|
@@ -145,6 +145,32 @@ describe('Verify existing ff overrides are passed down if test runner is nested'
|
|
|
145
145
|
),
|
|
146
146
|
);
|
|
147
147
|
`,
|
|
148
|
+
output: `ffTest(
|
|
149
|
+
'uip.sample.color',
|
|
150
|
+
ff =>
|
|
151
|
+
ffTest(
|
|
152
|
+
'uip.sample.backgroundColor',
|
|
153
|
+
() => {
|
|
154
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
155
|
+
},
|
|
156
|
+
() => {
|
|
157
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
158
|
+
},
|
|
159
|
+
ff,
|
|
160
|
+
),
|
|
161
|
+
ff =>
|
|
162
|
+
ffTest(
|
|
163
|
+
'uip.sample.backgroundColor',
|
|
164
|
+
() => {
|
|
165
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
166
|
+
},
|
|
167
|
+
() => {
|
|
168
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
169
|
+
},
|
|
170
|
+
ff,
|
|
171
|
+
),
|
|
172
|
+
);
|
|
173
|
+
`,
|
|
148
174
|
errors: [
|
|
149
175
|
{
|
|
150
176
|
messageId: 'passDownExistingFeatureFlagParam',
|
|
@@ -177,6 +203,31 @@ describe('Verify existing ff overrides are passed down if test runner is nested'
|
|
|
177
203
|
),
|
|
178
204
|
);
|
|
179
205
|
`,
|
|
206
|
+
output: `ffTest(
|
|
207
|
+
'uip.sample.color',
|
|
208
|
+
ff =>
|
|
209
|
+
ffTest(
|
|
210
|
+
'uip.sample.backgroundColor',
|
|
211
|
+
() => {
|
|
212
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
213
|
+
},
|
|
214
|
+
() => {
|
|
215
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
216
|
+
}, ff,
|
|
217
|
+
),
|
|
218
|
+
ff =>
|
|
219
|
+
ffTest(
|
|
220
|
+
'uip.sample.backgroundColor',
|
|
221
|
+
() => {
|
|
222
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
223
|
+
},
|
|
224
|
+
() => {
|
|
225
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
226
|
+
},
|
|
227
|
+
ff,
|
|
228
|
+
),
|
|
229
|
+
);
|
|
230
|
+
`,
|
|
180
231
|
errors: [
|
|
181
232
|
{
|
|
182
233
|
messageId: 'passDownExistingFeatureFlagArgument',
|
|
@@ -210,6 +261,32 @@ describe('Verify existing ff overrides are passed down if test runner is nested'
|
|
|
210
261
|
),
|
|
211
262
|
);
|
|
212
263
|
`,
|
|
264
|
+
output: `ffTest(
|
|
265
|
+
'uip.sample.color',
|
|
266
|
+
ff =>
|
|
267
|
+
ffTest(
|
|
268
|
+
'uip.sample.backgroundColor',
|
|
269
|
+
() => {
|
|
270
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
271
|
+
},
|
|
272
|
+
() => {
|
|
273
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: red');
|
|
274
|
+
},
|
|
275
|
+
ff,
|
|
276
|
+
),
|
|
277
|
+
ff =>
|
|
278
|
+
ffTest(
|
|
279
|
+
'uip.sample.backgroundColor',
|
|
280
|
+
() => {
|
|
281
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
282
|
+
},
|
|
283
|
+
() => {
|
|
284
|
+
expect(getByText('SampleComponent')).toHaveStyle('color: blue');
|
|
285
|
+
},
|
|
286
|
+
ff,
|
|
287
|
+
),
|
|
288
|
+
);
|
|
289
|
+
`,
|
|
213
290
|
errors: [
|
|
214
291
|
{
|
|
215
292
|
messageId: 'passDownExistingFeatureFlagNamesMatch',
|
|
@@ -8,15 +8,16 @@ const rule: Rule.RuleModule = {
|
|
|
8
8
|
recommended: false,
|
|
9
9
|
},
|
|
10
10
|
type: 'problem',
|
|
11
|
+
fixable: 'code',
|
|
11
12
|
messages: {
|
|
12
13
|
onlyInlineFeatureFlag:
|
|
13
14
|
'Only pass in feature flag as string literal, please replace {{identifierName}} with its value.',
|
|
14
15
|
onlyInlineTestFunction:
|
|
15
16
|
'Only pass in test functions/cases in an inline manner. Test functions/cases should be passed in directly, instead of as variables. Please replace {{identifierName}} with its own definition.',
|
|
16
17
|
passDownExistingFeatureFlagParam:
|
|
17
|
-
'
|
|
18
|
+
'An argument symbolising existing FFs needs to be passed down as param when calling nested test runner. See examples in the package which declares this function.',
|
|
18
19
|
passDownExistingFeatureFlagArgument:
|
|
19
|
-
'
|
|
20
|
+
'An argument symbolising existing FFs needs to be passed in as argument when calling nested test runner. See examples in the package which declares this function.',
|
|
20
21
|
passDownExistingFeatureFlagNamesMatch:
|
|
21
22
|
'Argument names not matching when passing down existing feature flags. See examples in the package which declares this function.',
|
|
22
23
|
},
|
|
@@ -78,25 +79,48 @@ const rule: Rule.RuleModule = {
|
|
|
78
79
|
node.parent.params[0].type !== 'Identifier'
|
|
79
80
|
) {
|
|
80
81
|
return context.report({
|
|
81
|
-
node,
|
|
82
|
+
node: node.parent,
|
|
82
83
|
messageId: 'passDownExistingFeatureFlagParam',
|
|
84
|
+
fix: function (fixer) {
|
|
85
|
+
const parentNodeRange = node.parent.range as [number, number];
|
|
86
|
+
return [
|
|
87
|
+
fixer.replaceTextRange(
|
|
88
|
+
[parentNodeRange[0], parentNodeRange[0] + 2],
|
|
89
|
+
'ff',
|
|
90
|
+
),
|
|
91
|
+
node.arguments[3]
|
|
92
|
+
? fixer.replaceText(node.arguments[3], 'ff')
|
|
93
|
+
: fixer.insertTextAfter(node.arguments[2], ', ff'),
|
|
94
|
+
];
|
|
95
|
+
},
|
|
83
96
|
});
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
// Not pass in ff to test runner as 4th argument
|
|
100
|
+
const paramName = node.parent.params[0].name;
|
|
87
101
|
if (!node.arguments[3] || node.arguments[3].type !== 'Identifier') {
|
|
88
102
|
return context.report({
|
|
89
103
|
node,
|
|
90
104
|
messageId: 'passDownExistingFeatureFlagArgument',
|
|
105
|
+
fix: function (fixer) {
|
|
106
|
+
return node.arguments[3]
|
|
107
|
+
? fixer.replaceText(node.arguments[3], paramName)
|
|
108
|
+
: fixer.insertTextAfter(
|
|
109
|
+
node.arguments[2],
|
|
110
|
+
`, ${paramName}`,
|
|
111
|
+
);
|
|
112
|
+
},
|
|
91
113
|
});
|
|
92
114
|
}
|
|
93
115
|
// Pass in the above two, but names don't match
|
|
94
|
-
const paramName = node.parent.params[0].name;
|
|
95
116
|
const arguName = node.arguments[3].name;
|
|
96
117
|
if (paramName !== arguName) {
|
|
97
118
|
return context.report({
|
|
98
|
-
node,
|
|
119
|
+
node: node.parent,
|
|
99
120
|
messageId: 'passDownExistingFeatureFlagNamesMatch',
|
|
121
|
+
fix: function (fixer) {
|
|
122
|
+
return fixer.replaceText(node.arguments[3], paramName);
|
|
123
|
+
},
|
|
100
124
|
});
|
|
101
125
|
}
|
|
102
126
|
}
|