@atlaskit/eslint-plugin-platform 2.9.1 → 2.9.3

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/index.js +15 -3
  3. package/dist/cjs/rules/compiled/expand-motion-shorthand/index.js +281 -0
  4. package/dist/cjs/rules/compiled/no-css-prop-in-object-spread/index.js +162 -0
  5. package/dist/cjs/rules/compiled/use-motion-token-values/index.js +506 -0
  6. package/dist/cjs/rules/editor-example-type-import-required/index.js +321 -0
  7. package/dist/cjs/rules/no-xcss-in-cx/index.js +221 -0
  8. package/dist/cjs/rules/visit-example-type-import-required/index.js +23 -13
  9. package/dist/es2019/index.js +15 -3
  10. package/dist/es2019/rules/compiled/expand-motion-shorthand/index.js +239 -0
  11. package/dist/es2019/rules/compiled/no-css-prop-in-object-spread/index.js +136 -0
  12. package/dist/es2019/rules/compiled/use-motion-token-values/index.js +444 -0
  13. package/dist/es2019/rules/editor-example-type-import-required/index.js +286 -0
  14. package/dist/es2019/rules/no-xcss-in-cx/index.js +187 -0
  15. package/dist/es2019/rules/visit-example-type-import-required/index.js +23 -14
  16. package/dist/esm/index.js +15 -3
  17. package/dist/esm/rules/compiled/expand-motion-shorthand/index.js +275 -0
  18. package/dist/esm/rules/compiled/no-css-prop-in-object-spread/index.js +156 -0
  19. package/dist/esm/rules/compiled/use-motion-token-values/index.js +499 -0
  20. package/dist/esm/rules/editor-example-type-import-required/index.js +314 -0
  21. package/dist/esm/rules/no-xcss-in-cx/index.js +216 -0
  22. package/dist/esm/rules/visit-example-type-import-required/index.js +23 -13
  23. package/dist/types/index.d.ts +282 -243
  24. package/dist/types/rules/compiled/expand-motion-shorthand/index.d.ts +3 -0
  25. package/dist/types/rules/compiled/no-css-prop-in-object-spread/index.d.ts +3 -0
  26. package/dist/types/rules/compiled/use-motion-token-values/index.d.ts +3 -0
  27. package/dist/types/rules/editor-example-type-import-required/index.d.ts +4 -0
  28. package/dist/types/rules/no-xcss-in-cx/index.d.ts +31 -0
  29. package/dist/types-ts4.5/index.d.ts +226 -211
  30. package/dist/types-ts4.5/rules/compiled/expand-motion-shorthand/index.d.ts +3 -0
  31. package/dist/types-ts4.5/rules/compiled/no-css-prop-in-object-spread/index.d.ts +3 -0
  32. package/dist/types-ts4.5/rules/compiled/use-motion-token-values/index.d.ts +3 -0
  33. package/dist/types-ts4.5/rules/editor-example-type-import-required/index.d.ts +4 -0
  34. package/dist/types-ts4.5/rules/no-xcss-in-cx/index.d.ts +31 -0
  35. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/eslint-plugin-platform
2
2
 
3
+ ## 2.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a1196120ab924`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a1196120ab924) -
8
+ Add `use-motion-token-values` and `expand-motion-shorthand` lint rules to enforce motion token
9
+ usage.
10
+
11
+ ## 2.9.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`48fa19b8ba41a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48fa19b8ba41a) -
16
+ Add `no-xcss-in-cx` ESLint rule to prevent `xcss()` from `@atlaskit/primitives` being called
17
+ inline inside `cx()` in an `xcss` prop. Calling `xcss()` inline produces a StyleRule opaque object
18
+ rather than a Compiled atomic class string, which causes runtime errors. The rule is import-aware
19
+ and recurses into logical (`&&`) and conditional (`?:`) expressions.
20
+
3
21
  ## 2.9.1
4
22
 
