@atlaskit/eslint-plugin-platform 2.1.2 → 2.2.1

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,5 +1,22 @@
1
1
  # @atlaskit/eslint-plugin-platform
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#103444](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103444)
8
+ [`5d5006fe81146`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d5006fe81146) -
9
+ AFB-822 Refactor ESLint rule and added an extra case for when ESLint rule should throw error but
10
+ not provide a fix
11
+
12
+ ## 2.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#103661](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103661)
17
+ [`976a915b13fc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/976a915b13fc2) -
18
+ add flat config support
19
+
3
20
  ## 2.1.2
4
21
 
5
22
  ### 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 configs = exports.configs = {
83
- recommended: {
84
- plugins: ['@atlaskit/platform', '@compiled'],
85
- rules: _objectSpread(_objectSpread({}, commonConfig), {}, {
86
- // See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
87
- // These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
88
- '@atlaskit/platform/no-module-level-eval': 'error',
89
- '@atlaskit/platform/static-feature-flags': 'error',
90
- '@atlaskit/platform/no-preconditioning': 'error',
91
- '@atlaskit/platform/inline-usage': 'error',
92
- '@atlaskit/platform/prefer-fg': 'error',
93
- '@atlaskit/platform/no-alias': 'error',
94
- // end: feature-gating rules
95
- '@atlaskit/platform/ensure-feature-flag-registration': 'error',
96
- '@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
97
- allowedPrefixes: ['platform.', 'platform_']
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 processors = exports.processors = {
109
- 'package-json-processor': {
110
- preprocess: function preprocess(source) {
111
- // augment the json into a js file
112
- return [jsonPrefix + source.trim()];
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
- postprocess: function postprocess(messages) {
115
- return messages[0].map(function (message) {
116
- var fix = message.fix;
117
- if (!fix) {
118
- return message;
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
- var offset = jsonPrefix.length;
121
- return _objectSpread(_objectSpread({}, message), {}, {
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
- supportsAutofix: true
129
- },
130
- // This processor is used for ESLint FlatConfig,
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
- postprocess: function postprocess(messages) {
138
- return messages[0].map(function (message) {
139
- var fix = message.fix;
140
- if (!fix) {
141
- return message;
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
- var offset = jsonPrefixForFlatConfig.length;
144
- return _objectSpread(_objectSpread({}, message), {}, {
145
- fix: _objectSpread(_objectSpread({}, fix), {}, {
146
- range: [fix.range[0] - offset, fix.range[1] - offset]
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
- supportsAutofix: true
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
  }
@@ -46,31 +46,74 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
46
46
  }
47
47
  return propertyValues;
48
48
  };
49
- var checkValidPropertyValues = function checkValidPropertyValues(propertyValues) {
49
+
50
+ /**
51
+ * Checks if the parsed property values are valid (i.e. no rule violation will be thrown). Cases are, the property values:
52
+ * 1. Do not contain a token
53
+ * 2. Have length that are not in the range [1, 4]
54
+ * 3. Includes `calc(...)`
55
+ * Then, the rule will return with no error
56
+ * @param propertyValues property values parsed as list of strings
57
+ * @returns boolean
58
+ */
59
+ var isPropertyValueExempted = function isPropertyValueExempted(propertyValues) {
50
60
  if (!propertyValues.some(function (str) {
51
61
  return str.includes('token(');
52
62
  })) {
53
- return false;
63
+ return true;
54
64
  }
55
65
  if (propertyValues.length < 1 || propertyValues.length > 4) {
56
- return false;
66
+ return true;
57
67
  }
58
68
  if (propertyValues.some(function (str) {
59
69
  return str.includes('calc(');
60
70
  })) {
61
- return false;
71
+ return true;
62
72
  }
63
- return true;
73
+ return false;
64
74
  };
65
75
 
66
- // Check that all expressions in TemplateLiteral are token expressions
67
- // If true: create an autofix
68
- // If false: report violation without autofix
69
- var hasOnlyTokens = function hasOnlyTokens(templateLiteral) {
76
+ /**
77
+ * Checks if the parsed property values are invalid (i.e. rule violation thrown) and autofix required. Cases are when:
78
+ * 1. All expressions in TemplateLiteral are token expressions
79
+ * 2. Property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
80
+ * The rule will return with error and provide a fix
81
+ * @param templateLiteral TemplateLiteral AST Node
82
+ * @param propertyValues property values parsed as list of strings
83
+ * @returns boolean
84
+ */
85
+ var isPropertyValuesInvalidFix = function isPropertyValuesInvalidFix(templateLiteral, propertyValues) {
70
86
  var expressions = templateLiteral.expressions;
71
- return expressions.every(function (expr) {
87
+ if (!expressions.every(function (expr) {
72
88
  return expr.type === 'CallExpression' && isTokenCallExpression(expr);
73
- });
89
+ })) {
90
+ return false;
91
+ }
92
+ var _iterator = _createForOfIteratorHelper(propertyValues),
93
+ _step;
94
+ try {
95
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
96
+ var propValue = _step.value;
97
+ if (propValue === '0') {
98
+ continue;
99
+ }
100
+ if (['auto', 'initial', 'inherit'].includes(propValue.slice(1, -1))) {
101
+ continue;
102
+ }
103
+ if (/^token\(.*\)$/.test(propValue)) {
104
+ continue;
105
+ }
106
+ if (/^['"]\d+(\.\d+)?((rem)|(em)|(px))['"]$/.test(propValue)) {
107
+ continue;
108
+ }
109
+ return false;
110
+ }
111
+ } catch (err) {
112
+ _iterator.e(err);
113
+ } finally {
114
+ _iterator.f();
115
+ }
116
+ return true;
74
117
  };
75
118
 
76
119
  // To fix spacing shorthands, given a list of spacing property values, expands the spacing property and adds autofix fixes
@@ -92,11 +135,11 @@ var expandSpacingProperties = function expandSpacingProperties(_ref) {
92
135
  var fixes = [];
93
136
  var parentNode = node.parent;
94
137
  if (parentNode && parentNode.type === 'ObjectExpression') {
95
- var _iterator = _createForOfIteratorHelper(parentNode.properties),
96
- _step;
138
+ var _iterator2 = _createForOfIteratorHelper(parentNode.properties),
139
+ _step2;
97
140
  try {
98
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
- var prop = _step.value;
141
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
142
+ var prop = _step2.value;
100
143
  if (prop.type !== 'Property') {
101
144
  continue;
102
145
  }
@@ -121,9 +164,9 @@ var expandSpacingProperties = function expandSpacingProperties(_ref) {
121
164
  }
122
165
  }
123
166
  } catch (err) {
124
- _iterator.e(err);
167
+ _iterator2.e(err);
125
168
  } finally {
126
- _iterator.f();
169
+ _iterator2.f();
127
170
  }
128
171
  }
129
172
  fixes.push(fixer.insertTextAfter(node, "".concat(propertyShorthand, "Top: ").concat(spacing[0], ",\n")));
@@ -138,8 +181,30 @@ var executeExpandSpacingRule = function executeExpandSpacingRule(context, node,
138
181
  return;
139
182
  }
140
183
  if (node.value.type === 'TemplateLiteral') {
141
- // Value of spacing property is a TemplateLiteral type that contains a token, e.g. padding: `0 token('a')`
142
- if (!hasOnlyTokens(node.value)) {
184
+ var propertyValues = parseTemplateLiteral(node.value, context);
185
+ if (isPropertyValueExempted(propertyValues)) {
186
+ // Valid, so no error should be thrown
187
+ return;
188
+ }
189
+ if (isPropertyValuesInvalidFix(node.value, propertyValues)) {
190
+ // Invalid, so error should be thrown and fix provided
191
+ context.report({
192
+ node: node,
193
+ messageId: 'expandSpacingShorthand',
194
+ data: {
195
+ property: propertyShorthand
196
+ },
197
+ fix: function fix(fixer) {
198
+ return expandSpacingProperties({
199
+ context: context,
200
+ node: node,
201
+ propertyValues: propertyValues,
202
+ fixer: fixer,
203
+ propertyShorthand: propertyShorthand
204
+ });
205
+ }
206
+ });
207
+ } else {
143
208
  context.report({
144
209
  node: node,
145
210
  messageId: 'expandSpacingShorthand',
@@ -149,26 +214,6 @@ var executeExpandSpacingRule = function executeExpandSpacingRule(context, node,
149
214
  });
150
215
  return;
151
216
  }
152
- var propertyValues = parseTemplateLiteral(node.value, context);
153
- if (!checkValidPropertyValues(propertyValues)) {
154
- return;
155
- }
156
- context.report({
157
- node: node,
158
- messageId: 'expandSpacingShorthand',
159
- data: {
160
- property: propertyShorthand
161
- },
162
- fix: function fix(fixer) {
163
- return expandSpacingProperties({
164
- context: context,
165
- node: node,
166
- propertyValues: propertyValues,
167
- fixer: fixer,
168
- propertyShorthand: propertyShorthand
169
- });
170
- }
171
- });
172
217
  } else if (node.value.type === 'CallExpression' && isTokenCallExpression(node.value)) {
173
218
  // Value of spacing property is a token CallExpression type, e.g. margin: token('space.100', '8px')
174
219
  var _propertyValues2 = [(0, _contextCompat.getSourceCode)(context).getText(node.value)];
@@ -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
- export const rules = {
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
- export const configs = {
75
- recommended: {
76
- plugins: ['@atlaskit/platform', '@compiled'],
77
- rules: {
78
- ...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
- },
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
- export const processors = {
104
- 'package-json-processor': {
105
- preprocess: source => {
106
- // augment the json into a js file
107
- return [jsonPrefix + source.trim()];
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
- postprocess: messages => {
110
- return messages[0].map(message => {
111
- const {
112
- fix
113
- } = message;
114
- if (!fix) {
115
- return message;
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
- const offset = jsonPrefix.length;
118
- return {
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
- supportsAutofix: true
128
- },
129
- // This processor is used for ESLint FlatConfig,
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
- postprocess: messages => {
137
- return messages[0].map(message => {
138
- const {
139
- fix
140
- } = message;
141
- if (!fix) {
142
- return message;
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
- const offset = jsonPrefixForFlatConfig.length;
145
- return {
146
- ...message,
147
- fix: {
148
- ...fix,
149
- range: [fix.range[0] - offset, fix.range[1] - offset]
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
- supportsAutofix: true
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;