@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#103661](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103661)
|
|
8
|
+
[`976a915b13fc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/976a915b13fc2) -
|
|
9
|
+
add flat config support
|
|
10
|
+
|
|
3
11
|
## 2.1.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.rules = exports.processors = exports.configs = void 0;
|
|
7
|
+
exports.rules = exports.processors = exports.plugin = exports.default = exports.configs = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _eslintPlugin = _interopRequireDefault(require("@compiled/eslint-plugin"));
|
|
9
10
|
var _ensureFeatureFlagRegistration = _interopRequireDefault(require("./rules/ensure-feature-flag-registration"));
|
|
10
11
|
var _noPrePostInstalls = _interopRequireDefault(require("./rules/no-pre-post-installs"));
|
|
11
12
|
var _ensureTestRunnerArguments = _interopRequireDefault(require("./rules/ensure-test-runner-arguments"));
|
|
@@ -34,6 +35,7 @@ var _expandBackgroundShorthand = _interopRequireDefault(require("./rules/compile
|
|
|
34
35
|
var _expandSpacingShorthand = _interopRequireDefault(require("./rules/compiled/expand-spacing-shorthand"));
|
|
35
36
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
37
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line import/no-extraneous-dependencies
|
|
38
|
+
var packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
|
|
37
39
|
var rules = exports.rules = {
|
|
38
40
|
'ensure-feature-flag-registration': _ensureFeatureFlagRegistration.default,
|
|
39
41
|
'ensure-feature-flag-prefix': _ensureFeatureFlagPrefix.default,
|
|
@@ -79,75 +81,115 @@ var commonConfig = {
|
|
|
79
81
|
runtime: 'classic'
|
|
80
82
|
}]
|
|
81
83
|
};
|
|
82
|
-
var
|
|
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: _objectSpread({}, commonConfig)
|
|
104
|
-
}
|
|
105
|
-
};
|
|
84
|
+
var recommendedRules = _objectSpread(_objectSpread({}, commonConfig), {}, {
|
|
85
|
+
// See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
|
|
86
|
+
// These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
|
|
87
|
+
'@atlaskit/platform/no-module-level-eval': 'error',
|
|
88
|
+
'@atlaskit/platform/static-feature-flags': 'error',
|
|
89
|
+
'@atlaskit/platform/no-preconditioning': 'error',
|
|
90
|
+
'@atlaskit/platform/inline-usage': 'error',
|
|
91
|
+
'@atlaskit/platform/prefer-fg': 'error',
|
|
92
|
+
'@atlaskit/platform/no-alias': 'error',
|
|
93
|
+
// end: feature-gating rules
|
|
94
|
+
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
95
|
+
'@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
|
|
96
|
+
allowedPrefixes: ['platform.', 'platform_']
|
|
97
|
+
}]
|
|
98
|
+
});
|
|
99
|
+
var jiraRules = commonConfig;
|
|
106
100
|
var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
107
101
|
var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
var name = packageJson.name,
|
|
103
|
+
version = packageJson.version;
|
|
104
|
+
var plugin = exports.plugin = {
|
|
105
|
+
meta: {
|
|
106
|
+
name: name,
|
|
107
|
+
version: version
|
|
108
|
+
},
|
|
109
|
+
rules: rules,
|
|
110
|
+
configs: {
|
|
111
|
+
recommended: {
|
|
112
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
113
|
+
rules: recommendedRules
|
|
113
114
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
'recommended/flat': {
|
|
116
|
+
plugins: {
|
|
117
|
+
get '@atlaskit/platform'() {
|
|
118
|
+
return plugin;
|
|
119
|
+
},
|
|
120
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
121
|
+
'@compiled': {
|
|
122
|
+
meta: _eslintPlugin.default.meta,
|
|
123
|
+
rules: _eslintPlugin.default.rules
|
|
119
124
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
123
|
-
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
});
|
|
125
|
+
},
|
|
126
|
+
rules: recommendedRules
|
|
127
127
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// once we roll out FlatConfig, we can remove the above processor
|
|
132
|
-
'package-json-processor-for-flat-config': {
|
|
133
|
-
preprocess: function preprocess(source) {
|
|
134
|
-
// augment the json into a js file
|
|
135
|
-
return [jsonPrefixForFlatConfig + source.trim()];
|
|
128
|
+
jira: {
|
|
129
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
130
|
+
rules: jiraRules
|
|
136
131
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
'jira/flat': {
|
|
133
|
+
plugins: {
|
|
134
|
+
get '@atlaskit/platform'() {
|
|
135
|
+
return plugin;
|
|
136
|
+
},
|
|
137
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
138
|
+
'@compiled': {
|
|
139
|
+
meta: _eslintPlugin.default.meta,
|
|
140
|
+
rules: _eslintPlugin.default.rules
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
},
|
|
143
|
+
rules: jiraRules
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
processors: {
|
|
147
|
+
'package-json-processor': {
|
|
148
|
+
preprocess: function preprocess(source) {
|
|
149
|
+
// augment the json into a js file
|
|
150
|
+
return [jsonPrefix + source.trim()];
|
|
151
|
+
},
|
|
152
|
+
postprocess: function postprocess(messages) {
|
|
153
|
+
return messages[0].map(function (message) {
|
|
154
|
+
var fix = message.fix;
|
|
155
|
+
if (!fix) {
|
|
156
|
+
return message;
|
|
157
|
+
}
|
|
158
|
+
var offset = jsonPrefix.length;
|
|
159
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
160
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
161
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
162
|
+
})
|
|
163
|
+
});
|
|
148
164
|
});
|
|
149
|
-
}
|
|
165
|
+
},
|
|
166
|
+
supportsAutofix: true
|
|
150
167
|
},
|
|
151
|
-
|
|
168
|
+
// This processor is used for ESLint FlatConfig,
|
|
169
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
170
|
+
'package-json-processor-for-flat-config': {
|
|
171
|
+
preprocess: function preprocess(source) {
|
|
172
|
+
// augment the json into a js file
|
|
173
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
174
|
+
},
|
|
175
|
+
postprocess: function postprocess(messages) {
|
|
176
|
+
return messages[0].map(function (message) {
|
|
177
|
+
var fix = message.fix;
|
|
178
|
+
if (!fix) {
|
|
179
|
+
return message;
|
|
180
|
+
}
|
|
181
|
+
var offset = jsonPrefixForFlatConfig.length;
|
|
182
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
183
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
184
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
supportsAutofix: true
|
|
190
|
+
}
|
|
152
191
|
}
|
|
153
|
-
};
|
|
192
|
+
};
|
|
193
|
+
var configs = exports.configs = plugin.configs;
|
|
194
|
+
var processors = exports.processors = plugin.processors;
|
|
195
|
+
var _default = exports.default = plugin;
|
|
@@ -32,7 +32,7 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
|
|
|
32
32
|
if (cookedQuasi) {
|
|
33
33
|
var splitQuasis = cookedQuasi.split(' ');
|
|
34
34
|
splitQuasis.forEach(function (str) {
|
|
35
|
-
str = str.trim().replace("
|
|
35
|
+
str = str.trim().replace("'", '');
|
|
36
36
|
if (str.length > 0) {
|
|
37
37
|
propertyValues.push(isNaN(Number(str)) ? "'".concat(str, "'") : str);
|
|
38
38
|
}
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
|
|
2
|
+
import compiledPlugin from '@compiled/eslint-plugin';
|
|
3
3
|
import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registration';
|
|
4
4
|
import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
5
5
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
@@ -26,7 +26,8 @@ import useEntrypointsInExamples from './rules/use-entrypoints-in-examples';
|
|
|
26
26
|
import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
|
|
27
27
|
import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
|
|
28
28
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
29
|
-
|
|
29
|
+
const packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
|
|
30
|
+
const rules = {
|
|
30
31
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
31
32
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
32
33
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
@@ -71,86 +72,127 @@ const commonConfig = {
|
|
|
71
72
|
runtime: 'classic'
|
|
72
73
|
}]
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
|
|
90
|
-
allowedPrefixes: ['platform.', 'platform_']
|
|
91
|
-
}]
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
jira: {
|
|
95
|
-
plugins: ['@atlaskit/platform', '@compiled'],
|
|
96
|
-
rules: {
|
|
97
|
-
...commonConfig
|
|
98
|
-
}
|
|
99
|
-
}
|
|
75
|
+
const recommendedRules = {
|
|
76
|
+
...commonConfig,
|
|
77
|
+
// See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
|
|
78
|
+
// These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
|
|
79
|
+
'@atlaskit/platform/no-module-level-eval': 'error',
|
|
80
|
+
'@atlaskit/platform/static-feature-flags': 'error',
|
|
81
|
+
'@atlaskit/platform/no-preconditioning': 'error',
|
|
82
|
+
'@atlaskit/platform/inline-usage': 'error',
|
|
83
|
+
'@atlaskit/platform/prefer-fg': 'error',
|
|
84
|
+
'@atlaskit/platform/no-alias': 'error',
|
|
85
|
+
// end: feature-gating rules
|
|
86
|
+
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
87
|
+
'@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
|
|
88
|
+
allowedPrefixes: ['platform.', 'platform_']
|
|
89
|
+
}]
|
|
100
90
|
};
|
|
91
|
+
const jiraRules = commonConfig;
|
|
101
92
|
const jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
102
93
|
const jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
const {
|
|
95
|
+
name,
|
|
96
|
+
version
|
|
97
|
+
} = packageJson;
|
|
98
|
+
const plugin = {
|
|
99
|
+
meta: {
|
|
100
|
+
name,
|
|
101
|
+
version
|
|
102
|
+
},
|
|
103
|
+
rules,
|
|
104
|
+
configs: {
|
|
105
|
+
recommended: {
|
|
106
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
107
|
+
rules: recommendedRules
|
|
108
108
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
'recommended/flat': {
|
|
110
|
+
plugins: {
|
|
111
|
+
get '@atlaskit/platform'() {
|
|
112
|
+
return plugin;
|
|
113
|
+
},
|
|
114
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
115
|
+
'@compiled': {
|
|
116
|
+
meta: compiledPlugin.meta,
|
|
117
|
+
rules: compiledPlugin.rules
|
|
116
118
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
...message,
|
|
120
|
-
fix: {
|
|
121
|
-
...fix,
|
|
122
|
-
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
});
|
|
119
|
+
},
|
|
120
|
+
rules: recommendedRules
|
|
126
121
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// once we roll out FlatConfig, we can remove the above processor
|
|
131
|
-
'package-json-processor-for-flat-config': {
|
|
132
|
-
preprocess: source => {
|
|
133
|
-
// augment the json into a js file
|
|
134
|
-
return [jsonPrefixForFlatConfig + source.trim()];
|
|
122
|
+
jira: {
|
|
123
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
124
|
+
rules: jiraRules
|
|
135
125
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
126
|
+
'jira/flat': {
|
|
127
|
+
plugins: {
|
|
128
|
+
get '@atlaskit/platform'() {
|
|
129
|
+
return plugin;
|
|
130
|
+
},
|
|
131
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
132
|
+
'@compiled': {
|
|
133
|
+
meta: compiledPlugin.meta,
|
|
134
|
+
rules: compiledPlugin.rules
|
|
143
135
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
136
|
+
},
|
|
137
|
+
rules: jiraRules
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
processors: {
|
|
141
|
+
'package-json-processor': {
|
|
142
|
+
preprocess: source => {
|
|
143
|
+
// augment the json into a js file
|
|
144
|
+
return [jsonPrefix + source.trim()];
|
|
145
|
+
},
|
|
146
|
+
postprocess: messages => {
|
|
147
|
+
return messages[0].map(message => {
|
|
148
|
+
const {
|
|
149
|
+
fix
|
|
150
|
+
} = message;
|
|
151
|
+
if (!fix) {
|
|
152
|
+
return message;
|
|
150
153
|
}
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
const offset = jsonPrefix.length;
|
|
155
|
+
return {
|
|
156
|
+
...message,
|
|
157
|
+
fix: {
|
|
158
|
+
...fix,
|
|
159
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
supportsAutofix: true
|
|
153
165
|
},
|
|
154
|
-
|
|
166
|
+
// This processor is used for ESLint FlatConfig,
|
|
167
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
168
|
+
'package-json-processor-for-flat-config': {
|
|
169
|
+
preprocess: source => {
|
|
170
|
+
// augment the json into a js file
|
|
171
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
172
|
+
},
|
|
173
|
+
postprocess: messages => {
|
|
174
|
+
return messages[0].map(message => {
|
|
175
|
+
const {
|
|
176
|
+
fix
|
|
177
|
+
} = message;
|
|
178
|
+
if (!fix) {
|
|
179
|
+
return message;
|
|
180
|
+
}
|
|
181
|
+
const offset = jsonPrefixForFlatConfig.length;
|
|
182
|
+
return {
|
|
183
|
+
...message,
|
|
184
|
+
fix: {
|
|
185
|
+
...fix,
|
|
186
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
supportsAutofix: true
|
|
192
|
+
}
|
|
155
193
|
}
|
|
156
|
-
};
|
|
194
|
+
};
|
|
195
|
+
const configs = plugin.configs;
|
|
196
|
+
const processors = plugin.processors;
|
|
197
|
+
export { configs, plugin, processors, rules };
|
|
198
|
+
export default plugin;
|
|
@@ -21,7 +21,7 @@ const parseTemplateLiteral = (templateLiteral, context) => {
|
|
|
21
21
|
if (cookedQuasi) {
|
|
22
22
|
const splitQuasis = cookedQuasi.split(' ');
|
|
23
23
|
splitQuasis.forEach(str => {
|
|
24
|
-
str = str.trim().replace("
|
|
24
|
+
str = str.trim().replace("'", '');
|
|
25
25
|
if (str.length > 0) {
|
|
26
26
|
propertyValues.push(isNaN(Number(str)) ? `'${str}'` : str);
|
|
27
27
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
-
|
|
5
|
+
import compiledPlugin from '@compiled/eslint-plugin';
|
|
6
6
|
import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registration';
|
|
7
7
|
import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
8
8
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
@@ -29,7 +29,8 @@ import useEntrypointsInExamples from './rules/use-entrypoints-in-examples';
|
|
|
29
29
|
import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
|
|
30
30
|
import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
|
|
31
31
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
32
|
-
|
|
32
|
+
var packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
|
|
33
|
+
var rules = {
|
|
33
34
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
34
35
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
35
36
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
@@ -74,75 +75,116 @@ var commonConfig = {
|
|
|
74
75
|
runtime: 'classic'
|
|
75
76
|
}]
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}]
|
|
94
|
-
})
|
|
95
|
-
},
|
|
96
|
-
jira: {
|
|
97
|
-
plugins: ['@atlaskit/platform', '@compiled'],
|
|
98
|
-
rules: _objectSpread({}, commonConfig)
|
|
99
|
-
}
|
|
100
|
-
};
|
|
78
|
+
var recommendedRules = _objectSpread(_objectSpread({}, commonConfig), {}, {
|
|
79
|
+
// See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
|
|
80
|
+
// These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
|
|
81
|
+
'@atlaskit/platform/no-module-level-eval': 'error',
|
|
82
|
+
'@atlaskit/platform/static-feature-flags': 'error',
|
|
83
|
+
'@atlaskit/platform/no-preconditioning': 'error',
|
|
84
|
+
'@atlaskit/platform/inline-usage': 'error',
|
|
85
|
+
'@atlaskit/platform/prefer-fg': 'error',
|
|
86
|
+
'@atlaskit/platform/no-alias': 'error',
|
|
87
|
+
// end: feature-gating rules
|
|
88
|
+
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
89
|
+
'@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
|
|
90
|
+
allowedPrefixes: ['platform.', 'platform_']
|
|
91
|
+
}]
|
|
92
|
+
});
|
|
93
|
+
var jiraRules = commonConfig;
|
|
101
94
|
var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
102
95
|
var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
var name = packageJson.name,
|
|
97
|
+
version = packageJson.version;
|
|
98
|
+
var plugin = {
|
|
99
|
+
meta: {
|
|
100
|
+
name: name,
|
|
101
|
+
version: version
|
|
102
|
+
},
|
|
103
|
+
rules: rules,
|
|
104
|
+
configs: {
|
|
105
|
+
recommended: {
|
|
106
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
107
|
+
rules: recommendedRules
|
|
108
108
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
'recommended/flat': {
|
|
110
|
+
plugins: {
|
|
111
|
+
get '@atlaskit/platform'() {
|
|
112
|
+
return plugin;
|
|
113
|
+
},
|
|
114
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
115
|
+
'@compiled': {
|
|
116
|
+
meta: compiledPlugin.meta,
|
|
117
|
+
rules: compiledPlugin.rules
|
|
114
118
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
118
|
-
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
});
|
|
119
|
+
},
|
|
120
|
+
rules: recommendedRules
|
|
122
121
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// once we roll out FlatConfig, we can remove the above processor
|
|
127
|
-
'package-json-processor-for-flat-config': {
|
|
128
|
-
preprocess: function preprocess(source) {
|
|
129
|
-
// augment the json into a js file
|
|
130
|
-
return [jsonPrefixForFlatConfig + source.trim()];
|
|
122
|
+
jira: {
|
|
123
|
+
plugins: ['@atlaskit/platform', '@compiled'],
|
|
124
|
+
rules: jiraRules
|
|
131
125
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
'jira/flat': {
|
|
127
|
+
plugins: {
|
|
128
|
+
get '@atlaskit/platform'() {
|
|
129
|
+
return plugin;
|
|
130
|
+
},
|
|
131
|
+
// @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
|
|
132
|
+
'@compiled': {
|
|
133
|
+
meta: compiledPlugin.meta,
|
|
134
|
+
rules: compiledPlugin.rules
|
|
137
135
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
},
|
|
137
|
+
rules: jiraRules
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
processors: {
|
|
141
|
+
'package-json-processor': {
|
|
142
|
+
preprocess: function preprocess(source) {
|
|
143
|
+
// augment the json into a js file
|
|
144
|
+
return [jsonPrefix + source.trim()];
|
|
145
|
+
},
|
|
146
|
+
postprocess: function postprocess(messages) {
|
|
147
|
+
return messages[0].map(function (message) {
|
|
148
|
+
var fix = message.fix;
|
|
149
|
+
if (!fix) {
|
|
150
|
+
return message;
|
|
151
|
+
}
|
|
152
|
+
var offset = jsonPrefix.length;
|
|
153
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
154
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
155
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
156
|
+
})
|
|
157
|
+
});
|
|
143
158
|
});
|
|
144
|
-
}
|
|
159
|
+
},
|
|
160
|
+
supportsAutofix: true
|
|
145
161
|
},
|
|
146
|
-
|
|
162
|
+
// This processor is used for ESLint FlatConfig,
|
|
163
|
+
// once we roll out FlatConfig, we can remove the above processor
|
|
164
|
+
'package-json-processor-for-flat-config': {
|
|
165
|
+
preprocess: function preprocess(source) {
|
|
166
|
+
// augment the json into a js file
|
|
167
|
+
return [jsonPrefixForFlatConfig + source.trim()];
|
|
168
|
+
},
|
|
169
|
+
postprocess: function postprocess(messages) {
|
|
170
|
+
return messages[0].map(function (message) {
|
|
171
|
+
var fix = message.fix;
|
|
172
|
+
if (!fix) {
|
|
173
|
+
return message;
|
|
174
|
+
}
|
|
175
|
+
var offset = jsonPrefixForFlatConfig.length;
|
|
176
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
177
|
+
fix: _objectSpread(_objectSpread({}, fix), {}, {
|
|
178
|
+
range: [fix.range[0] - offset, fix.range[1] - offset]
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
supportsAutofix: true
|
|
184
|
+
}
|
|
147
185
|
}
|
|
148
|
-
};
|
|
186
|
+
};
|
|
187
|
+
var configs = plugin.configs;
|
|
188
|
+
var processors = plugin.processors;
|
|
189
|
+
export { configs, plugin, processors, rules };
|
|
190
|
+
export default plugin;
|
|
@@ -25,7 +25,7 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
|
|
|
25
25
|
if (cookedQuasi) {
|
|
26
26
|
var splitQuasis = cookedQuasi.split(' ');
|
|
27
27
|
splitQuasis.forEach(function (str) {
|
|
28
|
-
str = str.trim().replace("
|
|
28
|
+
str = str.trim().replace("'", '');
|
|
29
29
|
if (str.length > 0) {
|
|
30
30
|
propertyValues.push(isNaN(Number(str)) ? "'".concat(str, "'") : str);
|
|
31
31
|
}
|