5
23
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -32,6 +32,9 @@ var _useRecommendedUtils = _interopRequireDefault(require("./rules/feature-gatin
32
32
  var _validGateName = _interopRequireDefault(require("./rules/feature-gating/valid-gate-name"));
33
33
  var _expandBackgroundShorthand = _interopRequireDefault(require("./rules/compiled/expand-background-shorthand"));
34
34
  var _expandSpacingShorthand = _interopRequireDefault(require("./rules/compiled/expand-spacing-shorthand"));
35
+ var _noCssPropInObjectSpread = _interopRequireDefault(require("./rules/compiled/no-css-prop-in-object-spread"));
36
+ var _useMotionTokenValues = _interopRequireDefault(require("./rules/compiled/use-motion-token-values"));
37
+ var _expandMotionShorthand = _interopRequireDefault(require("./rules/compiled/expand-motion-shorthand"));
35
38
  var _noSparseCheckout = _interopRequireDefault(require("./rules/no-sparse-checkout"));
36
39
  var _noDirectDocumentUsage = _interopRequireDefault(require("./rules/no-direct-document-usage"));
37
40
  var _noSetImmediate = _interopRequireDefault(require("./rules/no-set-immediate"));
@@ -43,7 +46,9 @@ var _noJestMockBarrelFiles = _interopRequireDefault(require("./rules/import/no-j
43
46
  var _noRelativeBarrelFileImports = _interopRequireDefault(require("./rules/import/no-relative-barrel-file-imports"));
44
47
  var _noConversationAssistantBarrelImports = _interopRequireDefault(require("./rules/import/no-conversation-assistant-barrel-imports"));
45
48
  var _visitExampleTypeImportRequired = _interopRequireDefault(require("./rules/visit-example-type-import-required"));
49
+ var _editorExampleTypeImportRequired = _interopRequireDefault(require("./rules/editor-example-type-import-required"));
46
50
  var _ensureUseSyncExternalStoreServerSnapshot = _interopRequireDefault(require("./rules/ensure-use-sync-external-store-server-snapshot"));
51
+ var _noXcssInCx = _interopRequireDefault(require("./rules/no-xcss-in-cx"));
47
52
  var _nodePath = require("node:path");
48
53
  var _nodeFs = require("node:fs");
49
54
  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; }
@@ -76,6 +81,7 @@ var rules = exports.rules = {
76
81
  'expand-border-shorthand': _expandBorderShorthand.default,
77
82
  'expand-background-shorthand': _expandBackgroundShorthand.default,
78
83
  'expand-spacing-shorthand': _expandSpacingShorthand.default,
84
+ 'no-css-prop-in-object-spread': _noCssPropInObjectSpread.default,
79
85
  'no-duplicate-dependencies': _noDuplicateDependencies.default,
80
86
  'no-invalid-feature-flag-usage': _noInvalidFeatureFlagUsage.default,
81
87
  'no-pre-post-install-scripts': _noPrePostInstalls.default,
@@ -102,7 +108,11 @@ var rules = exports.rules = {
102
108
  'no-relative-barrel-file-imports': _noRelativeBarrelFileImports.default,
103
109
  'no-conversation-assistant-barrel-imports': _noConversationAssistantBarrelImports.default,
104
110
  'visit-example-type-import-required': _visitExampleTypeImportRequired.default,
105
- 'ensure-use-sync-external-store-server-snapshot': _ensureUseSyncExternalStoreServerSnapshot.default
111
+ 'no-xcss-in-cx': _noXcssInCx.default,
112
+ 'editor-example-type-import-required': _editorExampleTypeImportRequired.default,
113
+ 'ensure-use-sync-external-store-server-snapshot': _ensureUseSyncExternalStoreServerSnapshot.default,
114
+ 'use-motion-token-values': _useMotionTokenValues.default,
115
+ 'expand-motion-shorthand': _expandMotionShorthand.default
106
116
  };
107
117
  var commonConfig = {
108
118
  '@atlaskit/platform/ensure-test-runner-arguments': 'error',
@@ -114,10 +124,14 @@ var commonConfig = {
114
124
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
115
125
  '@atlaskit/platform/no-direct-document-usage': 'warn',
116
126
  '@atlaskit/platform/no-set-immediate': 'error',
127
+ '@atlaskit/platform/no-xcss-in-cx': 'error',
117
128
  // Compiled: rules that are not included via `@compiled/recommended
118
129
  '@atlaskit/platform/expand-border-shorthand': 'error',
119
130
  '@atlaskit/platform/expand-background-shorthand': 'error',
120
131
  '@atlaskit/platform/expand-spacing-shorthand': 'error',
132
+ '@atlaskit/platform/no-css-prop-in-object-spread': 'error',
133
+ '@atlaskit/platform/use-motion-token-values': 'warn',
134
+ '@atlaskit/platform/expand-motion-shorthand': 'warn',
121
135
  '@compiled/jsx-pragma': ['error', {
122
136
  importSources: ['@atlaskit/css'],
123
137
  onlyRunIfImportingCompiled: true,
@@ -159,7 +173,6 @@ var plugin = exports.plugin = {
159
173
  get '@atlaskit/platform'() {
160
174
  return plugin;
161
175
  },
162
- // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
163
176
  '@compiled': {
164
177
  meta: _eslintPlugin.default.meta,
165
178
  rules: _eslintPlugin.default.rules
@@ -176,7 +189,6 @@ var plugin = exports.plugin = {
176
189
  get '@atlaskit/platform'() {
177
190
  return plugin;
178
191
  },
179
- // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
180
192
  '@compiled': {
181
193
  meta: _eslintPlugin.default.meta,
182
194
  rules: _eslintPlugin.default.rules
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.expandTransitionShorthand = exports.default = void 0;
7
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
8
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
9
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10
+ var EASING_KEYWORDS = ['ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];
11
+ var KEYWORD_VALUES = ['none', 'all', 'inherit', 'initial', 'unset'];
12
+ var isDuration = function isDuration(token) {
13
+ return /^\d+(?:\.\d+)?m?s$/.test(token);
14
+ };
15
+ var isEasing = function isEasing(token) {
16
+ return EASING_KEYWORDS.includes(token) || token.startsWith('cubic-bezier(') || token.startsWith('steps(');
17
+ };
18
+ /**
19
+ * Tokenizes a CSS shorthand value string, respecting function boundaries.
20
+ * e.g. 'opacity 200ms cubic-bezier(0.4, 0, 0, 1) 0ms' →
21
+ * ['opacity', '200ms', 'cubic-bezier(0.4, 0, 0, 1)', '0ms']
22
+ * Splits on whitespace only when not inside parentheses.
23
+ */
24
+ var tokenizeShorthand = function tokenizeShorthand(value) {
25
+ var tokens = [];
26
+ var depth = 0;
27
+ var current = '';
28
+ for (var i = 0; i < value.length; i++) {
29
+ var ch = value[i];
30
+ if (ch === '(') {
31
+ depth++;
32
+ current += ch;
33
+ } else if (ch === ')') {
34
+ depth--;
35
+ current += ch;
36
+ } else if (/\s/.test(ch) && depth === 0) {
37
+ if (current.length > 0) {
38
+ tokens.push(current);
39
+ current = '';
40
+ }
41
+ } else {
42
+ current += ch;
43
+ }
44
+ }
45
+ if (current.length > 0) {
46
+ tokens.push(current);
47
+ }
48
+ return tokens;
49
+ };
50
+
51
+ // Splits on top-level commas (outside function parens) — preserves cubic-bezier(...) commas.
52
+ var splitOnTopLevelCommas = function splitOnTopLevelCommas(value) {
53
+ var parts = [];
54
+ var depth = 0;
55
+ var current = '';
56
+ var _iterator = _createForOfIteratorHelper(value),
57
+ _step;
58
+ try {
59
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
60
+ var ch = _step.value;
61
+ if (ch === '(') {
62
+ depth++;
63
+ current += ch;
64
+ } else if (ch === ')') {
65
+ depth--;
66
+ current += ch;
67
+ } else if (ch === ',' && depth === 0) {
68
+ parts.push(current.trim());
69
+ current = '';
70
+ } else {
71
+ current += ch;
72
+ }
73
+ }
74
+ } catch (err) {
75
+ _iterator.e(err);
76
+ } finally {
77
+ _iterator.f();
78
+ }
79
+ if (current.trim().length > 0) {
80
+ parts.push(current.trim());
81
+ }
82
+ return parts;
83
+ };
84
+ var parseTransition = function parseTransition(value) {
85
+ var parts = tokenizeShorthand(value.trim());
86
+ var result = {};
87
+ var durationCount = 0;
88
+ var _iterator2 = _createForOfIteratorHelper(parts),
89
+ _step2;
90
+ try {
91
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
92
+ var part = _step2.value;
93
+ if (isDuration(part)) {
94
+ if (durationCount === 0) {
95
+ result.transitionDuration = part;
96
+ } else {
97
+ result.transitionDelay = part;
98
+ }
99
+ durationCount++;
100
+ } else if (isEasing(part)) {
101
+ result.transitionTimingFunction = part;
102
+ } else {
103
+ result.transitionProperty = part;
104
+ }
105
+ }
106
+ } catch (err) {
107
+ _iterator2.e(err);
108
+ } finally {
109
+ _iterator2.f();
110
+ }
111
+ return result;
112
+ };
113
+ var parseAnimation = function parseAnimation(value) {
114
+ var parts = tokenizeShorthand(value.trim());
115
+ var result = {};
116
+ var durationCount = 0;
117
+ var _iterator3 = _createForOfIteratorHelper(parts),
118
+ _step3;
119
+ try {
120
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
121
+ var part = _step3.value;
122
+ if (isDuration(part)) {
123
+ if (durationCount === 0) {
124
+ result.animationDuration = part;
125
+ } else {
126
+ result.animationDelay = part;
127
+ }
128
+ durationCount++;
129
+ } else if (isEasing(part)) {
130
+ result.animationTimingFunction = part;
131
+ } else if (part === 'infinite' || /^\d+(\.\d+)?$/.test(part)) {
132
+ result.animationIterationCount = part;
133
+ } else if (['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(part)) {
134
+ result.animationDirection = part;
135
+ } else if (['none', 'forwards', 'backwards', 'both'].includes(part)) {
136
+ result.animationFillMode = part;
137
+ } else if (['running', 'paused'].includes(part)) {
138
+ result.animationPlayState = part;
139
+ } else {
140
+ result.animationName = part;
141
+ }
142
+ }
143
+ } catch (err) {
144
+ _iterator3.e(err);
145
+ } finally {
146
+ _iterator3.f();
147
+ }
148
+ return result;
149
+ };
150
+
151
+ // Combine sub-property values across comma-separated transitions/animations.
152
+ // If no segment explicitly set this sub-property, omit it entirely.
153
+ // Otherwise, fill missing slots with the CSS spec default to preserve positional alignment.
154
+ var combineSubPropertyValues = function combineSubPropertyValues(segments, subProperty, defaultValue) {
155
+ if (segments.every(function (s) {
156
+ return s[subProperty] === undefined;
157
+ })) {
158
+ return undefined;
159
+ }
160
+ return segments.map(function (s) {
161
+ var _s$subProperty;
162
+ return (_s$subProperty = s[subProperty]) !== null && _s$subProperty !== void 0 ? _s$subProperty : defaultValue;
163
+ }).join(', ');
164
+ };
165
+ var buildTransitionFix = function buildTransitionFix(segments, indent) {
166
+ var lines = [];
167
+ var property = combineSubPropertyValues(segments, 'transitionProperty', 'all');
168
+ var duration = combineSubPropertyValues(segments, 'transitionDuration', '0s');
169
+ var timing = combineSubPropertyValues(segments, 'transitionTimingFunction', 'ease');
170
+ var delay = combineSubPropertyValues(segments, 'transitionDelay', '0s');
171
+ if (property !== undefined) lines.push("transitionProperty: '".concat(property, "'"));
172
+ if (duration !== undefined) lines.push("transitionDuration: '".concat(duration, "'"));
173
+ if (timing !== undefined) lines.push("transitionTimingFunction: '".concat(timing, "'"));
174
+ if (delay !== undefined) lines.push("transitionDelay: '".concat(delay, "'"));
175
+ return lines.join(",\n".concat(indent));
176
+ };
177
+ var buildAnimationFix = function buildAnimationFix(segments, indent) {
178
+ var lines = [];
179
+ var name = combineSubPropertyValues(segments, 'animationName', 'none');
180
+ var duration = combineSubPropertyValues(segments, 'animationDuration', '0s');
181
+ var timing = combineSubPropertyValues(segments, 'animationTimingFunction', 'ease');
182
+ var delay = combineSubPropertyValues(segments, 'animationDelay', '0s');
183
+ var iter = combineSubPropertyValues(segments, 'animationIterationCount', '1');
184
+ var direction = combineSubPropertyValues(segments, 'animationDirection', 'normal');
185
+ var fill = combineSubPropertyValues(segments, 'animationFillMode', 'none');
186
+ var playState = combineSubPropertyValues(segments, 'animationPlayState', 'running');
187
+ if (name !== undefined) lines.push("animationName: '".concat(name, "'"));
188
+ if (duration !== undefined) lines.push("animationDuration: '".concat(duration, "'"));
189
+ if (timing !== undefined) lines.push("animationTimingFunction: '".concat(timing, "'"));
190
+ if (delay !== undefined) lines.push("animationDelay: '".concat(delay, "'"));
191
+ if (iter !== undefined) lines.push("animationIterationCount: '".concat(iter, "'"));
192
+ if (direction !== undefined) lines.push("animationDirection: '".concat(direction, "'"));
193
+ if (fill !== undefined) lines.push("animationFillMode: '".concat(fill, "'"));
194
+ if (playState !== undefined) lines.push("animationPlayState: '".concat(playState, "'"));
195
+ return lines.join(",\n".concat(indent));
196
+ };
197
+ var TRANSITION_SUB_PROPERTIES = ['transitionProperty', 'transitionDuration', 'transitionTimingFunction', 'transitionDelay'];
198
+ var ANIMATION_SUB_PROPERTIES = ['animationName', 'animationDuration', 'animationTimingFunction', 'animationDelay', 'animationIterationCount', 'animationDirection', 'animationFillMode', 'animationPlayState'];
199
+ var executeExpandTransitionRule = function executeExpandTransitionRule(context, node, property) {
200
+ var _context$sourceCode, _node$loc;
201
+ if (node.value.type === 'CallExpression') {
202
+ return;
203
+ }
204
+ if (node.value.type === 'TemplateLiteral') {
205
+ return;
206
+ }
207
+ if (node.value.type !== 'Literal' || typeof node.value.value !== 'string') {
208
+ return;
209
+ }
210
+ var rawValue = node.value.value;
211
+ if (KEYWORD_VALUES.includes(rawValue)) {
212
+ return;
213
+ }
214
+ var subProperties = property === 'transition' ? TRANSITION_SUB_PROPERTIES : ANIMATION_SUB_PROPERTIES;
215
+
216
+ // Extract leading whitespace to preserve indentation style (tabs vs spaces)
217
+ var sourceCode = (_context$sourceCode = context.sourceCode) !== null && _context$sourceCode !== void 0 ? _context$sourceCode : context.getSourceCode();
218
+ var nodeStart = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
219
+ var indent = '\t';
220
+ if (nodeStart) {
221
+ var _sourceCode$lines;
222
+ var lineText = (_sourceCode$lines = sourceCode.lines[nodeStart.line - 1]) !== null && _sourceCode$lines !== void 0 ? _sourceCode$lines : '';
223
+ var leadingWhitespace = lineText.match(/^(\s*)/);
224
+ if (leadingWhitespace) {
225
+ indent = leadingWhitespace[1];
226
+ }
227
+ }
228
+ var segmentStrings = splitOnTopLevelCommas(rawValue);
229
+ if (property === 'transition') {
230
+ var segments = segmentStrings.map(parseTransition);
231
+ var fixText = buildTransitionFix(segments, indent);
232
+ context.report({
233
+ node: node,
234
+ messageId: 'expandTransitionShorthand',
235
+ data: {
236
+ property: property,
237
+ subProperties: subProperties.join(', ')
238
+ },
239
+ fix: function fix(fixer) {
240
+ return fixer.replaceText(node, fixText);
241
+ }
242
+ });
243
+ } else {
244
+ var _segments = segmentStrings.map(parseAnimation);
245
+ var _fixText = buildAnimationFix(_segments, indent);
246
+ context.report({
247
+ node: node,
248
+ messageId: 'expandTransitionShorthand',
249
+ data: {
250
+ property: property,
251
+ subProperties: subProperties.join(', ')
252
+ },
253
+ fix: function fix(fixer) {
254
+ return fixer.replaceText(node, _fixText);
255
+ }
256
+ });
257
+ }
258
+ };
259
+ var expandTransitionShorthand = exports.expandTransitionShorthand = {
260
+ meta: {
261
+ type: 'suggestion',
262
+ fixable: 'code',
263
+ docs: {
264
+ url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/platform/eslint-plugin/src/rules/compiled/expand-transition-shorthand/'
265
+ },
266
+ messages: {
267
+ expandTransitionShorthand: "Use {{ subProperties }} instead of the '{{ property }}' shorthand so that individual values can be replaced with motion tokens."
268
+ }
269
+ },
270
+ create: function create(context) {
271
+ return {
272
+ 'Property[key.name="transition"]': function PropertyKeyNameTransition(node) {
273
+ executeExpandTransitionRule(context, node, 'transition');
274
+ },
275
+ 'Property[key.name="animation"]': function PropertyKeyNameAnimation(node) {
276
+ executeExpandTransitionRule(context, node, 'animation');
277
+ }
278
+ };
279
+ }
280
+ };
281
+ var _default = exports.default = expandTransitionShorthand;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.noCssPropInObjectSpread = exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _contextCompat = require("../../util/context-compat");
10
+ 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; }
11
+ 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; }
12
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
13
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ /**
16
+ * Returns the `css` Property node from an ObjectExpression, or null if not found.
17
+ */
18
+ function getCssProperty(objectExpression) {
19
+ var _iterator = _createForOfIteratorHelper(objectExpression.properties),
20
+ _step;
21
+ try {
22
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
23
+ var prop = _step.value;
24
+ if (prop.type !== 'Property') {
25
+ continue;
26
+ }
27
+ var key = prop.key;
28
+ if (key.type === 'Identifier' && key.name === 'css' || key.type === 'Literal' && key.value === 'css') {
29
+ return prop;
30
+ }
31
+ }
32
+ } catch (err) {
33
+ _iterator.e(err);
34
+ } finally {
35
+ _iterator.f();
36
+ }
37
+ return null;
38
+ }
39
+ var noCssPropInObjectSpread = exports.noCssPropInObjectSpread = {
40
+ meta: {
41
+ docs: {
42
+ url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/platform/eslint-plugin/src/rules/compiled/no-css-prop-in-object-spread/',
43
+ description: 'Disallows `css` property inside objects spread into JSX — the Compiled JSX pragma ignores it'
44
+ },
45
+ fixable: 'code',
46
+ messages: {
47
+ noCssPropInObjectSpread: 'The `css` property inside an object spread into JSX is a no-op. The Compiled JSX pragma only processes `css` as a direct JSX attribute. Move `css` out of the spread: <El css={...} />'
48
+ },
49
+ type: 'problem'
50
+ },
51
+ create: function create(context) {
52
+ return {
53
+ JSXSpreadAttribute: function JSXSpreadAttribute(node) {
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ var spreadNode = node;
56
+ var arg = spreadNode.argument;
57
+
58
+ // Case 1: inline object literal — <div {...{ css: styles, id: 'foo' }} />
59
+ if (arg.type === 'ObjectExpression') {
60
+ var objectArg = arg;
61
+ var cssProp = getCssProperty(objectArg);
62
+ if (!cssProp) {
63
+ return;
64
+ }
65
+ context.report({
66
+ node: node,
67
+ messageId: 'noCssPropInObjectSpread',
68
+ fix: function fix(fixer) {
69
+ var sourceCode = (0, _contextCompat.getSourceCode)(context);
70
+ var cssValueText = sourceCode.getText(cssProp.value);
71
+ var remainingProps = objectArg.properties.filter(function (p) {
72
+ return p !== cssProp;
73
+ });
74
+ var directCssProp = "css={".concat(cssValueText, "}");
75
+ if (remainingProps.length === 0) {
76
+ return fixer.replaceText(node, directCssProp);
77
+ }
78
+ var remainingText = remainingProps.map(function (p) {
79
+ return sourceCode.getText(p);
80
+ }).join(', ');
81
+ return fixer.replaceText(node, "".concat(directCssProp, " {...{ ").concat(remainingText, " }}"));
82
+ }
83
+ });
84
+ return;
85
+ }
86
+
87
+ // Case 2: variable reference — <div {...props} />
88
+ if (arg.type === 'Identifier') {
89
+ var scope = (0, _contextCompat.getScope)(context, arg);
90
+ var currentScope = scope;
91
+ var variable = null;
92
+ while (currentScope) {
93
+ var found = currentScope.variables.find(function (v) {
94
+ return v.name === arg.name;
95
+ });
96
+ if (found) {
97
+ variable = found;
98
+ break;
99
+ }
100
+ currentScope = currentScope.upper;
101
+ }
102
+ if (!variable || variable.defs.length === 0) {
103
+ return;
104
+ }
105
+ var def = variable.defs[0];
106
+ if (def.type !== 'Variable' || !def.node.init || def.node.init.type !== 'ObjectExpression') {
107
+ return;
108
+ }
109
+ var initObject = def.node.init;
110
+ var _cssProp = getCssProperty(initObject);
111
+ if (!_cssProp) {
112
+ return;
113
+ }
114
+
115
+ // Only auto-fix when there is exactly one JSX spread site for this variable
116
+ var spreadCount = variable.references.filter(function (ref) {
117
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
+ var refParent = ref.identifier.parent;
119
+ return (refParent === null || refParent === void 0 ? void 0 : refParent.type) === 'JSXSpreadAttribute';
120
+ }).length;
121
+ context.report(_objectSpread({
122
+ node: node,
123
+ messageId: 'noCssPropInObjectSpread'
124
+ }, spreadCount === 1 ? {
125
+ fix: function fix(fixer) {
126
+ var sourceCode = (0, _contextCompat.getSourceCode)(context);
127
+ var cssValueText = sourceCode.getText(_cssProp.value);
128
+ var fixes = [];
129
+ var remainingProps = initObject.properties.filter(function (p) {
130
+ return p !== _cssProp;
131
+ });
132
+ if (remainingProps.length === 0) {
133
+ fixes.push(fixer.replaceText(initObject, '{}'));
134
+ } else {
135
+ var propIndex = initObject.properties.indexOf(_cssProp);
136
+ var isLast = propIndex === initObject.properties.length - 1;
137
+ var tokenBefore = sourceCode.getTokenBefore(_cssProp);
138
+ var tokenAfter = sourceCode.getTokenAfter(_cssProp);
139
+ if (!isLast && tokenAfter && tokenAfter.value === ',') {
140
+ var src = sourceCode.getText();
141
+ var afterEnd = tokenAfter.range[1];
142
+ var end = afterEnd;
143
+ while (end < src.length && src[end] === ' ') {
144
+ end++;
145
+ }
146
+ fixes.push(fixer.removeRange([_cssProp.range[0], end]));
147
+ } else if (tokenBefore && tokenBefore.value === ',') {
148
+ fixes.push(fixer.removeRange([tokenBefore.range[0], _cssProp.range[1]]));
149
+ } else {
150
+ fixes.push(fixer.remove(_cssProp));
151
+ }
152
+ }
153
+ fixes.push(fixer.insertTextBefore(node, "css={".concat(cssValueText, "} ")));
154
+ return fixes;
155
+ }
156
+ } : {}));
157
+ }
158
+ }
159
+ };
160
+ }
161
+ };
162
+ var _default = exports.default = noCssPropInObjectSpread;