@atlaskit/eslint-plugin-platform 0.6.1 → 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 +95 -28
- package/dist/cjs/index.js +24 -0
- package/dist/es2019/index.js +28 -0
- package/dist/esm/index.js +24 -0
- 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-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/CHANGELOG.md
CHANGED
|
@@ -1,169 +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
|
+
|
|
3
11
|
## 0.6.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
|
-
-
|
|
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`
|
|
8
18
|
|
|
9
19
|
## 0.6.0
|
|
10
20
|
|
|
11
21
|
### Minor Changes
|
|
12
22
|
|
|
13
|
-
-
|
|
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
|
|
14
26
|
|
|
15
27
|
## 0.5.0
|
|
16
28
|
|
|
17
29
|
### Minor Changes
|
|
18
30
|
|
|
19
|
-
-
|
|
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
|
|
20
34
|
|
|
21
35
|
## 0.4.1
|
|
22
36
|
|
|
23
37
|
### Patch Changes
|
|
24
38
|
|
|
25
|
-
-
|
|
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
|
|
26
42
|
|
|
27
43
|
## 0.4.0
|
|
28
44
|
|
|
29
45
|
### Minor Changes
|
|
30
46
|
|
|
31
|
-
-
|
|
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
|
|
32
50
|
|
|
33
51
|
## 0.3.0
|
|
34
52
|
|
|
35
53
|
### Minor Changes
|
|
36
54
|
|
|
37
|
-
-
|
|
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
|
|
38
58
|
|
|
39
59
|
## 0.2.6
|
|
40
60
|
|
|
41
61
|
### Patch Changes
|
|
42
62
|
|
|
43
|
-
-
|
|
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
|
|
44
66
|
|
|
45
67
|
## 0.2.5
|
|
46
68
|
|
|
47
69
|
### Patch Changes
|
|
48
70
|
|
|
49
|
-
-
|
|
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
|
|
50
74
|
|
|
51
75
|
## 0.2.4
|
|
52
76
|
|
|
53
77
|
### Patch Changes
|
|
54
78
|
|
|
55
|
-
-
|
|
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
|
|
56
83
|
|
|
57
84
|
## 0.2.3
|
|
58
85
|
|
|
59
86
|
### Patch Changes
|
|
60
87
|
|
|
61
|
-
-
|
|
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
|
|
62
91
|
|
|
63
92
|
## 0.2.2
|
|
64
93
|
|
|
65
94
|
### Patch Changes
|
|
66
95
|
|
|
67
|
-
-
|
|
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
|
|
68
99
|
|
|
69
100
|
## 0.2.1
|
|
70
101
|
|
|
71
102
|
### Patch Changes
|
|
72
103
|
|
|
73
|
-
-
|
|
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`
|
|
74
107
|
|
|
75
108
|
## 0.2.0
|
|
76
109
|
|
|
77
110
|
### Minor Changes
|
|
78
111
|
|
|
79
|
-
-
|
|
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
|
|
80
115
|
|
|
81
116
|
## 0.1.8
|
|
82
117
|
|
|
83
118
|
### Patch Changes
|
|
84
119
|
|
|
85
|
-
-
|
|
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
|
|
86
124
|
|
|
87
125
|
## 0.1.7
|
|
88
126
|
|
|
89
127
|
### Patch Changes
|
|
90
128
|
|
|
91
|
-
-
|
|
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
|
|
92
132
|
|
|
93
133
|
## 0.1.6
|
|
94
134
|
|
|
95
135
|
### Patch Changes
|
|
96
136
|
|
|
97
|
-
-
|
|
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.
|
|
98
140
|
|
|
99
141
|
## 0.1.5
|
|
100
142
|
|
|
101
143
|
### Patch Changes
|
|
102
144
|
|
|
103
|
-
-
|
|
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.
|
|
104
149
|
|
|
105
150
|
## 0.1.4
|
|
106
151
|
|
|
107
152
|
### Patch Changes
|
|
108
153
|
|
|
109
|
-
-
|
|
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
|
|
110
157
|
|
|
111
158
|
## 0.1.3
|
|
112
159
|
|
|
113
160
|
### Patch Changes
|
|
114
161
|
|
|
115
|
-
-
|
|
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
|
|
116
165
|
|
|
117
166
|
## 0.1.2
|
|
118
167
|
|
|
119
168
|
### Patch Changes
|
|
120
169
|
|
|
121
|
-
-
|
|
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
|
|
122
173
|
|
|
123
174
|
## 0.1.1
|
|
124
175
|
|
|
125
176
|
### Patch Changes
|
|
126
177
|
|
|
127
|
-
-
|
|
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
|
|
128
181
|
|
|
129
182
|
## 0.1.0
|
|
130
183
|
|
|
131
184
|
### Minor Changes
|
|
132
185
|
|
|
133
|
-
-
|
|
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.
|
|
134
189
|
|
|
135
190
|
## 0.0.7
|
|
136
191
|
|
|
137
192
|
### Patch Changes
|
|
138
193
|
|
|
139
|
-
-
|
|
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
|
|
140
197
|
|
|
141
198
|
## 0.0.6
|
|
142
199
|
|
|
143
200
|
### Patch Changes
|
|
144
201
|
|
|
145
|
-
-
|
|
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
|
|
146
205
|
|
|
147
206
|
## 0.0.5
|
|
148
207
|
|
|
149
208
|
### Patch Changes
|
|
150
209
|
|
|
151
|
-
-
|
|
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
|
|
152
213
|
|
|
153
214
|
## 0.0.4
|
|
154
215
|
|
|
155
216
|
### Patch Changes
|
|
156
217
|
|
|
157
|
-
-
|
|
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
|
|
158
221
|
|
|
159
222
|
## 0.0.3
|
|
160
223
|
|
|
161
224
|
### Patch Changes
|
|
162
225
|
|
|
163
|
-
-
|
|
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
|
|
164
229
|
|
|
165
230
|
## 0.0.2
|
|
166
231
|
|
|
167
232
|
### Patch Changes
|
|
168
233
|
|
|
169
|
-
-
|
|
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
|
};
|
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
|
};
|
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
|
};
|
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
|
};
|