@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 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
- - [#82550](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82550) [`f0948af9e586`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f0948af9e586) - Allow typescript upgrade to 5.x
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
- - [#81166](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81166) [`a249a1bd29a6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a249a1bd29a6) - Upgrade ESLint to version 8
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
- - [#78702](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78702) [`6b76dabb8255`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b76dabb8255) - Add rule to check for invalid flag usages in exports
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
- - [#43563](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43563) [`51f9f6e2f10`](https://bitbucket.org/atlassian/atlassian-frontend/commits/51f9f6e2f10) - Add @types/react v18.2 to critical deps whitelist
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
- - [#41190](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41190) [`a5047d254d4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5047d254d4) - Add no-duplicate-dependencies rule and enable package-json-processor autofix
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
- - [#39249](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39249) [`7efeb93141c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7efeb93141c) - Add a rule to ensure critical packages are resolved to the correct versions
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
- - [#39049](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39049) [`e5f52093b2a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e5f52093b2a) - Add a rule to ensure that publish config is correct for packages
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
- - [#38261](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38261) [`eb64cbdd681`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb64cbdd681) - Add a new rule to verify that the atlassian team is defined if the relevant section exists in the package.json
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
- - [#33879](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33879) [`0bf64fb3dd0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0bf64fb3dd0) - Update to support unary expressions like negation
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
- - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793) [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
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
- - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649) [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
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
- - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258) [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
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
- - [#32441](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32441) [`cb0e94d2ce4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb0e94d2ce4) - Fix prefixes for all flags being checked at any callsite, only the current flag will be checked from now on
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
- - [#32424](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32424) [`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY remove before merging to master; dupe adf-schema via adf-utils
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
- - [#31962](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31962) [`e8a8808f299`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e8a8808f299) - Add a new eslint rule that enforces prefixes on platform feature flags. Ignore existing usages.
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
- - [#31956](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31956) [`b47e48ad163`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b47e48ad163) - Adds an eslint rule to confirm that storybooks only get passed an object - to ensure that codemods work correctly.
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
- - [#31631](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31631) [`971489f4ff4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/971489f4ff4) - Add test runner to identified calls that require registration of platform feature flags
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
- - [#31581](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31581) [`7facf919a4e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7facf919a4e) - Remove product specific rules and make it so the recommended set is used everywhere instead
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
- - [#31440](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31440) [`166815fbd8f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/166815fbd8f) - Add recommended set of flags for use in products
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
- - [#30710](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30710) [`7edd9e8b4b1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7edd9e8b4b1) - Add suggestion to change feature flag to the closest matching feature flag using fuzzy search
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
- - [#30401](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30401) [`6339334e3ac`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6339334e3ac) - Adds new rule to disallow pre/post install scripts in package.json.
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
- - [#30777](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30777) [`0cab60b90c3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0cab60b90c3) - Add fix to eslint rule on the arguments of nested test runner
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
- - [#30491](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30491) [`99449cce7f5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/99449cce7f5) - Eslint rules around test runner arguments and limit on nested test runners
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
- - [#30484](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30484) [`aeb52cac34c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/aeb52cac34c) - Split feature flag registration rule into two to more easily use it in products
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
- - [#30432](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30432) [`cd5b194f403`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cd5b194f403) - Add check to ensure that there is only one feature flag call per expression
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
- - [#30320](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30320) [`11706c3e7c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/11706c3e7c5) - Publish platform eslint rules to npm to be consumed in other products
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
- - [#28303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/28303) [`85dc0230439`](https://bitbucket.org/atlassian/atlassian-frontend/commits/85dc0230439) - Add eslint rule to allow for platform feature flag usage
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: ['4.9', '5.4'],
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
- // TODO: remove '|| !packageJson['exports']' once all package.json files have 'exports'
45
- if (!pkgName || !packageJson['af:exports'] || !packageJson['exports']) {
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 {
@@ -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: ['4.9', '5.4'],
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
- // TODO: remove '|| !packageJson['exports']' once all package.json files have 'exports'
35
- if (!pkgName || !packageJson['af:exports'] || !packageJson['exports']) {
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: ['4.9', '5.4'],
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
- // TODO: remove '|| !packageJson['exports']' once all package.json files have 'exports'
38
- if (!pkgName || !packageJson['af:exports'] || !packageJson['exports']) {
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 {
@@ -31,4 +31,5 @@ export declare const configs: {
31
31
  };
32
32
  export declare const processors: {
33
33
  'package-json-processor': Linter.Processor<string | Linter.ProcessorFile>;
34
+ 'package-json-processor-for-flat-config': Linter.Processor<string | Linter.ProcessorFile>;
34
35
  };
@@ -31,4 +31,5 @@ export declare const configs: {
31
31
  };
32
32
  export declare const processors: {
33
33
  'package-json-processor': Linter.Processor<string | Linter.ProcessorFile>;
34
+ 'package-json-processor-for-flat-config': Linter.Processor<string | Linter.ProcessorFile>;
34
35
  };
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.0",
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.4.5",
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.9.5",
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.9.5",
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.9.8",
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.9.8",
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": "4.5.8",
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": "~4.5.8",
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.9.5",
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": "4.5.8",
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: ['4.9', '5.4'],
11
+ typescript: ['5.4'],
11
12
  '@types/react': ['16.14', '18.2'],
12
13
  };
13
14
 
@@ -1,6 +1,6 @@
1
1
  import { tester } from '../../../../__tests__/utils/_tester';
2
2
  import rule from '../../index';
3
- import { PackageJson } from 'read-pkg-up';
3
+ import { type PackageJson } from 'read-pkg-up';
4
4
 
5
5
  let mockPath = 'test/package.json';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { tester } from '../../../../__tests__/utils/_tester';
2
2
  import rule from '../../index';
3
- import { PackageJson } from 'read-pkg-up';
3
+ import { type PackageJson } from 'read-pkg-up';
4
4
 
5
5
  let mockPath = 'test/package.json';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { tester } from '../../../../__tests__/utils/_tester';
2
2
  import rule from '../../index';
3
- import { PackageJson } from 'read-pkg-up';
3
+ import { type PackageJson } from 'read-pkg-up';
4
4
 
5
5
  let mockPath = 'packages/test/package.json';
6
6
 
@@ -41,20 +41,18 @@ const rule: Rule.RuleModule = {
41
41
 
42
42
  const pkgName = packageJson.name;
43
43
 
44
- // TODO: remove '|| !packageJson['exports']' once all package.json files have 'exports'
45
- if (!pkgName || !packageJson['af:exports'] || !packageJson['exports']) {
44
+ if (!pkgName || !packageJson['af:exports']) {
46
45
  return {};
47
46
  }
48
47
 
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
- // }
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'];