@atlaskit/eslint-plugin-design-system 8.15.5 → 8.17.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/constellation/index/usage.mdx +62 -16
  3. package/dist/cjs/rules/prefer-primitives/index.js +2 -3
  4. package/dist/cjs/rules/prefer-primitives/utils.js +16 -5
  5. package/dist/cjs/rules/use-primitives/index.js +89 -58
  6. package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +95 -0
  7. package/dist/cjs/rules/use-primitives/transformers/index.js +31 -0
  8. package/dist/cjs/rules/use-primitives/transformers/jsx-element-to-box.js +26 -0
  9. package/dist/cjs/rules/use-primitives/utils/contains-only-supported-attrs.js +19 -0
  10. package/dist/cjs/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +31 -0
  11. package/dist/cjs/rules/use-primitives/utils/get-attribute-value-identifier.js +37 -0
  12. package/dist/cjs/rules/use-primitives/utils/get-function-argument-at-pos.js +10 -0
  13. package/dist/cjs/rules/use-primitives/utils/get-jsx-attribute-by-name.js +16 -0
  14. package/dist/cjs/rules/use-primitives/utils/get-variable-definition-value.js +29 -0
  15. package/dist/cjs/rules/use-primitives/utils/get-variable-usage-count.js +21 -0
  16. package/dist/cjs/rules/use-primitives/utils/index.js +89 -0
  17. package/dist/cjs/rules/use-primitives/utils/is-function-named.js +19 -0
  18. package/dist/cjs/rules/use-primitives/utils/is-valid-tag-name.js +13 -0
  19. package/dist/cjs/rules/use-primitives/utils/update-jsx-attribute-by-name.js +31 -0
  20. package/dist/cjs/rules/use-primitives/utils/update-jsx-element-name.js +16 -0
  21. package/dist/cjs/rules/use-primitives/utils/upsert-import-declaration.js +80 -0
  22. package/dist/es2019/rules/prefer-primitives/index.js +1 -2
  23. package/dist/es2019/rules/prefer-primitives/utils.js +11 -2
  24. package/dist/es2019/rules/use-primitives/index.js +91 -60
  25. package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +91 -0
  26. package/dist/es2019/rules/use-primitives/transformers/index.js +2 -0
  27. package/dist/es2019/rules/use-primitives/transformers/jsx-element-to-box.js +16 -0
  28. package/dist/es2019/rules/use-primitives/utils/contains-only-supported-attrs.js +13 -0
  29. package/dist/es2019/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +26 -0
  30. package/dist/es2019/rules/use-primitives/utils/get-attribute-value-identifier.js +32 -0
  31. package/dist/es2019/rules/use-primitives/utils/get-function-argument-at-pos.js +4 -0
  32. package/dist/es2019/rules/use-primitives/utils/get-jsx-attribute-by-name.js +10 -0
  33. package/dist/es2019/rules/use-primitives/utils/get-variable-definition-value.js +23 -0
  34. package/dist/es2019/rules/use-primitives/utils/get-variable-usage-count.js +15 -0
  35. package/dist/es2019/rules/use-primitives/utils/index.js +12 -0
  36. package/dist/es2019/rules/use-primitives/utils/is-function-named.js +13 -0
  37. package/dist/es2019/rules/use-primitives/utils/is-valid-tag-name.js +7 -0
  38. package/dist/es2019/rules/use-primitives/utils/update-jsx-attribute-by-name.js +26 -0
  39. package/dist/es2019/rules/use-primitives/utils/update-jsx-element-name.js +12 -0
  40. package/dist/es2019/rules/use-primitives/utils/upsert-import-declaration.js +76 -0
  41. package/dist/esm/rules/prefer-primitives/index.js +1 -2
  42. package/dist/esm/rules/prefer-primitives/utils.js +13 -2
  43. package/dist/esm/rules/use-primitives/index.js +91 -60
  44. package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +88 -0
  45. package/dist/esm/rules/use-primitives/transformers/index.js +2 -0
  46. package/dist/esm/rules/use-primitives/transformers/jsx-element-to-box.js +19 -0
  47. package/dist/esm/rules/use-primitives/utils/contains-only-supported-attrs.js +13 -0
  48. package/dist/esm/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +26 -0
  49. package/dist/esm/rules/use-primitives/utils/get-attribute-value-identifier.js +32 -0
  50. package/dist/esm/rules/use-primitives/utils/get-function-argument-at-pos.js +4 -0
  51. package/dist/esm/rules/use-primitives/utils/get-jsx-attribute-by-name.js +10 -0
  52. package/dist/esm/rules/use-primitives/utils/get-variable-definition-value.js +23 -0
  53. package/dist/esm/rules/use-primitives/utils/get-variable-usage-count.js +15 -0
  54. package/dist/esm/rules/use-primitives/utils/index.js +12 -0
  55. package/dist/esm/rules/use-primitives/utils/is-function-named.js +13 -0
  56. package/dist/esm/rules/use-primitives/utils/is-valid-tag-name.js +7 -0
  57. package/dist/esm/rules/use-primitives/utils/update-jsx-attribute-by-name.js +24 -0
  58. package/dist/esm/rules/use-primitives/utils/update-jsx-element-name.js +10 -0
  59. package/dist/esm/rules/use-primitives/utils/upsert-import-declaration.js +75 -0
  60. package/dist/types/rules/prefer-primitives/utils.d.ts +2 -1
  61. package/dist/types/rules/use-primitives/transformers/css-to-xcss.d.ts +9 -0
  62. package/dist/types/rules/use-primitives/transformers/index.d.ts +2 -0
  63. package/dist/types/rules/use-primitives/transformers/jsx-element-to-box.d.ts +3 -0
  64. package/dist/types/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +2 -0
  65. package/dist/types/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +9 -0
  66. package/dist/types/rules/use-primitives/utils/get-attribute-value-identifier.d.ts +14 -0
  67. package/dist/types/rules/use-primitives/utils/get-function-argument-at-pos.d.ts +2 -0
  68. package/dist/types/rules/use-primitives/utils/get-jsx-attribute-by-name.d.ts +2 -0
  69. package/dist/types/rules/use-primitives/utils/get-variable-definition-value.d.ts +2 -0
  70. package/dist/types/rules/use-primitives/utils/get-variable-usage-count.d.ts +6 -0
  71. package/dist/types/rules/use-primitives/utils/index.d.ts +12 -0
  72. package/dist/types/rules/use-primitives/utils/is-function-named.d.ts +2 -0
  73. package/dist/types/rules/use-primitives/utils/is-valid-tag-name.d.ts +2 -0
  74. package/dist/types/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +3 -0
  75. package/dist/types/rules/use-primitives/utils/update-jsx-element-name.d.ts +3 -0
  76. package/dist/types/rules/use-primitives/utils/upsert-import-declaration.d.ts +11 -0
  77. package/dist/types-ts4.5/rules/prefer-primitives/utils.d.ts +2 -1
  78. package/dist/types-ts4.5/rules/use-primitives/transformers/css-to-xcss.d.ts +9 -0
  79. package/dist/types-ts4.5/rules/use-primitives/transformers/index.d.ts +2 -0
  80. package/dist/types-ts4.5/rules/use-primitives/transformers/jsx-element-to-box.d.ts +3 -0
  81. package/dist/types-ts4.5/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +2 -0
  82. package/dist/types-ts4.5/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +9 -0
  83. package/dist/types-ts4.5/rules/use-primitives/utils/get-attribute-value-identifier.d.ts +14 -0
  84. package/dist/types-ts4.5/rules/use-primitives/utils/get-function-argument-at-pos.d.ts +2 -0
  85. package/dist/types-ts4.5/rules/use-primitives/utils/get-jsx-attribute-by-name.d.ts +2 -0
  86. package/dist/types-ts4.5/rules/use-primitives/utils/get-variable-definition-value.d.ts +2 -0
  87. package/dist/types-ts4.5/rules/use-primitives/utils/get-variable-usage-count.d.ts +6 -0
  88. package/dist/types-ts4.5/rules/use-primitives/utils/index.d.ts +12 -0
  89. package/dist/types-ts4.5/rules/use-primitives/utils/is-function-named.d.ts +2 -0
  90. package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-tag-name.d.ts +2 -0
  91. package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +3 -0
  92. package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-element-name.d.ts +3 -0
  93. package/dist/types-ts4.5/rules/use-primitives/utils/upsert-import-declaration.d.ts +11 -0
  94. package/package.json +3 -1
  95. package/dist/cjs/rules/use-primitives/utils.js +0 -364
  96. package/dist/es2019/rules/use-primitives/utils.js +0 -353
  97. package/dist/esm/rules/use-primitives/utils.js +0 -359
  98. package/dist/types/rules/use-primitives/utils.d.ts +0 -13
  99. package/dist/types-ts4.5/rules/use-primitives/utils.d.ts +0 -13
