@atlaskit/eslint-plugin-design-system 13.3.0 → 13.4.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/presets/all-flat.codegen.js +2 -1
  4. package/dist/cjs/presets/all.codegen.js +2 -1
  5. package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
  6. package/dist/cjs/presets/recommended.codegen.js +2 -1
  7. package/dist/cjs/rules/ensure-design-token-usage/index.js +1 -0
  8. package/dist/cjs/rules/index.codegen.js +3 -1
  9. package/dist/cjs/rules/no-custom-icons/index.js +2 -0
  10. package/dist/cjs/rules/no-deprecated-apis/index.js +3 -1
  11. package/dist/cjs/rules/no-deprecated-imports/checks.js +3 -1
  12. package/dist/cjs/rules/no-legacy-icons/helpers.js +3 -1
  13. package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +1 -0
  14. package/dist/cjs/rules/use-cx-function-in-xcss/index.js +97 -0
  15. package/dist/cjs/rules/use-heading/index.js +1 -0
  16. package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +1 -0
  17. package/dist/cjs/rules/use-modal-dialog-close-button/index.js +24 -12
  18. package/dist/cjs/rules/use-primitives/index.js +1 -0
  19. package/dist/cjs/rules/use-primitives-text/index.js +1 -0
  20. package/dist/cjs/rules/use-tokens-typography/index.js +1 -0
  21. package/dist/es2019/presets/all-flat.codegen.js +2 -1
  22. package/dist/es2019/presets/all.codegen.js +2 -1
  23. package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
  24. package/dist/es2019/presets/recommended.codegen.js +2 -1
  25. package/dist/es2019/rules/ensure-design-token-usage/index.js +1 -0
  26. package/dist/es2019/rules/index.codegen.js +3 -1
  27. package/dist/es2019/rules/no-custom-icons/index.js +2 -0
  28. package/dist/es2019/rules/no-deprecated-apis/index.js +3 -1
  29. package/dist/es2019/rules/no-deprecated-imports/checks.js +3 -1
  30. package/dist/es2019/rules/no-legacy-icons/helpers.js +3 -1
  31. package/dist/es2019/rules/no-unsafe-design-token-usage/index.js +1 -0
  32. package/dist/es2019/rules/use-cx-function-in-xcss/index.js +70 -0
  33. package/dist/es2019/rules/use-heading/index.js +1 -0
  34. package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +1 -0
  35. package/dist/es2019/rules/use-modal-dialog-close-button/index.js +24 -12
  36. package/dist/es2019/rules/use-primitives/index.js +1 -0
  37. package/dist/es2019/rules/use-primitives-text/index.js +1 -0
  38. package/dist/es2019/rules/use-tokens-typography/index.js +1 -0
  39. package/dist/esm/presets/all-flat.codegen.js +2 -1
  40. package/dist/esm/presets/all.codegen.js +2 -1
  41. package/dist/esm/presets/recommended-flat.codegen.js +2 -1
  42. package/dist/esm/presets/recommended.codegen.js +2 -1
  43. package/dist/esm/rules/ensure-design-token-usage/index.js +1 -0
  44. package/dist/esm/rules/index.codegen.js +3 -1
  45. package/dist/esm/rules/no-custom-icons/index.js +2 -0
  46. package/dist/esm/rules/no-deprecated-apis/index.js +3 -1
  47. package/dist/esm/rules/no-deprecated-imports/checks.js +3 -1
  48. package/dist/esm/rules/no-legacy-icons/helpers.js +3 -1
  49. package/dist/esm/rules/no-unsafe-design-token-usage/index.js +1 -0
  50. package/dist/esm/rules/use-cx-function-in-xcss/index.js +91 -0
  51. package/dist/esm/rules/use-heading/index.js +1 -0
  52. package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +1 -0
  53. package/dist/esm/rules/use-modal-dialog-close-button/index.js +24 -12
  54. package/dist/esm/rules/use-primitives/index.js +1 -0
  55. package/dist/esm/rules/use-primitives-text/index.js +1 -0
  56. package/dist/esm/rules/use-tokens-typography/index.js +1 -0
  57. package/dist/types/index.codegen.d.ts +9 -0
  58. package/dist/types/presets/all-flat.codegen.d.ts +1 -0
  59. package/dist/types/presets/all.codegen.d.ts +1 -0
  60. package/dist/types/presets/recommended-flat.codegen.d.ts +1 -0
  61. package/dist/types/presets/recommended.codegen.d.ts +1 -0
  62. package/dist/types/rules/index.codegen.d.ts +1 -0
  63. package/dist/types/rules/no-legacy-icons/helpers.d.ts +1 -1
  64. package/dist/types/rules/use-cx-function-in-xcss/index.d.ts +3 -0
  65. package/dist/types-ts4.5/index.codegen.d.ts +9 -0
  66. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -0
  67. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -0
  68. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -0
  69. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -0
  70. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  71. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +1 -1
  72. package/dist/types-ts4.5/rules/use-cx-function-in-xcss/index.d.ts +3 -0
  73. package/package.json +4 -4
