@atlaskit/eslint-plugin-platform 0.6.0 → 0.6.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 +100 -27
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +2 -1
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +11 -14
- package/dist/es2019/index.js +28 -0
- package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +2 -1
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +11 -14
- package/dist/esm/index.js +24 -0
- package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +2 -1
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +11 -14
- package/dist/types/index.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/index.tsx +29 -0
- package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +8 -8
- package/src/rules/ensure-critical-dependency-resolutions/index.tsx +2 -1
- package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +1 -1
- package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +1 -1
- package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +1 -1
- package/src/rules/ensure-native-and-af-exports-synced/index.tsx +9 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,163 +1,236 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#104090](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104090)
|
|
8
|
+
[`3f7cadbe8c81`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f7cadbe8c81) -
|
|
9
|
+
Fixed an issue with the package.json processor in FlatConfig
|
|
10
|
+
|
|
11
|
+
## 0.6.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116)
|
|
16
|
+
[`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) -
|
|
17
|
+
Upgrade Typescript from `4.9.5` to `5.4.2`
|
|
18
|
+
|
|
3
19
|
## 0.6.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
6
22
|
|
|
7
|
-
-
|
|
23
|
+
- [#82550](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82550)
|
|
24
|
+
[`f0948af9e586`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f0948af9e586) -
|
|
25
|
+
Allow typescript upgrade to 5.x
|
|
8
26
|
|
|
9
27
|
## 0.5.0
|
|
10
28
|
|
|
11
29
|
### Minor Changes
|
|
12
30
|
|
|
13
|
-
-
|
|
31
|
+
- [#81166](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81166)
|
|
32
|
+
[`a249a1bd29a6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a249a1bd29a6) -
|
|
33
|
+
Upgrade ESLint to version 8
|
|
14
34
|
|
|
15
35
|
## 0.4.1
|
|
16
36
|
|
|
17
37
|
### Patch Changes
|
|
18
38
|
|
|
19
|
-
-
|
|
39
|
+
- [#78702](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78702)
|
|
40
|
+
[`6b76dabb8255`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b76dabb8255) -
|
|
41
|
+
Add rule to check for invalid flag usages in exports
|
|
20
42
|
|
|
21
43
|
## 0.4.0
|
|
22
44
|
|
|
23
45
|
### Minor Changes
|
|
24
46
|
|
|
25
|
-
-
|
|
47
|
+
- [#43563](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43563)
|
|
48
|
+
[`51f9f6e2f10`](https://bitbucket.org/atlassian/atlassian-frontend/commits/51f9f6e2f10) - Add
|
|
49
|
+
@types/react v18.2 to critical deps whitelist
|
|
26
50
|
|
|
27
51
|
## 0.3.0
|
|
28
52
|
|
|
29
53
|
### Minor Changes
|
|
30
54
|
|
|
31
|
-
-
|
|
55
|
+
- [#41190](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41190)
|
|
56
|
+
[`a5047d254d4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5047d254d4) - Add
|
|
57
|
+
no-duplicate-dependencies rule and enable package-json-processor autofix
|
|
32
58
|
|
|
33
59
|
## 0.2.6
|
|
34
60
|
|
|
35
61
|
### Patch Changes
|
|
36
62
|
|
|
37
|
-
-
|
|
63
|
+
- [#39249](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39249)
|
|
64
|
+
[`7efeb93141c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7efeb93141c) - Add a
|
|
65
|
+
rule to ensure critical packages are resolved to the correct versions
|
|
38
66
|
|
|
39
67
|
## 0.2.5
|
|
40
68
|
|
|
41
69
|
### Patch Changes
|
|
42
70
|
|
|
43
|
-
-
|
|
71
|
+
- [#39049](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39049)
|
|
72
|
+
[`e5f52093b2a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e5f52093b2a) - Add a
|
|
73
|
+
rule to ensure that publish config is correct for packages
|
|
44
74
|
|
|
45
75
|
## 0.2.4
|
|
46
76
|
|
|
47
77
|
### Patch Changes
|
|
48
78
|
|
|
49
|
-
-
|
|
79
|
+
- [#38261](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38261)
|
|
80
|
+
[`eb64cbdd681`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb64cbdd681) - Add a
|
|
81
|
+
new rule to verify that the atlassian team is defined if the relevant section exists in the
|
|
82
|
+
package.json
|
|
50
83
|
|
|
51
84
|
## 0.2.3
|
|
52
85
|
|
|
53
86
|
### Patch Changes
|
|
54
87
|
|
|
55
|
-
-
|
|
88
|
+
- [#33879](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33879)
|
|
89
|
+
[`0bf64fb3dd0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0bf64fb3dd0) - Update
|
|
90
|
+
to support unary expressions like negation
|
|
56
91
|
|
|
57
92
|
## 0.2.2
|
|
58
93
|
|
|
59
94
|
### Patch Changes
|
|
60
95
|
|
|
61
|
-
-
|
|
96
|
+
- [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793)
|
|
97
|
+
[`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure
|
|
98
|
+
legacy types are published for TS 4.5-4.8
|
|
62
99
|
|
|
63
100
|
## 0.2.1
|
|
64
101
|
|
|
65
102
|
### Patch Changes
|
|
66
103
|
|
|
67
|
-
-
|
|
104
|
+
- [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649)
|
|
105
|
+
[`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) -
|
|
106
|
+
Upgrade Typescript from `4.5.5` to `4.9.5`
|
|
68
107
|
|
|
69
108
|
## 0.2.0
|
|
70
109
|
|
|
71
110
|
### Minor Changes
|
|
72
111
|
|
|
73
|
-
-
|
|
112
|
+
- [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258)
|
|
113
|
+
[`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip
|
|
114
|
+
minor dependency bump
|
|
74
115
|
|
|
75
116
|
## 0.1.8
|
|
76
117
|
|
|
77
118
|
### Patch Changes
|
|
78
119
|
|
|
79
|
-
-
|
|
120
|
+
- [#32441](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32441)
|
|
121
|
+
[`cb0e94d2ce4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb0e94d2ce4) - Fix
|
|
122
|
+
prefixes for all flags being checked at any callsite, only the current flag will be checked from
|
|
123
|
+
now on
|
|
80
124
|
|
|
81
125
|
## 0.1.7
|
|
82
126
|
|
|
83
127
|
### Patch Changes
|
|
84
128
|
|
|
85
|
-
-
|
|
129
|
+
- [#32424](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32424)
|
|
130
|
+
[`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY
|
|
131
|
+
remove before merging to master; dupe adf-schema via adf-utils
|
|
86
132
|
|
|
87
133
|
## 0.1.6
|
|
88
134
|
|
|
89
135
|
### Patch Changes
|
|
90
136
|
|
|
91
|
-
-
|
|
137
|
+
- [#31962](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31962)
|
|
138
|
+
[`e8a8808f299`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e8a8808f299) - Add a
|
|
139
|
+
new eslint rule that enforces prefixes on platform feature flags. Ignore existing usages.
|
|
92
140
|
|
|
93
141
|
## 0.1.5
|
|
94
142
|
|
|
95
143
|
### Patch Changes
|
|
96
144
|
|
|
97
|
-
-
|
|
145
|
+
- [#31956](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31956)
|
|
146
|
+
[`b47e48ad163`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b47e48ad163) - Adds
|
|
147
|
+
an eslint rule to confirm that storybooks only get passed an object - to ensure that codemods
|
|
148
|
+
work correctly.
|
|
98
149
|
|
|
99
150
|
## 0.1.4
|
|
100
151
|
|
|
101
152
|
### Patch Changes
|
|
102
153
|
|
|
103
|
-
-
|
|
154
|
+
- [#31631](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31631)
|
|
155
|
+
[`971489f4ff4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/971489f4ff4) - Add
|
|
156
|
+
test runner to identified calls that require registration of platform feature flags
|
|
104
157
|
|
|
105
158
|
## 0.1.3
|
|
106
159
|
|
|
107
160
|
### Patch Changes
|
|
108
161
|
|
|
109
|
-
-
|
|
162
|
+
- [#31581](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31581)
|
|
163
|
+
[`7facf919a4e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7facf919a4e) - Remove
|
|
164
|
+
product specific rules and make it so the recommended set is used everywhere instead
|
|
110
165
|
|
|
111
166
|
## 0.1.2
|
|
112
167
|
|
|
113
168
|
### Patch Changes
|
|
114
169
|
|
|
115
|
-
-
|
|
170
|
+
- [#31440](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31440)
|
|
171
|
+
[`166815fbd8f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/166815fbd8f) - Add
|
|
172
|
+
recommended set of flags for use in products
|
|
116
173
|
|
|
117
174
|
## 0.1.1
|
|
118
175
|
|
|
119
176
|
### Patch Changes
|
|
120
177
|
|
|
121
|
-
-
|
|
178
|
+
- [#30710](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30710)
|
|
179
|
+
[`7edd9e8b4b1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7edd9e8b4b1) - Add
|
|
180
|
+
suggestion to change feature flag to the closest matching feature flag using fuzzy search
|
|
122
181
|
|
|
123
182
|
## 0.1.0
|
|
124
183
|
|
|
125
184
|
### Minor Changes
|
|
126
185
|
|
|
127
|
-
-
|
|
186
|
+
- [#30401](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30401)
|
|
187
|
+
[`6339334e3ac`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6339334e3ac) - Adds
|
|
188
|
+
new rule to disallow pre/post install scripts in package.json.
|
|
128
189
|
|
|
129
190
|
## 0.0.7
|
|
130
191
|
|
|
131
192
|
### Patch Changes
|
|
132
193
|
|
|
133
|
-
-
|
|
194
|
+
- [#30777](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30777)
|
|
195
|
+
[`0cab60b90c3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0cab60b90c3) - Add
|
|
196
|
+
fix to eslint rule on the arguments of nested test runner
|
|
134
197
|
|
|
135
198
|
## 0.0.6
|
|
136
199
|
|
|
137
200
|
### Patch Changes
|
|
138
201
|
|
|
139
|
-
-
|
|
202
|
+
- [#30491](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30491)
|
|
203
|
+
[`99449cce7f5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/99449cce7f5) - Eslint
|
|
204
|
+
rules around test runner arguments and limit on nested test runners
|
|
140
205
|
|
|
141
206
|
## 0.0.5
|
|
142
207
|
|
|
143
208
|
### Patch Changes
|
|
144
209
|
|
|
145
|
-
-
|
|
210
|
+
- [#30484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30484)
|
|
211
|
+
[`aeb52cac34c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/aeb52cac34c) - Split
|
|
212
|
+
feature flag registration rule into two to more easily use it in products
|
|
146
213
|
|
|
147
214
|
## 0.0.4
|
|
148
215
|
|
|
149
216
|
### Patch Changes
|
|
150
217
|
|
|
151
|
-
-
|
|
218
|
+
- [#30432](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30432)
|
|
219
|
+
[`cd5b194f403`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cd5b194f403) - Add
|
|
220
|
+
check to ensure that there is only one feature flag call per expression
|
|
152
221
|
|
|
153
222
|
## 0.0.3
|
|
154
223
|
|
|
155
224
|
### Patch Changes
|
|
156
225
|
|
|
157
|
-
-
|
|
226
|
+
- [#30320](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30320)
|
|
227
|
+
[`11706c3e7c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/11706c3e7c5) -
|
|
228
|
+
Publish platform eslint rules to npm to be consumed in other products
|
|
158
229
|
|
|
159
230
|
## 0.0.2
|
|
160
231
|
|
|
161
232
|
### Patch Changes
|
|
162
233
|
|
|
163
|
-
-
|
|
234
|
+
- [#28303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/28303)
|
|
235
|
+
[`85dc0230439`](https://bitbucket.org/atlassian/atlassian-frontend/commits/85dc0230439) - Add
|
|
236
|
+
eslint rule to allow for platform feature flag usage
|
package/dist/cjs/index.js
CHANGED
|
@@ -51,6 +51,7 @@ var configs = exports.configs = {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
54
|
+
var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
54
55
|
var processors = exports.processors = {
|
|
55
56
|
'package-json-processor': {
|
|
56
57
|
preprocess: function preprocess(source) {
|
|
@@ -72,5 +73,28 @@ var processors = exports.processors = {
|
|
|
72
73
|
});
|
|
73
74
|
},
|
|
74
75
|
supportsAutofix: true
|
|
76
|
+
},
|
|
77
|
+
// This processor is used for ESLint FlatConfig,
|
|
78
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
79
|
+
'package-json-processor-for-flat-config': {
|
|
80
|
+
preprocess: function preprocess(source) {
|
|
81
|
+
// augment the json into a js file
|
|
82
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
83
|
+
},
|
|
84
|
+
postprocess: function postprocess(messages) {
|
|
85
|
+
return messages[0].map(function (message) {
|
|
86
|
+
var fix = message.fix;
|
|
87
|
+
if (!fix) {
|
|
88
|
+
return message;
|
|
89
|
+
}
|
|
90
|
+
var offset = jsonPrefixForFlatConfig.length;
|
|
91
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
92
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
93
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
supportsAutofix: true
|
|
75
99
|
}
|
|
76
100
|
};
|
|
@@ -12,8 +12,9 @@ var _handleAstObject = require("../util/handle-ast-object");
|
|
|
12
12
|
|
|
13
13
|
// Here we only need to specify the major and minor versions
|
|
14
14
|
// In matchMinorVersion, we will check if the versions in resolutions fall in the right ranges.
|
|
15
|
+
//
|
|
15
16
|
var DESIRED_PKG_VERSIONS = {
|
|
16
|
-
typescript: ['
|
|
17
|
+
typescript: ['5.4'],
|
|
17
18
|
'@types/react': ['16.14', '18.2']
|
|
18
19
|
};
|
|
19
20
|
var matchMinorVersion = function matchMinorVersion(desiredVersion, versionInResolutions) {
|
|
@@ -40,22 +40,19 @@ var rule = {
|
|
|
40
40
|
var _getMetadataForFilena = (0, _registrationUtils.getMetadataForFilename)(fileName),
|
|
41
41
|
packageJson = _getMetadataForFilena.pkgJson;
|
|
42
42
|
var pkgName = packageJson.name;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (!pkgName || !packageJson['af:exports']) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
if (!packageJson['exports']) {
|
|
47
|
+
context.report({
|
|
48
|
+
node: context.getSourceCode().ast,
|
|
49
|
+
messageId: 'missingExportsProperty',
|
|
50
|
+
data: {
|
|
51
|
+
pkgName: pkgName
|
|
52
|
+
}
|
|
53
|
+
});
|
|
46
54
|
return {};
|
|
47
55
|
}
|
|
48
|
-
|
|
49
|
-
// TODO: Add back in once all package.json files have 'exports'
|
|
50
|
-
// if (!packageJson['exports']) {
|
|
51
|
-
// context.report({
|
|
52
|
-
// node: context.getSourceCode().ast,
|
|
53
|
-
// messageId: 'missingExportsProperty',
|
|
54
|
-
// data: { pkgName },
|
|
55
|
-
// });
|
|
56
|
-
// return {};
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
56
|
var afExports = packageJson['af:exports'];
|
|
60
57
|
var nativeExports = packageJson['exports'];
|
|
61
58
|
return {
|
package/dist/es2019/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export const configs = {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
46
|
+
const jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
46
47
|
export const processors = {
|
|
47
48
|
'package-json-processor': {
|
|
48
49
|
preprocess: source => {
|
|
@@ -68,5 +69,32 @@ export const processors = {
|
|
|
68
69
|
});
|
|
69
70
|
},
|
|
70
71
|
supportsAutofix: true
|
|
72
|
+
},
|
|
73
|
+
// This processor is used for ESLint FlatConfig,
|
|
74
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
75
|
+
'package-json-processor-for-flat-config': {
|
|
76
|
+
preprocess: source => {
|
|
77
|
+
// augment the json into a js file
|
|
78
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
79
|
+
},
|
|
80
|
+
postprocess: messages => {
|
|
81
|
+
return messages[0].map(message => {
|
|
82
|
+
const {
|
|
83
|
+
fix
|
|
84
|
+
} = message;
|
|
85
|
+
if (!fix) {
|
|
86
|
+
return message;
|
|
87
|
+
}
|
|
88
|
+
const offset = jsonPrefixForFlatConfig.length;
|
|
89
|
+
return {
|
|
90
|
+
...message,
|
|
91
|
+
fix: {
|
|
92
|
+
...fix,
|
|
93
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
supportsAutofix: true
|
|
71
99
|
}
|
|
72
100
|
};
|
|
@@ -5,8 +5,9 @@ import { getObjectPropertyAsObject } from '../util/handle-ast-object';
|
|
|
5
5
|
|
|
6
6
|
// Here we only need to specify the major and minor versions
|
|
7
7
|
// In matchMinorVersion, we will check if the versions in resolutions fall in the right ranges.
|
|
8
|
+
//
|
|
8
9
|
const DESIRED_PKG_VERSIONS = {
|
|
9
|
-
typescript: ['
|
|
10
|
+
typescript: ['5.4'],
|
|
10
11
|
'@types/react': ['16.14', '18.2']
|
|
11
12
|
};
|
|
12
13
|
const matchMinorVersion = (desiredVersion, versionInResolutions) => {
|
|
@@ -30,22 +30,19 @@ const rule = {
|
|
|
30
30
|
pkgJson: packageJson
|
|
31
31
|
} = getMetadataForFilename(fileName);
|
|
32
32
|
const pkgName = packageJson.name;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!pkgName || !packageJson['af:exports']) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
if (!packageJson['exports']) {
|
|
37
|
+
context.report({
|
|
38
|
+
node: context.getSourceCode().ast,
|
|
39
|
+
messageId: 'missingExportsProperty',
|
|
40
|
+
data: {
|
|
41
|
+
pkgName
|
|
42
|
+
}
|
|
43
|
+
});
|
|
36
44
|
return {};
|
|
37
45
|
}
|
|
38
|
-
|
|
39
|
-
// TODO: Add back in once all package.json files have 'exports'
|
|
40
|
-
// if (!packageJson['exports']) {
|
|
41
|
-
// context.report({
|
|
42
|
-
// node: context.getSourceCode().ast,
|
|
43
|
-
// messageId: 'missingExportsProperty',
|
|
44
|
-
// data: { pkgName },
|
|
45
|
-
// });
|
|
46
|
-
// return {};
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
46
|
const afExports = packageJson['af:exports'];
|
|
50
47
|
const nativeExports = packageJson['exports'];
|
|
51
48
|
return {
|
package/dist/esm/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export var configs = {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
49
|
+
var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
49
50
|
export var processors = {
|
|
50
51
|
'package-json-processor': {
|
|
51
52
|
preprocess: function preprocess(source) {
|
|
@@ -67,5 +68,28 @@ export var processors = {
|
|
|
67
68
|
});
|
|
68
69
|
},
|
|
69
70
|
supportsAutofix: true
|
|
71
|
+
},
|
|
72
|
+
// This processor is used for ESLint FlatConfig,
|
|
73
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
74
|
+
'package-json-processor-for-flat-config': {
|
|
75
|
+
preprocess: function preprocess(source) {
|
|
76
|
+
// augment the json into a js file
|
|
77
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
78
|
+
},
|
|
79
|
+
postprocess: function postprocess(messages) {
|
|
80
|
+
return messages[0].map(function (message) {
|
|
81
|
+
var fix = message.fix;
|
|
82
|
+
if (!fix) {
|
|
83
|
+
return message;
|
|
84
|
+
}
|
|
85
|
+
var offset = jsonPrefixForFlatConfig.length;
|
|
86
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
87
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
88
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
supportsAutofix: true
|
|
70
94
|
}
|
|
71
95
|
};
|
|
@@ -6,8 +6,9 @@ import { getObjectPropertyAsObject } from '../util/handle-ast-object';
|
|
|
6
6
|
|
|
7
7
|
// Here we only need to specify the major and minor versions
|
|
8
8
|
// In matchMinorVersion, we will check if the versions in resolutions fall in the right ranges.
|
|
9
|
+
//
|
|
9
10
|
var DESIRED_PKG_VERSIONS = {
|
|
10
|
-
typescript: ['
|
|
11
|
+
typescript: ['5.4'],
|
|
11
12
|
'@types/react': ['16.14', '18.2']
|
|
12
13
|
};
|
|
13
14
|
var matchMinorVersion = function matchMinorVersion(desiredVersion, versionInResolutions) {
|
|
@@ -33,22 +33,19 @@ var rule = {
|
|
|
33
33
|
var _getMetadataForFilena = getMetadataForFilename(fileName),
|
|
34
34
|
packageJson = _getMetadataForFilena.pkgJson;
|
|
35
35
|
var pkgName = packageJson.name;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (!pkgName || !packageJson['af:exports']) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
if (!packageJson['exports']) {
|
|
40
|
+
context.report({
|
|
41
|
+
node: context.getSourceCode().ast,
|
|
42
|
+
messageId: 'missingExportsProperty',
|
|
43
|
+
data: {
|
|
44
|
+
pkgName: pkgName
|
|
45
|
+
}
|
|
46
|
+
});
|
|
39
47
|
return {};
|
|
40
48
|
}
|
|
41
|
-
|
|
42
|
-
// TODO: Add back in once all package.json files have 'exports'
|
|
43
|
-
// if (!packageJson['exports']) {
|
|
44
|
-
// context.report({
|
|
45
|
-
// node: context.getSourceCode().ast,
|
|
46
|
-
// messageId: 'missingExportsProperty',
|
|
47
|
-
// data: { pkgName },
|
|
48
|
-
// });
|
|
49
|
-
// return {};
|
|
50
|
-
// }
|
|
51
|
-
|
|
52
49
|
var afExports = packageJson['af:exports'];
|
|
53
50
|
var nativeExports = packageJson['exports'];
|
|
54
51
|
return {
|
package/dist/types/index.d.ts
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.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "UIP - Platform Integration Trust (PITa)",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
40
|
-
"@types/eslint": "^8.
|
|
40
|
+
"@types/eslint": "^8.56.6",
|
|
41
41
|
"eslint": "^8.49.0",
|
|
42
42
|
"tsconfig-paths": "^4.2.0"
|
|
43
43
|
},
|
package/src/index.tsx
CHANGED
|
@@ -49,6 +49,9 @@ export const configs = {
|
|
|
49
49
|
const jsonPrefix =
|
|
50
50
|
'/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
51
51
|
|
|
52
|
+
const jsonPrefixForFlatConfig =
|
|
53
|
+
'/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
54
|
+
|
|
52
55
|
export const processors = {
|
|
53
56
|
'package-json-processor': {
|
|
54
57
|
preprocess: (source: string) => {
|
|
@@ -74,4 +77,30 @@ export const processors = {
|
|
|
74
77
|
},
|
|
75
78
|
supportsAutofix: true,
|
|
76
79
|
} as Linter.Processor,
|
|
80
|
+
// This processor is used for ESLint FlatConfig,
|
|
81
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
82
|
+
'package-json-processor-for-flat-config': {
|
|
83
|
+
preprocess: (source: string) => {
|
|
84
|
+
// augment the json into a js file
|
|
85
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
86
|
+
},
|
|
87
|
+
postprocess: (messages) => {
|
|
88
|
+
return messages[0].map((message) => {
|
|
89
|
+
const { fix } = message;
|
|
90
|
+
if (!fix) {
|
|
91
|
+
return message;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const offset = jsonPrefixForFlatConfig.length;
|
|
95
|
+
return {
|
|
96
|
+
...message,
|
|
97
|
+
fix: {
|
|
98
|
+
...fix,
|
|
99
|
+
range: [fix.range[0] - offset, fix.range[1] - offset],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
supportsAutofix: true,
|
|
105
|
+
} as Linter.Processor,
|
|
77
106
|
};
|
|
@@ -11,7 +11,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
11
11
|
code: `const foo = {
|
|
12
12
|
"resolutions": {
|
|
13
13
|
"@types/react": "16.14.15",
|
|
14
|
-
"typescript": "4.
|
|
14
|
+
"typescript": "5.4.2",
|
|
15
15
|
}
|
|
16
16
|
}`,
|
|
17
17
|
filename: `${cwd}/package.json`,
|
|
@@ -21,7 +21,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
21
21
|
code: `const foo = {
|
|
22
22
|
"resolutions": {
|
|
23
23
|
"@types/react": "18.2.28",
|
|
24
|
-
"typescript": "4.
|
|
24
|
+
"typescript": "5.4.2",
|
|
25
25
|
}
|
|
26
26
|
}`,
|
|
27
27
|
filename: `${cwd}/package.json`,
|
|
@@ -31,7 +31,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
31
31
|
code: `const foo = {
|
|
32
32
|
"resolutions": {
|
|
33
33
|
"@types/react": "~16.14.25",
|
|
34
|
-
"typescript": "~4.
|
|
34
|
+
"typescript": "~5.4.2",
|
|
35
35
|
}
|
|
36
36
|
}`,
|
|
37
37
|
filename: `${cwd}/package.json`,
|
|
@@ -60,7 +60,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
60
60
|
{
|
|
61
61
|
code: `const foo = {
|
|
62
62
|
"resolutions": {
|
|
63
|
-
"typescript": "~4.
|
|
63
|
+
"typescript": "~5.4.2",
|
|
64
64
|
}
|
|
65
65
|
}`,
|
|
66
66
|
filename: `${cwd}/package.json`,
|
|
@@ -75,7 +75,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
75
75
|
code: `const foo = {
|
|
76
76
|
"resolutions": {
|
|
77
77
|
"@types/react": "16.8.25",
|
|
78
|
-
"typescript": "
|
|
78
|
+
"typescript": "5.1.1",
|
|
79
79
|
}
|
|
80
80
|
}`,
|
|
81
81
|
filename: `${cwd}/package.json`,
|
|
@@ -90,7 +90,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
90
90
|
code: `const foo = {
|
|
91
91
|
"resolutions": {
|
|
92
92
|
"@types/react": "~16.14.25",
|
|
93
|
-
"typescript": "~
|
|
93
|
+
"typescript": "~5.1.1",
|
|
94
94
|
}
|
|
95
95
|
}`,
|
|
96
96
|
filename: `${cwd}/package.json`,
|
|
@@ -105,7 +105,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
105
105
|
code: `const foo = {
|
|
106
106
|
"resolutions": {
|
|
107
107
|
"@types/react": "~16.14.25",
|
|
108
|
-
"typescript": "^4.
|
|
108
|
+
"typescript": "^5.4.2",
|
|
109
109
|
}
|
|
110
110
|
}`,
|
|
111
111
|
filename: `${cwd}/package.json`,
|
|
@@ -120,7 +120,7 @@ describe('test ensure-critical-dependency-resolutions rule', () => {
|
|
|
120
120
|
code: `const foo = {
|
|
121
121
|
"resolutions": {
|
|
122
122
|
"@types/react": "16.14.15",
|
|
123
|
-
"typescript": "
|
|
123
|
+
"typescript": "5.1.1",
|
|
124
124
|
}
|
|
125
125
|
}`,
|
|
126
126
|
filename: `${cwd}/packages/packge/directory/package.json`,
|
|
@@ -6,8 +6,9 @@ import { getObjectPropertyAsObject } from '../util/handle-ast-object';
|
|
|
6
6
|
|
|
7
7
|
// Here we only need to specify the major and minor versions
|
|
8
8
|
// In matchMinorVersion, we will check if the versions in resolutions fall in the right ranges.
|
|
9
|
+
//
|
|
9
10
|
const DESIRED_PKG_VERSIONS: Record<string, string[]> = {
|
|
10
|
-
typescript: ['
|
|
11
|
+
typescript: ['5.4'],
|
|
11
12
|
'@types/react': ['16.14', '18.2'],
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -41,20 +41,18 @@ const rule: Rule.RuleModule = {
|
|
|
41
41
|
|
|
42
42
|
const pkgName = packageJson.name;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
if (!pkgName || !packageJson['af:exports'] || !packageJson['exports']) {
|
|
44
|
+
if (!pkgName || !packageJson['af:exports']) {
|
|
46
45
|
return {};
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// }
|
|
48
|
+
if (!packageJson['exports']) {
|
|
49
|
+
context.report({
|
|
50
|
+
node: context.getSourceCode().ast,
|
|
51
|
+
messageId: 'missingExportsProperty',
|
|
52
|
+
data: { pkgName },
|
|
53
|
+
});
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
58
56
|
|
|
59
57
|
const afExports: { [key: string]: any } = packageJson['af:exports'];
|
|
60
58
|
const nativeExports: { [key: string]: any } = packageJson['exports'];
|