@@ -1,364 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.validPrimitiveElements = exports.shouldSuggestText = exports.shouldSuggestStack = exports.shouldSuggestInline = exports.shouldSuggestBox = exports.primitiveFixer = exports.isWhiteSpace = exports.isValidPrimitiveElement = exports.getChildrenByType = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _eslintCodemodUtils = require("eslint-codemod-utils");
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; } // eslint-disable-next-line import/no-extraneous-dependencies
12
- var shouldSuggestBox = exports.shouldSuggestBox = function shouldSuggestBox(node
13
- // scope: Scope.Scope,
14
- ) {
15
- if (!node) {
16
- return false;
17
- }
18
- if (!isValidPrimitiveElement(node)) {
19
- return false;
20
- }
21
-
22
- /**
23
- * Check for empty elements: `<div></div>` || `<span></span>`
24
- */
25
- if (node.children.length === 0) {
26
- return true;
27
- }
28
-
29
- /**
30
- * Check for elements containing only whitespace. e.g. `<div> </div>` || `<span> </span>`
31
- */
32
- if (containsOnlyWhitespace(node)) {
33
- return true;
34
- }
35
-
36
- /**
37
- * If an element contains more than one JSX child, then we don't want to convert it.
38
- */
39
- var JSXChildren = getChildrenByType(node, ['JSXElement']);
40
- if (JSXChildren.length > 1) {
41
- return false;
42
- }
43
-
44
- /**
45
- * Check for things like:
46
- * ```
47
- * <div>
48
- * <h2>heading</h2>
49
- * subheading <= rejected because of standalone piece of text
50
- * </div>
51
- * ```
52
- */
53
- var nonWhiteSpaceTextChildren = getChildrenByType(node, ['JSXText']).filter(function (child) {
54
- return !isWhiteSpace(child.value);
55
- });
56
- if (nonWhiteSpaceTextChildren.length > 0) {
57
- return false;
58
- }
59
-
60
- // Possible since we now know the div only has one child
61
- // const singleChild = node.children[0];
62
-
63
- // // let's narrow down the type inside of the expression
64
- // if (isNodeOfType(singleChild, 'JSXExpressionContainer')) {
65
- // const expression = singleChild.expression;
66
-
67
- // // If an Identifier that is just a string then should be a <Text>, not <Box>
68
- // const identifier =
69
- // isNodeOfType(expression, 'Identifier') &&
70
- // getIdentifierInParentScope(scope, expression.name);
71
-
72
- // if (
73
- // identifier &&
74
- // (isVariableAnnotatedWithType(identifier, 'StringTypeAnnotation') ||
75
- // isVariableAnnotatedWithType(identifier, 'TSStringKeyword'))
76
- // ) {
77
- // return false;
78
- // }
79
- // }
80
-
81
- return true;
82
- };
83
- var shouldSuggestInline = exports.shouldSuggestInline = function shouldSuggestInline(node, context) {
84
- if (!node) {
85
- return false;
86
- }
87
- if (!isValidPrimitiveElement(node)) {
88
- return false;
89
- }
90
- var cssStyleObject = getCSSPropStyleObject(node, context);
91
- if (!cssStyleObject) {
92
- return false;
93
- }
94
- if (!hasInlineCompatibleStyles(cssStyleObject)) {
95
- return false;
96
- }
97
- var JSXChildren = getChildrenByType(node, ['JSXElement']);
98
- if (JSXChildren.length < 2) {
99
- return false;
100
- }
101
- return true;
102
- };
103
- var shouldSuggestStack = exports.shouldSuggestStack = function shouldSuggestStack(node, context) {
104
- if (!node) {
105
- return false;
106
- }
107
- if (!isValidPrimitiveElement(node)) {
108
- return false;
109
- }
110
- var cssStyleObject = getCSSPropStyleObject(node, context);
111
- if (!cssStyleObject) {
112
- return false;
113
- }
114
- if (!hasStackCompatibleStyles(cssStyleObject)) {
115
- return false;
116
- }
117
- var JSXChildren = getChildrenByType(node, ['JSXElement']);
118
- if (JSXChildren.length < 2) {
119
- return false;
120
- }
121
- return true;
122
- };
123
- var shouldSuggestText = exports.shouldSuggestText = function shouldSuggestText(node, scope) {
124
- if (!node) {
125
- return true;
126
- }
127
-
128
- // node doesn't have children then it should be a <Box>
129
- if (!node.children || node.children.length === 0) {
130
- return false;
131
- }
132
- var containsOnlyText = node.children.filter(function (child) {
133
- return (0, _eslintCodemodUtils.isNodeOfType)(child, 'Literal') || (0, _eslintCodemodUtils.isNodeOfType)(child, 'JSXText');
134
- });
135
- if (containsOnlyText) {
136
- return true;
137
- }
138
-
139
- // if the element contains strictly a single child... let's see what we can discover
140
- if (node.children.length === 1) {
141
- var singleChild = node.children[0];
142
-
143
- // let's narrow down the type inside of the expression
144
- if ((0, _eslintCodemodUtils.isNodeOfType)(singleChild, 'JSXExpressionContainer')) {
145
- var expression = singleChild.expression;
146
-
147
- // A direct Literal is another case for only <Text>
148
- if ((0, _eslintCodemodUtils.isNodeOfType)(expression, 'Literal')) {
149
- return true;
150
- }
151
-
152
- // If an Identifier then we want to confirm it's just string to suggest only <Text>
153
- var identifier = (0, _eslintCodemodUtils.isNodeOfType)(expression, 'Identifier') && (0, _eslintCodemodUtils.getIdentifierInParentScope)(scope, expression.name);
154
- if (identifier && (isVariableAnnotatedWithType(identifier, 'StringTypeAnnotation') || isVariableAnnotatedWithType(identifier, 'TSStringKeyword'))) {
155
- return true;
156
- }
157
- }
158
- }
159
- return true;
160
- };
161
- var primitiveFixer = exports.primitiveFixer = function primitiveFixer(node, nodeName, context) {
162
- return function (fixer) {
163
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXOpeningElement')) {
164
- return [];
165
- }
166
- var parent = node.parent;
167
- if (!(0, _eslintCodemodUtils.isNodeOfType)(parent, 'JSXElement')) {
168
- return [];
169
- }
170
- var fixes = [];
171
- var body = context.getSourceCode().ast.body;
172
- var imports = body.filter(function (node) {
173
- return (0, _eslintCodemodUtils.isNodeOfType)(node, 'ImportDeclaration');
174
- });
175
- var primitivesNode = imports.find(function (node) {
176
- return (0, _eslintCodemodUtils.hasImportDeclaration)(node, '@atlaskit/primitives');
177
- });
178
- if (!primitivesNode) {
179
- fixes.push(fixer.insertTextBefore(body[0], "".concat((0, _eslintCodemodUtils.insertImportDeclaration)('@atlaskit/primitives', [nodeName]), ";\n")));
180
- } else {
181
- fixes.push(fixer.replaceText(primitivesNode, "".concat((0, _eslintCodemodUtils.insertImportSpecifier)(primitivesNode, nodeName), ";\n")));
182
- }
183
- var closingElement = parent.closingElement;
184
- var jsxId = (0, _eslintCodemodUtils.jsxIdentifier)(nodeName);
185
- var attributes = [];
186
-
187
- // Box defaults to div. We only need to add an as prop if it's not a div
188
- if (node.name.name !== 'div' && nodeName === 'Box') {
189
- var asProp = (0, _eslintCodemodUtils.jsxAttribute)({
190
- name: (0, _eslintCodemodUtils.jsxIdentifier)('as'),
191
- value: (0, _eslintCodemodUtils.literal)({
192
- value: "".concat(node.name.name),
193
- raw: "\"".concat(node.name.name, "\"")
194
- })
195
- });
196
- attributes.push(asProp);
197
- }
198
- var hasStylingProps = getJSXAttributeByName(node, 'style') || getJSXAttributeByName(node, 'css') || getJSXAttributeByName(node, 'class') || getJSXAttributeByName(node, 'className');
199
- if (hasStylingProps) {
200
- fixes.push(fixer.insertTextBefore(node, '// TODO: Manually convert styling into props\n'));
201
- }
202
- var candidateAttributes = node.attributes.map(function (attr) {
203
- // pull out any named attributes we can re-map
204
- if ((0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute')) {
205
- if (attr.name.name === 'data-testid') {
206
- return (0, _eslintCodemodUtils.jsxAttribute)(_objectSpread(_objectSpread({}, attr), {}, {
207
- name: (0, _eslintCodemodUtils.jsxIdentifier)('testId')
208
- }));
209
- }
210
- }
211
- return attr;
212
- }).filter(Boolean);
213
- fixes.push(fixer.replaceText(node, (0, _eslintCodemodUtils.jsxOpeningElement)(_objectSpread(_objectSpread({}, node), {}, {
214
- name: jsxId,
215
- attributes: candidateAttributes.concat(attributes)
216
- })).toString()));
217
- if (closingElement && closingElement.name) {
218
- fixes.push(fixer.replaceText(closingElement.name, "".concat(jsxId)));
219
- }
220
- return fixes;
221
- };
222
- };
223
- var isVariableAnnotatedWithType = function isVariableAnnotatedWithType(identifier, typeAnnotation) {
224
- var _identifiers$;
225
- if (!identifier || identifier.identifiers.length === 0) {
226
- return false;
227
- }
228
- var typeAnnotationObject = (_identifiers$ = identifier.identifiers[0]) === null || _identifiers$ === void 0 || (_identifiers$ = _identifiers$.typeAnnotation) === null || _identifiers$ === void 0 ? void 0 : _identifiers$.typeAnnotation;
229
-
230
- // variable declaration lacks type definitions
231
- if (!typeAnnotationObject) {
232
- return false;
233
- }
234
-
235
- // single type annotation
236
- if (typeAnnotationObject.type === typeAnnotation) {
237
- return true;
238
- }
239
- return false;
240
- };
241
- var getJSXAttributeByName = function getJSXAttributeByName(node, attrName) {
242
- return node.attributes.find(function (attr) {
243
- // Ignore JSXSpreadAttributes
244
- if (!(0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute')) {
245
- return false;
246
- }
247
- return attr.name.name === attrName;
248
- });
249
- };
250
- var isWhiteSpace = exports.isWhiteSpace = function isWhiteSpace(value) {
251
- return value.trim() === '';
252
- };
253
- function containsOnlyWhitespace(node) {
254
- return node.children.every(function (child) {
255
- if (!(0, _eslintCodemodUtils.isNodeOfType)(child, 'JSXText')) {
256
- return false;
257
- }
258
- return isWhiteSpace(child.value);
259
- });
260
- }
261
- var getChildrenByType = exports.getChildrenByType = function getChildrenByType(node, types) {
262
- return node.children.filter(function (child) {
263
- return types.find(function (type) {
264
- return (0, _eslintCodemodUtils.isNodeOfType)(child, type);
265
- });
266
- });
267
- };
268
-
269
- // FIXME: This not correctly typed
270
-
271
- var getCSSPropStyleObject = function getCSSPropStyleObject(node, context) {
272
- var cssAttr = getJSXAttributeByName(node.openingElement, 'css');
273
- var styleObj = {};
274
- if (cssAttr && cssAttr.value) {
275
- var scope = context.getScope();
276
- var _ref = cssAttr.value,
277
- expression = _ref.expression;
278
- var variableDeclarator = (0, _eslintCodemodUtils.getIdentifierInParentScope)(scope, expression.name);
279
- var defNode = variableDeclarator === null || variableDeclarator === void 0 ? void 0 : variableDeclarator.defs[0];
280
- if (!defNode) {
281
- return undefined;
282
- }
283
-
284
- // check if the variable declaration has a call expression init
285
- // eg we're looking for css() type inits
286
- if (!(0, _eslintCodemodUtils.isNodeOfType)(defNode.node, 'VariableDeclarator') && !(0, _eslintCodemodUtils.isNodeOfType)(defNode.node.init, 'CallExpression')) {
287
- return undefined;
288
- }
289
- var init = defNode.node.init;
290
-
291
- // make the sure the init is called 'css'
292
- if (!((0, _eslintCodemodUtils.isNodeOfType)(init.callee, 'Identifier') && init.callee.name === 'css')) {
293
- return undefined;
294
- }
295
- var styles = init.arguments[0];
296
- if (!styles) {
297
- return undefined;
298
- }
299
-
300
- // make sure the styles are object styles (they should be but let's just double check)
301
- if (!(0, _eslintCodemodUtils.isNodeOfType)(styles, 'ObjectExpression')) {
302
- return undefined;
303
- }
304
- styles.properties.forEach(function (prop) {
305
- if (!(0, _eslintCodemodUtils.isNodeOfType)(prop, 'Property')) {
306
- return;
307
- }
308
- if (!(0, _eslintCodemodUtils.isNodeOfType)(prop.key, 'Identifier')) {
309
- return;
310
- }
311
- if (!(0, _eslintCodemodUtils.isNodeOfType)(prop.value, 'Literal')) {
312
- return;
313
- }
314
- styleObj[prop.key.name] = prop.value.value;
315
- });
316
- }
317
- return styleObj;
318
- };
319
- var validPrimitiveElements = exports.validPrimitiveElements = new Set(['div', 'span', 'article', 'aside', 'dialog', 'footer', 'header', 'li', 'main', 'nav', 'ol', 'section', 'ul']);
320
- var isValidPrimitiveElement = exports.isValidPrimitiveElement = function isValidPrimitiveElement(node) {
321
- return validPrimitiveElements.has(node.openingElement.name.name);
322
- };
323
- var hasInlineCompatibleStyles = function hasInlineCompatibleStyles(cssStyleObject) {
324
- if (!['flex', 'inline-flex'].includes(cssStyleObject['display'])) {
325
- return false;
326
- }
327
-
328
- /**
329
- * Default `flexDirection` is `'row'`, so we can recommend an Inline if
330
- * it's `undefined`, or if it's explicitly `'row'` or `'row-reverse'`.
331
- *
332
- * Note: Currently we are including `'row-reverse'` even though Inline doesn't support it
333
- * as an attempt to educate makers about accessibility concerns. *
334
- */
335
- var flexDirection = cssStyleObject['flex-direction'] || cssStyleObject['flexDirection'];
336
- var validFlexDirectionValue = ['row', 'row-reverse', undefined].includes(flexDirection);
337
-
338
- /**
339
- * Note: Currently we are including `'wrap-reverse'` even though Inline doesn't support it
340
- * as an attempt to educate makers about accessibility concerns.
341
- */
342
- var flexWrap = cssStyleObject['flex-wrap'] || cssStyleObject['flexWrap'];
343
- var validFlexWrapValue = ['wrap', 'wrap-reverse'].includes(flexWrap);
344
- if (validFlexDirectionValue || validFlexWrapValue) {
345
- return true;
346
- }
347
- return false;
348
- };
349
- var hasStackCompatibleStyles = function hasStackCompatibleStyles(cssStyleObject) {
350
- if (!['flex', 'inline-flex'].includes(cssStyleObject['display'])) {
351
- return false;
352
- }
353
-
354
- /**
355
- * Note: Currently we are including `'column-reverse'` even though Stack doesn't support it
356
- * as an attempt to educate makers about accessibility concerns.
357
- */
358
- var flexDirection = cssStyleObject['flex-direction'] || cssStyleObject['flexDirection'];
359
- var validFlexDirectionValue = ['column', 'column-reverse'].includes(flexDirection);
360
- if (!validFlexDirectionValue) {
361
- return false;
362
- }
363
- return true;
364
- };