@atlaskit/eslint-plugin-platform 2.1.2 → 2.2.0
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 +8 -0
- package/dist/cjs/index.js +105 -63
- package/dist/cjs/rules/compiled/expand-spacing-shorthand/index.js +1 -1
- package/dist/es2019/index.js +116 -74
- package/dist/es2019/rules/compiled/expand-spacing-shorthand/index.js +1 -1
- package/dist/esm/index.js +106 -64
- package/dist/esm/rules/compiled/expand-spacing-shorthand/index.js +1 -1
- package/dist/types/index.d.ts +233 -35
- package/dist/types-ts4.5/index.d.ts +276 -42
- package/package.json +1 -1
- package/src/index.tsx +120 -79
- package/src/rules/compiled/expand-spacing-shorthand/index.ts +1 -1
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import
|
|
2
|
+
import compiledPlugin from '@compiled/eslint-plugin';
|
|
3
|
+
import type { ESLint, Linter } from 'eslint';
|
|
3
4
|
import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registration';
|
|
4
5
|
import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
5
6
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
@@ -27,7 +28,13 @@ import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
|
|
|
27
28
|
import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
|
|
28
29
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
const packageJson: {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
35
|
+
} = require('@atlaskit/eslint-plugin-platform/package.json');
|
|
36
|
+
|
|
37
|
+
const rules = {
|
|
31
38
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
32
39
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
33
40
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
@@ -75,36 +82,27 @@ const commonConfig = {
|
|
|
75
82
|
runtime: 'classic',
|
|
76
83
|
},
|
|
77
84
|
],
|
|
78
|
-
};
|
|
85
|
+
} satisfies Linter.RulesRecord;
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
jira: {
|
|
102
|
-
plugins: ['@atlaskit/platform', '@compiled'],
|
|
103
|
-
rules: {
|
|
104
|
-
...commonConfig,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
87
|
+
const recommendedRules = {
|
|
88
|
+
...commonConfig,
|
|
89
|
+
// See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
|
|
90
|
+
// These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
|
|
91
|
+
'@atlaskit/platform/no-module-level-eval': 'error',
|
|
92
|
+
'@atlaskit/platform/static-feature-flags': 'error',
|
|
93
|
+
'@atlaskit/platform/no-preconditioning': 'error',
|
|
94
|
+
'@atlaskit/platform/inline-usage': 'error',
|
|
95
|
+
'@atlaskit/platform/prefer-fg': 'error',
|
|
96
|
+
'@atlaskit/platform/no-alias': 'error',
|
|
97
|
+
// end: feature-gating rules
|
|
98
|
+
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
99
|
+
'@atlaskit/platform/ensure-feature-flag-prefix': [
|
|
100
|
+
'warn',
|
|
101
|
+
{ allowedPrefixes: ['platform.', 'platform_'] },
|
|
102
|
+
],
|
|
103
|
+
} satisfies Linter.RulesRecord;
|
|
104
|
+
|
|
105
|
+
const jiraRules = commonConfig;
|
|
108
106
|
|
|
109
107
|
const jsonPrefix =
|
|
110
108
|
'/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
@@ -112,55 +110,98 @@ const jsonPrefix =
|
|
|
112
110
|
const jsonPrefixForFlatConfig =
|
|
113
111
|
'/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
const { name, version } = packageJson;
|
|
114
|
+
const plugin = {
|
|
115
|
+
meta: {
|
|
116
|
+
name,
|
|
117
|
+
version,
|
|
118
|
+
},
|
|
119
|
+
rules,
|
|
120
|
+
configs: {
|
|
121
|
+
recommended: {
|
|
122
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
123
|
+
rules: recommendedRules,
|
|
120
124
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
...message,
|
|
131
|
-
fix: {
|
|
132
|
-
...fix,
|
|
133
|
-
range: [fix.range[0] - offset, fix.range[1] - offset],
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
});
|
|
125
|
+
'recommended/flat': {
|
|
126
|
+
plugins: {
|
|
127
|
+
get '@atlaskit/platform'(): ESLint.Plugin {
|
|
128
|
+
return plugin;
|
|
129
|
+
},
|
|
130
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
131
|
+
'@compiled': { meta: compiledPlugin.meta, rules: compiledPlugin.rules } as ESLint.Plugin,
|
|
132
|
+
},
|
|
133
|
+
rules: recommendedRules,
|
|
137
134
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// once we roll out FlatConfig, we can remove the above processor
|
|
142
|
-
'package-json-processor-for-flat-config': {
|
|
143
|
-
preprocess: (source: string) => {
|
|
144
|
-
// augment the json into a js file
|
|
145
|
-
return [jsonPrefixForFlatConfig + source.trim()];
|
|
135
|
+
jira: {
|
|
136
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
137
|
+
rules: jiraRules,
|
|
146
138
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
...message,
|
|
157
|
-
fix: {
|
|
158
|
-
...fix,
|
|
159
|
-
range: [fix.range[0] - offset, fix.range[1] - offset],
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
});
|
|
139
|
+
'jira/flat': {
|
|
140
|
+
plugins: {
|
|
141
|
+
get '@atlaskit/platform'(): ESLint.Plugin {
|
|
142
|
+
return plugin;
|
|
143
|
+
},
|
|
144
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
145
|
+
'@compiled': { meta: compiledPlugin.meta, rules: compiledPlugin.rules } as ESLint.Plugin,
|
|
146
|
+
},
|
|
147
|
+
rules: jiraRules,
|
|
163
148
|
},
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
149
|
+
},
|
|
150
|
+
processors: {
|
|
151
|
+
'package-json-processor': {
|
|
152
|
+
preprocess: (source: string) => {
|
|
153
|
+
// augment the json into a js file
|
|
154
|
+
return [jsonPrefix + source.trim()];
|
|
155
|
+
},
|
|
156
|
+
postprocess: (messages) => {
|
|
157
|
+
return messages[0].map((message) => {
|
|
158
|
+
const { fix } = message;
|
|
159
|
+
if (!fix) {
|
|
160
|
+
return message;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const offset = jsonPrefix.length;
|
|
164
|
+
return {
|
|
165
|
+
...message,
|
|
166
|
+
fix: {
|
|
167
|
+
...fix,
|
|
168
|
+
range: [fix.range[0] - offset, fix.range[1] - offset],
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
supportsAutofix: true,
|
|
174
|
+
} as Linter.Processor,
|
|
175
|
+
// This processor is used for ESLint FlatConfig,
|
|
176
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
177
|
+
'package-json-processor-for-flat-config': {
|
|
178
|
+
preprocess: (source: string) => {
|
|
179
|
+
// augment the json into a js file
|
|
180
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
181
|
+
},
|
|
182
|
+
postprocess: (messages) => {
|
|
183
|
+
return messages[0].map((message) => {
|
|
184
|
+
const { fix } = message;
|
|
185
|
+
if (!fix) {
|
|
186
|
+
return message;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const offset = jsonPrefixForFlatConfig.length;
|
|
190
|
+
return {
|
|
191
|
+
...message,
|
|
192
|
+
fix: {
|
|
193
|
+
...fix,
|
|
194
|
+
range: [fix.range[0] - offset, fix.range[1] - offset],
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
supportsAutofix: true,
|
|
200
|
+
} as Linter.Processor,
|
|
201
|
+
},
|
|
202
|
+
} satisfies ESLint.Plugin;
|
|
203
|
+
const configs = plugin.configs;
|
|
204
|
+
const processors = plugin.processors;
|
|
205
|
+
|
|
206
|
+
export { configs, plugin, processors, rules };
|
|
207
|
+
export default plugin;
|
|
@@ -34,7 +34,7 @@ const parseTemplateLiteral = (templateLiteral: TemplateLiteral, context: Rule.Ru
|
|
|
34
34
|
if (cookedQuasi) {
|
|
35
35
|
const splitQuasis = cookedQuasi.split(' ');
|
|
36
36
|
splitQuasis.forEach((str) => {
|
|
37
|
-
str = str.trim().replace("
|
|
37
|
+
str = str.trim().replace("'", '');
|
|
38
38
|
if (str.length > 0) {
|
|
39
39
|
propertyValues.push(isNaN(Number(str)) ? `'${str}'` : str);
|
|
40
40
|
}
|