@@ -31,6 +31,7 @@ const rule = createLintRule({
31
31
  }
32
32
  },
33
33
  create(context) {
34
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
34
35
  const config = getConfig(context.options[0]);
35
36
  return errorBoundary({
36
37
  // transforms <h1>...</h1> usages
@@ -40,6 +40,7 @@ const rule = createLintRule({
40
40
  }
41
41
  },
42
42
  create(context) {
43
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
43
44
  const config = getConfig(context.options[0]);
44
45
  return errorBoundary({
45
46
  'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': node => RestrictedProperty.lint(node, {
@@ -65,7 +65,7 @@ const rule = createLintRule({
65
65
  return;
66
66
  }
67
67
  const name = node.openingElement.name.name;
68
- if (name !== defaultImportLocalName) {
68
+ if (![defaultImportLocalName, modalHeaderLocalName].includes(name)) {
69
69
  return;
70
70
  }
71
71
  let modalHeaderNode = null;
@@ -120,13 +120,31 @@ const rule = createLintRule({
120
120
  checkNode(child);
121
121
  }
122
122
  };
123
- searchNode(node);
123
+ if (name === defaultImportLocalName) {
124
+ searchNode(node);
125
+
126
+ // If there is a close button, skip the rest, as this satisfies the
127
+ // rule. If there is a modal header, it will be recognized in later
128
+ // scans, so don't add duplicate errors
129
+ if (closeButtonNode || modalHeaderNode) {
130
+ return;
131
+ // No close button or modal header exists
132
+ } else {
133
+ return context.report({
134
+ node,
135
+ messageId: 'noCloseButtonExists'
136
+ });
137
+ }
138
+ } else if (name === modalHeaderLocalName) {
139
+ modalHeaderNode = node;
140
+ searchNode(node);
141
+
142
+ // If there is a close button, skip the rest, as this satisfies the rule.
143
+ if (closeButtonNode) {
144
+ return;
145
+ }
124
146
 
125
- // If there is a close button, skip the rest, as this satisfies the rule.
126
- if (closeButtonNode) {
127
- return;
128
147
  // No close button exists, so check the modal header
129
- } else if (modalHeaderNode !== null) {
130
148
  const prop = JSXElementHelper.getAttributeByName(modalHeaderNode, PROP_NAME);
131
149
 
132
150
  // If the prop exists
@@ -155,12 +173,6 @@ const rule = createLintRule({
155
173
  }]
156
174
  });
157
175
  }
158
- // No close button or modal header exists
159
- } else {
160
- return context.report({
161
- node,
162
- messageId: 'noCloseButtonExists'
163
- });
164
176
  }
165
177
  }
166
178
  };
@@ -32,6 +32,7 @@ const rule = createLintRule({
32
32
  }
33
33
  },
34
34
  create(context) {
35
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
35
36
  const config = getConfig(context.options[0]);
36
37
  return {
37
38
  // transforms styled.<html>(...) usages
@@ -47,6 +47,7 @@ const rule = createLintRule({
47
47
  }
48
48
  },
49
49
  create(context) {
50
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
50
51
  const config = getConfig(context.options[0]);
51
52
  return errorBoundary({
52
53
  'JSXElement[openingElement.name.name=span]': node => {
@@ -8,6 +8,7 @@ import { RestrictedCapitalisation } from './transformers/restricted-capitalisati
8
8
  import { StyleObject } from './transformers/style-object';
9
9
  import { UntokenizedProperties } from './transformers/untokenized-properties';
10
10
  const create = context => {
11
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
11
12
  const config = getConfig(context.options[0]);
12
13
  return errorBoundary({
13
14
  // const styles = css({ fontSize: '14px', ... }), styled.div({ fontSize: 14, ... })
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::f468eaa1b0e61e0eba404cafc58f6977>>
3
+ * @codegen <<SignedSource::9b616276b6c3b9db3c1d886bf8de4fc4>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -39,6 +39,7 @@ export default {
39
39
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
40
40
  '@atlaskit/design-system/prefer-primitives': 'warn',
41
41
  '@atlaskit/design-system/use-button-group-label': 'warn',
42
+ '@atlaskit/design-system/use-cx-function-in-xcss': 'error',
42
43
  '@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
43
44
  '@atlaskit/design-system/use-drawer-label': 'warn',
44
45
  '@atlaskit/design-system/use-heading': 'warn',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::29cc321a798c65c8464afd9e46366540>>
3
+ * @codegen <<SignedSource::96ec2e315f96de68a6448317cce334ce>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -38,6 +38,7 @@ export default {
38
38
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
39
39
  '@atlaskit/design-system/prefer-primitives': 'warn',
40
40
  '@atlaskit/design-system/use-button-group-label': 'warn',
41
+ '@atlaskit/design-system/use-cx-function-in-xcss': 'error',
41
42
  '@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
42
43
  '@atlaskit/design-system/use-drawer-label': 'warn',
43
44
  '@atlaskit/design-system/use-heading': 'warn',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::76f6f7b7602ea240cbcfc6bc98a781af>>
3
+ * @codegen <<SignedSource::4f6ee2ae56e1c0534f0f8e3fde314cc7>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -28,6 +28,7 @@ export default {
28
28
  '@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
29
29
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
30
30
  '@atlaskit/design-system/use-button-group-label': 'warn',
31
+ '@atlaskit/design-system/use-cx-function-in-xcss': 'error',
31
32
  '@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
32
33
  '@atlaskit/design-system/use-drawer-label': 'warn',
33
34
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::98f3a7e3c7f8f8532248994786f11c98>>
3
+ * @codegen <<SignedSource::85c1f4ada9dac0f66e87e3734a36cb6b>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -27,6 +27,7 @@ export default {
27
27
  '@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
28
28
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
29
29
  '@atlaskit/design-system/use-button-group-label': 'warn',
30
+ '@atlaskit/design-system/use-cx-function-in-xcss': 'error',
30
31
  '@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
31
32
  '@atlaskit/design-system/use-drawer-label': 'warn',
32
33
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
@@ -20,6 +20,7 @@ var defaultConfig = {
20
20
  };
21
21
  var createWithConfig = function createWithConfig(initialConfig) {
22
22
  return function (context) {
23
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
23
24
  var userConfig = context.options[0];
24
25
  // merge configs
25
26
  var config = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::551d1887446166d5a78fc51663d43e9c>>
3
+ * @codegen <<SignedSource::66749852497ab0f2dc3214dd47aaf598>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import consistentCssPropUsage from './consistent-css-prop-usage';
@@ -35,6 +35,7 @@ import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
35
35
  import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
36
36
  import preferPrimitives from './prefer-primitives';
37
37
  import useButtonGroupLabel from './use-button-group-label';
38
+ import useCxFunctionInXcss from './use-cx-function-in-xcss';
38
39
  import useDatetimePickerCalendarButton from './use-datetime-picker-calendar-button';
39
40
  import useDrawerLabel from './use-drawer-label';
40
41
  import useHeading from './use-heading';
@@ -85,6 +86,7 @@ export var rules = {
85
86
  'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
86
87
  'prefer-primitives': preferPrimitives,
87
88
  'use-button-group-label': useButtonGroupLabel,
89
+ 'use-cx-function-in-xcss': useCxFunctionInXcss,
88
90
  'use-datetime-picker-calendar-button': useDatetimePickerCalendarButton,
89
91
  'use-drawer-label': useDrawerLabel,
90
92
  'use-heading': useHeading,
@@ -32,6 +32,8 @@ var rule = createLintRule({
32
32
  create: function create(context) {
33
33
  var _context$options$;
34
34
  var isIconBase = createIsFromImportSourceFor('@atlaskit/icon', '@atlaskit/icon/base');
35
+
36
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
35
37
  var _ref = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {},
36
38
  _ref$centralLocation = _ref.centralLocation,
37
39
  centralLocation = _ref$centralLocation === void 0 ? '' : _ref$centralLocation,
@@ -67,7 +67,9 @@ var rule = createLintRule({
67
67
  var _context$options$;
68
68
  // Get the rule configuration specified otherwise use default config.
69
69
  // A bit confusing as it seems that the default options have precedence over the user specified options.
70
- var deprecatedConfig = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('jsxAttributes');
70
+ var deprecatedConfig =
71
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
72
+ ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('jsxAttributes');
71
73
  return {
72
74
  // find JSX attribute - find name of attribute - get source and find relevant identifiers.
73
75
  JSXAttribute: function JSXAttribute(node) {
@@ -32,7 +32,9 @@ export var createChecks = function createChecks(context) {
32
32
  type = _ref.type,
33
33
  node = _ref.node,
34
34
  importNames = _ref.importNames;
35
- var restrictedPathMessages = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('imports');
35
+ var restrictedPathMessages =
36
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
37
+ ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('imports');
36
38
  if (!isDeprecatedImportConfig(restrictedPathMessages)) {
37
39
  throw new Error('Config is invalid for deprecated imports');
38
40
  }
@@ -311,7 +311,9 @@ var getLiteralStringValue = function getLiteralStringValue(value) {
311
311
  }
312
312
  return;
313
313
  };
314
- export var createHelpers = function createHelpers(context) {
314
+ export var createHelpers = function createHelpers(ctx) {
315
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
316
+ var context = ctx;
315
317
  /**
316
318
  * Extracts the token name of a token() call from a JSXExpressionContainer
317
319
  * @param value The JSXExpressionContainer to extract the token call from
@@ -49,6 +49,7 @@ var rule = createLintRule({
49
49
  }]
50
50
  },
51
51
  create: function create(context) {
52
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
52
53
  var config = _objectSpread({}, context.options[0]);
53
54
  if (!config.fallbackUsage) {
54
55
  config.fallbackUsage = config.shouldEnforceFallbacks ? 'forced' : 'none';
@@ -0,0 +1,91 @@
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
+ import { isNodeOfType } from 'eslint-codemod-utils';
5
+ import { createLintRule } from '../utils/create-rule';
6
+ var rule = createLintRule({
7
+ meta: {
8
+ name: 'use-cx-function-in-xcss',
9
+ fixable: 'code',
10
+ hasSuggestions: true,
11
+ type: 'problem',
12
+ docs: {
13
+ description: 'Enforces cx function use to combine styles in xcss.',
14
+ recommended: true,
15
+ severity: 'error'
16
+ },
17
+ messages: {
18
+ useCxFunc: "Use the cx function when combining styles in the xcss prop."
19
+ }
20
+ },
21
+ create: function create(context) {
22
+ var importStatement = null;
23
+ var primitiveNames = new Set();
24
+ return {
25
+ "ImportDeclaration[source.value='@atlaskit/css']": function ImportDeclarationSourceValueAtlaskit_css(node) {
26
+ importStatement = {
27
+ node: node
28
+ };
29
+ var _iterator = _createForOfIteratorHelper(node.specifiers),
30
+ _step;
31
+ try {
32
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33
+ var specifier = _step.value;
34
+ if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cx') {
35
+ importStatement.cxFuncLocalName = specifier.local.name;
36
+ }
37
+ }
38
+ } catch (err) {
39
+ _iterator.e(err);
40
+ } finally {
41
+ _iterator.f();
42
+ }
43
+ },
44
+ 'ImportDeclaration[source.value="@atlaskit/primitives/compiled"]': function ImportDeclarationSourceValueAtlaskit_primitives_compiled(node) {
45
+ var _iterator2 = _createForOfIteratorHelper(node.specifiers),
46
+ _step2;
47
+ try {
48
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
49
+ var specifier = _step2.value;
50
+ primitiveNames.add(specifier.local.name);
51
+ }
52
+ } catch (err) {
53
+ _iterator2.e(err);
54
+ } finally {
55
+ _iterator2.f();
56
+ }
57
+ },
58
+ 'JSXAttribute > JSXIdentifier[name=/[xX]css$/]': function JSXAttribute__JSXIdentifierName_XXCss$_(node) {
59
+ var xcssValue = node.parent && isNodeOfType(node.parent, 'JSXAttribute') && node.parent.value && isNodeOfType(node.parent.value, 'JSXExpressionContainer') ? node.parent.value : undefined;
60
+ if (!xcssValue) {
61
+ return;
62
+ }
63
+ var jsxElementName = node.parent.parent && isNodeOfType(node.parent.parent, 'JSXOpeningElement') && node.parent.parent.name && isNodeOfType(node.parent.parent.name, 'JSXIdentifier') ? node.parent.parent.name.name : undefined;
64
+ if (!jsxElementName) {
65
+ return;
66
+ }
67
+ // check if this JSX element is from the primitives entry point and if prop value is an array
68
+ if (primitiveNames.has(jsxElementName) && xcssValue.expression.type === 'ArrayExpression') {
69
+ context.report({
70
+ node: xcssValue,
71
+ messageId: 'useCxFunc',
72
+ fix: function fix(fixer) {
73
+ var fixes = [];
74
+ var sourceCode = context.sourceCode;
75
+ var styles = sourceCode.getText(xcssValue.expression);
76
+ fixes.push(fixer.replaceText(xcssValue, (importStatement && importStatement.cxFuncLocalName ? "{".concat(importStatement.cxFuncLocalName) : "{cx") + "(".concat(styles.replace(/^\[/, '').replace(/\]$/, ''), ")}")));
77
+ if (!importStatement) {
78
+ fixes.push(fixer.insertTextBeforeRange([0, 0], "import { cx } from '@atlaskit/css';\n"));
79
+ } else if (!importStatement.cxFuncLocalName) {
80
+ var importText = sourceCode.getText(importStatement.node);
81
+ fixes.push(fixer.replaceText(importStatement.node, importText.includes('{') ? importText.replace(/import(.*) {\s?/, "import$1 { cx, ") : importText.replace(/ from /, ", { cx } from ")));
82
+ }
83
+ return fixes;
84
+ }
85
+ });
86
+ }
87
+ }
88
+ };
89
+ }
90
+ });
91
+ export default rule;
@@ -31,6 +31,7 @@ var rule = createLintRule({
31
31
  }
32
32
  },
33
33
  create: function create(context) {
34
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
34
35
  var config = getConfig(context.options[0]);
35
36
  return errorBoundary({
36
37
  // transforms <h1>...</h1> usages
@@ -40,6 +40,7 @@ var rule = createLintRule({
40
40
  }
41
41
  },
42
42
  create: function create(context) {
43
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
43
44
  var config = getConfig(context.options[0]);
44
45
  return errorBoundary({
45
46
  'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__IdentifierName_FontSizeLineHeightFontWeightLetterSpacing_(node) {
@@ -68,7 +68,7 @@ var rule = createLintRule({
68
68
  return;
69
69
  }
70
70
  var name = node.openingElement.name.name;
71
- if (name !== defaultImportLocalName) {
71
+ if (![defaultImportLocalName, modalHeaderLocalName].includes(name)) {
72
72
  return;
73
73
  }
74
74
  var modalHeaderNode = null;
@@ -132,13 +132,31 @@ var rule = createLintRule({
132
132
  _iterator.f();
133
133
  }
134
134
  };
135
- searchNode(node);
135
+ if (name === defaultImportLocalName) {
136
+ searchNode(node);
137
+
138
+ // If there is a close button, skip the rest, as this satisfies the
139
+ // rule. If there is a modal header, it will be recognized in later
140
+ // scans, so don't add duplicate errors
141
+ if (closeButtonNode || modalHeaderNode) {
142
+ return;
143
+ // No close button or modal header exists
144
+ } else {
145
+ return context.report({
146
+ node: node,
147
+ messageId: 'noCloseButtonExists'
148
+ });
149
+ }
150
+ } else if (name === modalHeaderLocalName) {
151
+ modalHeaderNode = node;
152
+ searchNode(node);
153
+
154
+ // If there is a close button, skip the rest, as this satisfies the rule.
155
+ if (closeButtonNode) {
156
+ return;
157
+ }
136
158
 
137
- // If there is a close button, skip the rest, as this satisfies the rule.
138
- if (closeButtonNode) {
139
- return;
140
159
  // No close button exists, so check the modal header
141
- } else if (modalHeaderNode !== null) {
142
160
  var prop = JSXElementHelper.getAttributeByName(modalHeaderNode, PROP_NAME);
143
161
 
144
162
  // If the prop exists
@@ -171,12 +189,6 @@ var rule = createLintRule({
171
189
  }]
172
190
  });
173
191
  }
174
- // No close button or modal header exists
175
- } else {
176
- return context.report({
177
- node: node,
178
- messageId: 'noCloseButtonExists'
179
- });
180
192
  }
181
193
  }
182
194
  };
@@ -32,6 +32,7 @@ var rule = createLintRule({
32
32
  }
33
33
  },
34
34
  create: function create(context) {
35
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
35
36
  var config = getConfig(context.options[0]);
36
37
  return {
37
38
  // transforms styled.<html>(...) usages
@@ -47,6 +47,7 @@ var rule = createLintRule({
47
47
  }
48
48
  },
49
49
  create: function create(context) {
50
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
50
51
  var config = getConfig(context.options[0]);
51
52
  return errorBoundary({
52
53
  'JSXElement[openingElement.name.name=span]': function JSXElementOpeningElementNameNameSpan(node) {
@@ -8,6 +8,7 @@ import { RestrictedCapitalisation } from './transformers/restricted-capitalisati
8
8
  import { StyleObject } from './transformers/style-object';
9
9
  import { UntokenizedProperties } from './transformers/untokenized-properties';
10
10
  var create = function create(context) {
11
+ // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
11
12
  var config = getConfig(context.options[0]);
12
13
  return errorBoundary({
13
14
  // const styles = css({ fontSize: '14px', ... }), styled.div({ fontSize: 14, ... })
@@ -47,6 +47,7 @@ export declare const plugin: {
47
47
  'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
48
48
  'prefer-primitives': import("eslint").Rule.RuleModule;
49
49
  'use-button-group-label': import("eslint").Rule.RuleModule;
50
+ 'use-cx-function-in-xcss': import("eslint").Rule.RuleModule;
50
51
  'use-datetime-picker-calendar-button': import("eslint").Rule.RuleModule;
51
52
  'use-drawer-label': import("eslint").Rule.RuleModule;
52
53
  'use-heading': import("eslint").Rule.RuleModule;
@@ -100,6 +101,7 @@ export declare const plugin: {
100
101
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
101
102
  '@atlaskit/design-system/prefer-primitives': "warn";
102
103
  '@atlaskit/design-system/use-button-group-label': "warn";
104
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
103
105
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
104
106
  '@atlaskit/design-system/use-drawer-label': "warn";
105
107
  '@atlaskit/design-system/use-heading': "warn";
@@ -155,6 +157,7 @@ export declare const plugin: {
155
157
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
156
158
  '@atlaskit/design-system/prefer-primitives': "warn";
157
159
  '@atlaskit/design-system/use-button-group-label': "warn";
160
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
158
161
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
159
162
  '@atlaskit/design-system/use-drawer-label': "warn";
160
163
  '@atlaskit/design-system/use-heading': "warn";
@@ -197,6 +200,7 @@ export declare const plugin: {
197
200
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
198
201
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
199
202
  '@atlaskit/design-system/use-button-group-label': "warn";
203
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
200
204
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
201
205
  '@atlaskit/design-system/use-drawer-label': "warn";
202
206
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -236,6 +240,7 @@ export declare const plugin: {
236
240
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
237
241
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
238
242
  '@atlaskit/design-system/use-button-group-label': "warn";
243
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
239
244
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
240
245
  '@atlaskit/design-system/use-drawer-label': "warn";
241
246
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -287,6 +292,7 @@ declare const configs: {
287
292
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
288
293
  '@atlaskit/design-system/prefer-primitives': "warn";
289
294
  '@atlaskit/design-system/use-button-group-label': "warn";
295
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
290
296
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
291
297
  '@atlaskit/design-system/use-drawer-label': "warn";
292
298
  '@atlaskit/design-system/use-heading': "warn";
@@ -342,6 +348,7 @@ declare const configs: {
342
348
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
343
349
  '@atlaskit/design-system/prefer-primitives': "warn";
344
350
  '@atlaskit/design-system/use-button-group-label': "warn";
351
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
345
352
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
346
353
  '@atlaskit/design-system/use-drawer-label': "warn";
347
354
  '@atlaskit/design-system/use-heading': "warn";
@@ -384,6 +391,7 @@ declare const configs: {
384
391
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
385
392
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
386
393
  '@atlaskit/design-system/use-button-group-label': "warn";
394
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
387
395
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
388
396
  '@atlaskit/design-system/use-drawer-label': "warn";
389
397
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -423,6 +431,7 @@ declare const configs: {
423
431
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
424
432
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
425
433
  '@atlaskit/design-system/use-button-group-label': "warn";
434
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
426
435
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
427
436
  '@atlaskit/design-system/use-drawer-label': "warn";
428
437
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -32,6 +32,7 @@ declare const _default: {
32
32
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
33
33
  '@atlaskit/design-system/prefer-primitives': "warn";
34
34
  '@atlaskit/design-system/use-button-group-label': "warn";
35
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
35
36
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
36
37
  '@atlaskit/design-system/use-drawer-label': "warn";
37
38
  '@atlaskit/design-system/use-heading': "warn";
@@ -32,6 +32,7 @@ declare const _default: {
32
32
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
33
33
  '@atlaskit/design-system/prefer-primitives': "warn";
34
34
  '@atlaskit/design-system/use-button-group-label': "warn";
35
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
35
36
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
36
37
  '@atlaskit/design-system/use-drawer-label': "warn";
37
38
  '@atlaskit/design-system/use-heading': "warn";
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
22
22
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
23
23
  '@atlaskit/design-system/use-button-group-label': "warn";
24
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
24
25
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
25
26
  '@atlaskit/design-system/use-drawer-label': "warn";
26
27
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  '@atlaskit/design-system/no-unsafe-style-overrides': "warn";
22
22
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
23
23
  '@atlaskit/design-system/use-button-group-label': "warn";
24
+ '@atlaskit/design-system/use-cx-function-in-xcss': "error";
24
25
  '@atlaskit/design-system/use-datetime-picker-calendar-button': "warn";
25
26
  '@atlaskit/design-system/use-drawer-label': "warn";
26
27
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': "warn";
@@ -31,6 +31,7 @@ export declare const rules: {
31
31
  'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
32
32
  'prefer-primitives': import("eslint").Rule.RuleModule;
33
33
  'use-button-group-label': import("eslint").Rule.RuleModule;
34
+ 'use-cx-function-in-xcss': import("eslint").Rule.RuleModule;
34
35
  'use-datetime-picker-calendar-button': import("eslint").Rule.RuleModule;
35
36
  'use-drawer-label': import("eslint").Rule.RuleModule;
36
37
  'use-heading': import("eslint").Rule.RuleModule;
@@ -96,7 +96,7 @@ export declare const createAutoMigrationError: ({ node, importSource, iconName,
96
96
  spacing?: string | undefined;
97
97
  insideNewButton?: boolean | undefined;
98
98
  }) => void;
99
- export declare const createHelpers: (context: Rule.RuleContext) => {
99
+ export declare const createHelpers: (ctx: Rule.RuleContext) => {
100
100
  /**
101
101
  * Extracts the primaryColor value from a JSXAttribute
102
102
  */
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;