@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
@@ -0,0 +1,275 @@
1
+ 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; } } }; }
2
+ 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; } }
3
+ 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; }
4
+ var EASING_KEYWORDS = ['ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];
5
+ var KEYWORD_VALUES = ['none', 'all', 'inherit', 'initial', 'unset'];
6
+ var isDuration = function isDuration(token) {
7
+ return /^\d+(?:\.\d+)?m?s$/.test(token);
8
+ };
9
+ var isEasing = function isEasing(token) {
10
+ return EASING_KEYWORDS.includes(token) || token.startsWith('cubic-bezier(') || token.startsWith('steps(');
11
+ };
12
+ /**
13
+ * Tokenizes a CSS shorthand value string, respecting function boundaries.
14
+ * e.g. 'opacity 200ms cubic-bezier(0.4, 0, 0, 1) 0ms' →
15
+ * ['opacity', '200ms', 'cubic-bezier(0.4, 0, 0, 1)', '0ms']
16
+ * Splits on whitespace only when not inside parentheses.
17
+ */
18
+ var tokenizeShorthand = function tokenizeShorthand(value) {
19
+ var tokens = [];
20
+ var depth = 0;
21
+ var current = '';
22
+ for (var i = 0; i < value.length; i++) {
23
+ var ch = value[i];
24
+ if (ch === '(') {
25
+ depth++;
26
+ current += ch;
27
+ } else if (ch === ')') {
28
+ depth--;
29
+ current += ch;
30
+ } else if (/\s/.test(ch) && depth === 0) {
31
+ if (current.length > 0) {
32
+ tokens.push(current);
33
+ current = '';
34
+ }
35
+ } else {
36
+ current += ch;
37
+ }
38
+ }
39
+ if (current.length > 0) {
40
+ tokens.push(current);
41
+ }
42
+ return tokens;
43
+ };
44
+
45
+ // Splits on top-level commas (outside function parens) — preserves cubic-bezier(...) commas.
46
+ var splitOnTopLevelCommas = function splitOnTopLevelCommas(value) {
47
+ var parts = [];
48
+ var depth = 0;
49
+ var current = '';
50
+ var _iterator = _createForOfIteratorHelper(value),
51
+ _step;
52
+ try {
53
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
54
+ var ch = _step.value;
55
+ if (ch === '(') {
56
+ depth++;
57
+ current += ch;
58
+ } else if (ch === ')') {
59
+ depth--;
60
+ current += ch;
61
+ } else if (ch === ',' && depth === 0) {
62
+ parts.push(current.trim());
63
+ current = '';
64
+ } else {
65
+ current += ch;
66
+ }
67
+ }
68
+ } catch (err) {
69
+ _iterator.e(err);
70
+ } finally {
71
+ _iterator.f();
72
+ }
73
+ if (current.trim().length > 0) {
74
+ parts.push(current.trim());
75
+ }
76
+ return parts;
77
+ };
78
+ var parseTransition = function parseTransition(value) {
79
+ var parts = tokenizeShorthand(value.trim());
80
+ var result = {};
81
+ var durationCount = 0;
82
+ var _iterator2 = _createForOfIteratorHelper(parts),
83
+ _step2;
84
+ try {
85
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
86
+ var part = _step2.value;
87
+ if (isDuration(part)) {
88
+ if (durationCount === 0) {
89
+ result.transitionDuration = part;
90
+ } else {
91
+ result.transitionDelay = part;
92
+ }
93
+ durationCount++;
94
+ } else if (isEasing(part)) {
95
+ result.transitionTimingFunction = part;
96
+ } else {
97
+ result.transitionProperty = part;
98
+ }
99
+ }
100
+ } catch (err) {
101
+ _iterator2.e(err);
102
+ } finally {
103
+ _iterator2.f();
104
+ }
105
+ return result;
106
+ };
107
+ var parseAnimation = function parseAnimation(value) {
108
+ var parts = tokenizeShorthand(value.trim());
109
+ var result = {};
110
+ var durationCount = 0;
111
+ var _iterator3 = _createForOfIteratorHelper(parts),
112
+ _step3;
113
+ try {
114
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
115
+ var part = _step3.value;
116
+ if (isDuration(part)) {
117
+ if (durationCount === 0) {
118
+ result.animationDuration = part;
119
+ } else {
120
+ result.animationDelay = part;
121
+ }
122
+ durationCount++;
123
+ } else if (isEasing(part)) {
124
+ result.animationTimingFunction = part;
125
+ } else if (part === 'infinite' || /^\d+(\.\d+)?$/.test(part)) {
126
+ result.animationIterationCount = part;
127
+ } else if (['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(part)) {
128
+ result.animationDirection = part;
129
+ } else if (['none', 'forwards', 'backwards', 'both'].includes(part)) {
130
+ result.animationFillMode = part;
131
+ } else if (['running', 'paused'].includes(part)) {
132
+ result.animationPlayState = part;
133
+ } else {
134
+ result.animationName = part;
135
+ }
136
+ }
137
+ } catch (err) {
138
+ _iterator3.e(err);
139
+ } finally {
140
+ _iterator3.f();
141
+ }
142
+ return result;
143
+ };
144
+
145
+ // Combine sub-property values across comma-separated transitions/animations.
146
+ // If no segment explicitly set this sub-property, omit it entirely.
147
+ // Otherwise, fill missing slots with the CSS spec default to preserve positional alignment.
148
+ var combineSubPropertyValues = function combineSubPropertyValues(segments, subProperty, defaultValue) {
149
+ if (segments.every(function (s) {
150
+ return s[subProperty] === undefined;
151
+ })) {
152
+ return undefined;
153
+ }
154
+ return segments.map(function (s) {
155
+ var _s$subProperty;
156
+ return (_s$subProperty = s[subProperty]) !== null && _s$subProperty !== void 0 ? _s$subProperty : defaultValue;
157
+ }).join(', ');
158
+ };
159
+ var buildTransitionFix = function buildTransitionFix(segments, indent) {
160
+ var lines = [];
161
+ var property = combineSubPropertyValues(segments, 'transitionProperty', 'all');
162
+ var duration = combineSubPropertyValues(segments, 'transitionDuration', '0s');
163
+ var timing = combineSubPropertyValues(segments, 'transitionTimingFunction', 'ease');
164
+ var delay = combineSubPropertyValues(segments, 'transitionDelay', '0s');
165
+ if (property !== undefined) lines.push("transitionProperty: '".concat(property, "'"));
166
+ if (duration !== undefined) lines.push("transitionDuration: '".concat(duration, "'"));
167
+ if (timing !== undefined) lines.push("transitionTimingFunction: '".concat(timing, "'"));
168
+ if (delay !== undefined) lines.push("transitionDelay: '".concat(delay, "'"));
169
+ return lines.join(",\n".concat(indent));
170
+ };
171
+ var buildAnimationFix = function buildAnimationFix(segments, indent) {
172
+ var lines = [];
173
+ var name = combineSubPropertyValues(segments, 'animationName', 'none');
174
+ var duration = combineSubPropertyValues(segments, 'animationDuration', '0s');
175
+ var timing = combineSubPropertyValues(segments, 'animationTimingFunction', 'ease');
176
+ var delay = combineSubPropertyValues(segments, 'animationDelay', '0s');
177
+ var iter = combineSubPropertyValues(segments, 'animationIterationCount', '1');
178
+ var direction = combineSubPropertyValues(segments, 'animationDirection', 'normal');
179
+ var fill = combineSubPropertyValues(segments, 'animationFillMode', 'none');
180
+ var playState = combineSubPropertyValues(segments, 'animationPlayState', 'running');
181
+ if (name !== undefined) lines.push("animationName: '".concat(name, "'"));
182
+ if (duration !== undefined) lines.push("animationDuration: '".concat(duration, "'"));
183
+ if (timing !== undefined) lines.push("animationTimingFunction: '".concat(timing, "'"));
184
+ if (delay !== undefined) lines.push("animationDelay: '".concat(delay, "'"));
185
+ if (iter !== undefined) lines.push("animationIterationCount: '".concat(iter, "'"));
186
+ if (direction !== undefined) lines.push("animationDirection: '".concat(direction, "'"));
187
+ if (fill !== undefined) lines.push("animationFillMode: '".concat(fill, "'"));
188
+ if (playState !== undefined) lines.push("animationPlayState: '".concat(playState, "'"));
189
+ return lines.join(",\n".concat(indent));
190
+ };
191
+ var TRANSITION_SUB_PROPERTIES = ['transitionProperty', 'transitionDuration', 'transitionTimingFunction', 'transitionDelay'];
192
+ var ANIMATION_SUB_PROPERTIES = ['animationName', 'animationDuration', 'animationTimingFunction', 'animationDelay', 'animationIterationCount', 'animationDirection', 'animationFillMode', 'animationPlayState'];
193
+ var executeExpandTransitionRule = function executeExpandTransitionRule(context, node, property) {
194
+ var _context$sourceCode, _node$loc;
195
+ if (node.value.type === 'CallExpression') {
196
+ return;
197
+ }
198
+ if (node.value.type === 'TemplateLiteral') {
199
+ return;
200
+ }
201
+ if (node.value.type !== 'Literal' || typeof node.value.value !== 'string') {
202
+ return;
203
+ }
204
+ var rawValue = node.value.value;
205
+ if (KEYWORD_VALUES.includes(rawValue)) {
206
+ return;
207
+ }
208
+ var subProperties = property === 'transition' ? TRANSITION_SUB_PROPERTIES : ANIMATION_SUB_PROPERTIES;
209
+
210
+ // Extract leading whitespace to preserve indentation style (tabs vs spaces)
211
+ var sourceCode = (_context$sourceCode = context.sourceCode) !== null && _context$sourceCode !== void 0 ? _context$sourceCode : context.getSourceCode();
212
+ var nodeStart = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
213
+ var indent = '\t';
214
+ if (nodeStart) {
215
+ var _sourceCode$lines;
216
+ var lineText = (_sourceCode$lines = sourceCode.lines[nodeStart.line - 1]) !== null && _sourceCode$lines !== void 0 ? _sourceCode$lines : '';
217
+ var leadingWhitespace = lineText.match(/^(\s*)/);
218
+ if (leadingWhitespace) {
219
+ indent = leadingWhitespace[1];
220
+ }
221
+ }
222
+ var segmentStrings = splitOnTopLevelCommas(rawValue);
223
+ if (property === 'transition') {
224
+ var segments = segmentStrings.map(parseTransition);
225
+ var fixText = buildTransitionFix(segments, indent);
226
+ context.report({
227
+ node: node,
228
+ messageId: 'expandTransitionShorthand',
229
+ data: {
230
+ property: property,
231
+ subProperties: subProperties.join(', ')
232
+ },
233
+ fix: function fix(fixer) {
234
+ return fixer.replaceText(node, fixText);
235
+ }
236
+ });
237
+ } else {
238
+ var _segments = segmentStrings.map(parseAnimation);
239
+ var _fixText = buildAnimationFix(_segments, indent);
240
+ context.report({
241
+ node: node,
242
+ messageId: 'expandTransitionShorthand',
243
+ data: {
244
+ property: property,
245
+ subProperties: subProperties.join(', ')
246
+ },
247
+ fix: function fix(fixer) {
248
+ return fixer.replaceText(node, _fixText);
249
+ }
250
+ });
251
+ }
252
+ };
253
+ export var expandTransitionShorthand = {
254
+ meta: {
255
+ type: 'suggestion',
256
+ fixable: 'code',
257
+ docs: {
258
+ url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/platform/eslint-plugin/src/rules/compiled/expand-transition-shorthand/'
259
+ },
260
+ messages: {
261
+ expandTransitionShorthand: "Use {{ subProperties }} instead of the '{{ property }}' shorthand so that individual values can be replaced with motion tokens."
262
+ }
263
+ },
264
+ create: function create(context) {
265
+ return {
266
+ 'Property[key.name="transition"]': function PropertyKeyNameTransition(node) {
267
+ executeExpandTransitionRule(context, node, 'transition');
268
+ },
269
+ 'Property[key.name="animation"]': function PropertyKeyNameAnimation(node) {
270
+ executeExpandTransitionRule(context, node, 'animation');
271
+ }
272
+ };
273
+ }
274
+ };
275
+ export default expandTransitionShorthand;
@@ -0,0 +1,156 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ 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
+ 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; } } }; }
5
+ 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; } }
6
+ 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; }
7
+ import { getScope, getSourceCode } from '../../util/context-compat';
8
+
9
+ /**
10
+ * Returns the `css` Property node from an ObjectExpression, or null if not found.
11
+ */
12
+ function getCssProperty(objectExpression) {
13
+ var _iterator = _createForOfIteratorHelper(objectExpression.properties),
14
+ _step;
15
+ try {
16
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
17
+ var prop = _step.value;
18
+ if (prop.type !== 'Property') {
19
+ continue;
20
+ }
21
+ var key = prop.key;
22
+ if (key.type === 'Identifier' && key.name === 'css' || key.type === 'Literal' && key.value === 'css') {
23
+ return prop;
24
+ }
25
+ }
26
+ } catch (err) {
27
+ _iterator.e(err);
28
+ } finally {
29
+ _iterator.f();
30
+ }
31
+ return null;
32
+ }
33
+ export var noCssPropInObjectSpread = {
34
+ meta: {
35
+ docs: {
36
+ url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/platform/eslint-plugin/src/rules/compiled/no-css-prop-in-object-spread/',
37
+ description: 'Disallows `css` property inside objects spread into JSX — the Compiled JSX pragma ignores it'
38
+ },
39
+ fixable: 'code',
40
+ messages: {
41
+ 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={...} />'
42
+ },
43
+ type: 'problem'
44
+ },
45
+ create: function create(context) {
46
+ return {
47
+ JSXSpreadAttribute: function JSXSpreadAttribute(node) {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ var spreadNode = node;
50
+ var arg = spreadNode.argument;
51
+
52
+ // Case 1: inline object literal — <div {...{ css: styles, id: 'foo' }} />
53
+ if (arg.type === 'ObjectExpression') {
54
+ var objectArg = arg;
55
+ var cssProp = getCssProperty(objectArg);
56
+ if (!cssProp) {
57
+ return;
58
+ }
59
+ context.report({
60
+ node: node,
61
+ messageId: 'noCssPropInObjectSpread',
62
+ fix: function fix(fixer) {
63
+ var sourceCode = getSourceCode(context);
64
+ var cssValueText = sourceCode.getText(cssProp.value);
65
+ var remainingProps = objectArg.properties.filter(function (p) {
66
+ return p !== cssProp;
67
+ });
68
+ var directCssProp = "css={".concat(cssValueText, "}");
69
+ if (remainingProps.length === 0) {
70
+ return fixer.replaceText(node, directCssProp);
71
+ }
72
+ var remainingText = remainingProps.map(function (p) {
73
+ return sourceCode.getText(p);
74
+ }).join(', ');
75
+ return fixer.replaceText(node, "".concat(directCssProp, " {...{ ").concat(remainingText, " }}"));
76
+ }
77
+ });
78
+ return;
79
+ }
80
+
81
+ // Case 2: variable reference — <div {...props} />
82
+ if (arg.type === 'Identifier') {
83
+ var scope = getScope(context, arg);
84
+ var currentScope = scope;
85
+ var variable = null;
86
+ while (currentScope) {
87
+ var found = currentScope.variables.find(function (v) {
88
+ return v.name === arg.name;
89
+ });
90
+ if (found) {
91
+ variable = found;
92
+ break;
93
+ }
94
+ currentScope = currentScope.upper;
95
+ }
96
+ if (!variable || variable.defs.length === 0) {
97
+ return;
98
+ }
99
+ var def = variable.defs[0];
100
+ if (def.type !== 'Variable' || !def.node.init || def.node.init.type !== 'ObjectExpression') {
101
+ return;
102
+ }
103
+ var initObject = def.node.init;
104
+ var _cssProp = getCssProperty(initObject);
105
+ if (!_cssProp) {
106
+ return;
107
+ }
108
+
109
+ // Only auto-fix when there is exactly one JSX spread site for this variable
110
+ var spreadCount = variable.references.filter(function (ref) {
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ var refParent = ref.identifier.parent;
113
+ return (refParent === null || refParent === void 0 ? void 0 : refParent.type) === 'JSXSpreadAttribute';
114
+ }).length;
115
+ context.report(_objectSpread({
116
+ node: node,
117
+ messageId: 'noCssPropInObjectSpread'
118
+ }, spreadCount === 1 ? {
119
+ fix: function fix(fixer) {
120
+ var sourceCode = getSourceCode(context);
121
+ var cssValueText = sourceCode.getText(_cssProp.value);
122
+ var fixes = [];
123
+ var remainingProps = initObject.properties.filter(function (p) {
124
+ return p !== _cssProp;
125
+ });
126
+ if (remainingProps.length === 0) {
127
+ fixes.push(fixer.replaceText(initObject, '{}'));
128
+ } else {
129
+ var propIndex = initObject.properties.indexOf(_cssProp);
130
+ var isLast = propIndex === initObject.properties.length - 1;
131
+ var tokenBefore = sourceCode.getTokenBefore(_cssProp);
132
+ var tokenAfter = sourceCode.getTokenAfter(_cssProp);
133
+ if (!isLast && tokenAfter && tokenAfter.value === ',') {
134
+ var src = sourceCode.getText();
135
+ var afterEnd = tokenAfter.range[1];
136
+ var end = afterEnd;
137
+ while (end < src.length && src[end] === ' ') {
138
+ end++;
139
+ }
140
+ fixes.push(fixer.removeRange([_cssProp.range[0], end]));
141
+ } else if (tokenBefore && tokenBefore.value === ',') {
142
+ fixes.push(fixer.removeRange([tokenBefore.range[0], _cssProp.range[1]]));
143
+ } else {
144
+ fixes.push(fixer.remove(_cssProp));
145
+ }
146
+ }
147
+ fixes.push(fixer.insertTextBefore(node, "css={".concat(cssValueText, "} ")));
148
+ return fixes;
149
+ }
150
+ } : {}));
151
+ }
152
+ }
153
+ };
154
+ }
155
+ };
156
+ export default noCssPropInObjectSpread;