@atlaskit/eslint-plugin-ui-styling-standard 1.4.5 → 1.5.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 (49) hide show
  1. package/CHANGELOG.md +18 -5
  2. package/README.md +1 -0
  3. package/dist/cjs/index.codegen.js +3 -3
  4. package/dist/cjs/presets/all-flat.codegen.js +6 -3
  5. package/dist/cjs/presets/all.codegen.js +6 -3
  6. package/dist/cjs/presets/recommended-flat.codegen.js +6 -3
  7. package/dist/cjs/presets/recommended.codegen.js +6 -3
  8. package/dist/cjs/rules/index.codegen.js +3 -1
  9. package/dist/cjs/rules/no-important-styles/index.js +95 -28
  10. package/dist/cjs/rules/no-unsafe-selectors/index.js +1 -1
  11. package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +1 -1
  12. package/dist/cjs/rules/no-unused-cssmap-properties/index.js +192 -0
  13. package/dist/es2019/index.codegen.js +4 -5
  14. package/dist/es2019/presets/all-flat.codegen.js +6 -3
  15. package/dist/es2019/presets/all.codegen.js +6 -3
  16. package/dist/es2019/presets/recommended-flat.codegen.js +6 -3
  17. package/dist/es2019/presets/recommended.codegen.js +6 -3
  18. package/dist/es2019/rules/index.codegen.js +4 -1
  19. package/dist/es2019/rules/no-important-styles/index.js +65 -13
  20. package/dist/es2019/rules/no-unsafe-selectors/index.js +1 -1
  21. package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +1 -1
  22. package/dist/es2019/rules/no-unused-cssmap-properties/index.js +182 -0
  23. package/dist/esm/index.codegen.js +4 -4
  24. package/dist/esm/presets/all-flat.codegen.js +6 -3
  25. package/dist/esm/presets/all.codegen.js +6 -3
  26. package/dist/esm/presets/recommended-flat.codegen.js +6 -3
  27. package/dist/esm/presets/recommended.codegen.js +6 -3
  28. package/dist/esm/rules/index.codegen.js +4 -1
  29. package/dist/esm/rules/no-important-styles/index.js +95 -27
  30. package/dist/esm/rules/no-unsafe-selectors/index.js +1 -1
  31. package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +1 -1
  32. package/dist/esm/rules/no-unused-cssmap-properties/index.js +186 -0
  33. package/dist/types/index.codegen.d.ts +9 -718
  34. package/dist/types/presets/all-flat.codegen.d.ts +4 -40
  35. package/dist/types/presets/all.codegen.d.ts +4 -37
  36. package/dist/types/presets/recommended-flat.codegen.d.ts +4 -40
  37. package/dist/types/presets/recommended.codegen.d.ts +4 -37
  38. package/dist/types/rules/index.codegen.d.ts +7 -19
  39. package/dist/types/rules/no-unused-cssmap-properties/index.d.ts +3 -0
  40. package/dist/types/rules/utils/create-rule.d.ts +3 -1
  41. package/dist/types-ts4.5/index.codegen.d.ts +9 -1078
  42. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +4 -61
  43. package/dist/types-ts4.5/presets/all.codegen.d.ts +4 -61
  44. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +4 -61
  45. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +4 -61
  46. package/dist/types-ts4.5/rules/index.codegen.d.ts +7 -19
  47. package/dist/types-ts4.5/rules/no-unused-cssmap-properties/index.d.ts +3 -0
  48. package/dist/types-ts4.5/rules/utils/create-rule.d.ts +3 -1
  49. package/package.json +3 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d2b1c5a27d84a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2b1c5a27d84a) -
8
+ Fix two bugs in the no-unused-cssmap-properties rule:
9
+ - Use getDeclaredVariables() instead of scope-based lookup to properly track references across
10
+ nested scopes
11
+ - Fix isExported false positive by only checking direct export patterns instead of walking full
12
+ parent tree
13
+
14
+ ## 1.4.6
15
+
16
+ ### Patch Changes
17
+
18
+ - [`a60a82196851a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a60a82196851a) -
19
+ Internal refactors to remove unused variables. No functional or public changes.
20
+
3
21
  ## 1.4.5
4
22
 
5
23
  ### Patch Changes
@@ -352,7 +370,6 @@
352
370
  - [#99544](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99544)
353
371
  [`391edf6de450`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/391edf6de450) -
354
372
  Added `no-global-styles` rule which prevents:
355
-
356
373
  - The `Global` API from `@emotion`
357
374
  - The `createGlobalStyle` and `injectGlobal` APIs from `styled-components`
358
375
  - `<style>` elements in JSX
@@ -537,7 +554,6 @@
537
554
  functions will no longer be required to end with "Styles".
538
555
 
539
556
  [BREAKING] Some rule options have been changed:
540
-
541
557
  - `fixNamesOnly` and `autoFixNames` have been removed, as there is no longer an autofixer that
542
558
  enforces variable names.
543
559
  - If you use `fixNamesOnly: true`, we recommend switching to using `autoFix: false`.
@@ -634,7 +650,6 @@
634
650
  - [#74981](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74981)
635
651
  [`842300de03a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/842300de03a1) -
636
652
  Add the following rules:
637
-
638
653
  - `consistent-css-prop-usage`: Ensures consistency with `css` and `xcss` prop usages
639
654
  - `no-empty-styled-expression`: Forbids any styled expression to be used when passing empty
640
655
  arguments to styled.div() (or other JSX elements).
@@ -645,7 +660,6 @@
645
660
  - [#72983](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72983)
646
661
  [`878065bfc4c0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/878065bfc4c0) -
647
662
  Adds the following rules to the recommended preset:
648
-
649
663
  - `@atlaskit/design-system/no-css-tagged-template-expression`
650
664
  - `@atlaskit/design-system/no-keyframes-tagged-template-expression`
651
665
  - `@atlaskit/design-system/no-styled-tagged-template-expression`
@@ -671,7 +685,6 @@
671
685
  - [#69723](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69723)
672
686
  [`06cd0f04fefb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06cd0f04fefb) -
673
687
  Adds the following rules to the recommended config:
674
-
675
688
  - `local-cx-xcss` - Ensures the `cx()` function is only used within the `xcss` prop
676
689
  - `no-supress-xcss` - Disallows supressing type violations when using the `xcss` prop
677
690
  - `no-js-xcss` - Disallows using `xcss` prop inside JavaScript files
package/README.md CHANGED
@@ -58,6 +58,7 @@ module.exports = {
58
58
  | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-styled/README.md">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
59
59
  | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-unsafe-selectors/README.md">no-unsafe-selectors</a> | Disallows use of nested styles in `css` functions. | Yes | Yes | Yes |
60
60
  | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-unsafe-values/README.md">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
61
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-unused-cssmap-properties/README.md">no-unused-cssmap-properties</a> | Detects unused properties in cssMap style objects that are not exported. Helps maintain clean code by identifying style variants that are defined but never used. | Yes | | |
61
62
  | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/use-compiled/README.md">use-compiled</a> | Ensures usage of `@compiled/react` or `@atlaskit/css` instead of other CSS-in-JS libraries | Yes | Yes | |
62
63
  | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
63
64
  | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
@@ -20,7 +20,7 @@ var _index = require("./rules/index.codegen");
20
20
  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; }
21
21
  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; } /**
22
22
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
23
- * @codegen <<SignedSource::0b2a9d2f41301e40371dbce6d69039df>>
23
+ * @codegen <<SignedSource::93c84481278f52fc66ecbba80094e6e5>>
24
24
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
25
25
  */
26
26
  // this uses require because not all node versions this package supports use the same import assertions/attributes
@@ -56,6 +56,6 @@ var plugin = exports.plugin = {
56
56
  })
57
57
  }
58
58
  };
59
- var configs = exports.configs = plugin.configs,
60
- meta = exports.meta = plugin.meta;
59
+ var configs = exports.configs = plugin.configs;
60
+ var meta = exports.meta = plugin.meta;
61
61
  var _default = exports.default = plugin;
@@ -9,10 +9,11 @@ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/esli
9
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
10
  /**
11
11
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
12
- * @codegen <<SignedSource::4595bc1a07f9da4186e2df84cea56831>>
12
+ * @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
13
13
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
14
14
  */
15
- var _default = exports.default = {
15
+
16
+ var config = {
16
17
  plugins: {
17
18
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
18
19
  '@atlaskit/design-system': atlaskitDesignSystemPlugin
@@ -34,6 +35,7 @@ var _default = exports.default = {
34
35
  '@atlaskit/ui-styling-standard/no-styled': 'error',
35
36
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
36
37
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
38
+ '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
37
39
  '@atlaskit/ui-styling-standard/use-compiled': 'error',
38
40
  '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
39
41
  excludeReactComponents: true,
@@ -49,4 +51,5 @@ var _default = exports.default = {
49
51
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
50
52
  }]
51
53
  }
52
- };
54
+ };
55
+ var _default = exports.default = config;
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::884e28457d7860b1abca070fca8ab853>>
9
+ * @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var config = {
13
14
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
14
15
  rules: {
15
16
  '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
@@ -28,6 +29,7 @@ var _default = exports.default = {
28
29
  '@atlaskit/ui-styling-standard/no-styled': 'error',
29
30
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
30
31
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
32
+ '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
31
33
  '@atlaskit/ui-styling-standard/use-compiled': 'error',
32
34
  '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
33
35
  excludeReactComponents: true,
@@ -43,4 +45,5 @@ var _default = exports.default = {
43
45
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
44
46
  }]
45
47
  }
46
- };
48
+ };
49
+ var _default = exports.default = config;
@@ -9,10 +9,11 @@ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/esli
9
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
10
  /**
11
11
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
12
- * @codegen <<SignedSource::4595bc1a07f9da4186e2df84cea56831>>
12
+ * @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
13
13
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
14
14
  */
15
- var _default = exports.default = {
15
+
16
+ var config = {
16
17
  plugins: {
17
18
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
18
19
  '@atlaskit/design-system': atlaskitDesignSystemPlugin
@@ -34,6 +35,7 @@ var _default = exports.default = {
34
35
  '@atlaskit/ui-styling-standard/no-styled': 'error',
35
36
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
36
37
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
38
+ '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
37
39
  '@atlaskit/ui-styling-standard/use-compiled': 'error',
38
40
  '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
39
41
  excludeReactComponents: true,
@@ -49,4 +51,5 @@ var _default = exports.default = {
49
51
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
50
52
  }]
51
53
  }
52
- };
54
+ };
55
+ var _default = exports.default = config;
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::884e28457d7860b1abca070fca8ab853>>
9
+ * @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var config = {
13
14
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
14
15
  rules: {
15
16
  '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
@@ -28,6 +29,7 @@ var _default = exports.default = {
28
29
  '@atlaskit/ui-styling-standard/no-styled': 'error',
29
30
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
30
31
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
32
+ '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
31
33
  '@atlaskit/ui-styling-standard/use-compiled': 'error',
32
34
  '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
33
35
  excludeReactComponents: true,
@@ -43,4 +45,5 @@ var _default = exports.default = {
43
45
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
44
46
  }]
45
47
  }
46
- };
48
+ };
49
+ var _default = exports.default = config;
@@ -21,10 +21,11 @@ var _noNestedSelectors = _interopRequireDefault(require("./no-nested-selectors")
21
21
  var _noStyled = _interopRequireDefault(require("./no-styled"));
22
22
  var _noUnsafeSelectors = _interopRequireDefault(require("./no-unsafe-selectors"));
23
23
  var _noUnsafeValues = _interopRequireDefault(require("./no-unsafe-values"));
24
+ var _noUnusedCssmapProperties = _interopRequireDefault(require("./no-unused-cssmap-properties"));
24
25
  var _useCompiled = _interopRequireDefault(require("./use-compiled"));
25
26
  /**
26
27
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
27
- * @codegen <<SignedSource::71ba23a2a1467988c4fae8c2756447f9>>
28
+ * @codegen <<SignedSource::2eab912b0c44d0fcbdc2f0b79cb42fa9>>
28
29
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
29
30
  */
30
31
 
@@ -45,5 +46,6 @@ var rules = exports.rules = {
45
46
  'no-styled': _noStyled.default,
46
47
  'no-unsafe-selectors': _noUnsafeSelectors.default,
47
48
  'no-unsafe-values': _noUnsafeValues.default,
49
+ 'no-unused-cssmap-properties': _noUnusedCssmapProperties.default,
48
50
  'use-compiled': _useCompiled.default
49
51
  };
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.rule = exports.default = void 0;
8
- var _esquery = _interopRequireDefault(require("esquery"));
9
7
  var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
10
8
  var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
11
9
  var _schema = require("@atlaskit/eslint-utils/schema");
@@ -41,42 +39,111 @@ var rule = exports.rule = (0, _createRuleWithTypedConfig.createLintRuleWithTyped
41
39
  if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
42
40
  return;
43
41
  }
44
- var matches = (0, _esquery.default)(node, 'Property');
45
- var _iterator = _createForOfIteratorHelper(matches),
46
- _step;
47
- try {
48
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
49
- var match = _step.value;
50
- if (match.type !== 'Property') {
51
- return;
52
- }
53
- if (isImportant(match.value)) {
54
- context.report({
55
- node: match.value,
56
- messageId: 'no-important-styles'
57
- });
58
- }
42
+ walkProperties(node, function (propertyNode) {
43
+ if (isImportant(propertyNode.value)) {
44
+ context.report({
45
+ node: propertyNode.value,
46
+ messageId: 'no-important-styles'
47
+ });
59
48
  }
60
- } catch (err) {
61
- _iterator.e(err);
62
- } finally {
63
- _iterator.f();
64
- }
49
+ });
65
50
  }
66
51
  };
67
52
  }
68
53
  });
69
54
  var _default = exports.default = rule;
70
- var importantRegex = /!\s*important\s*$/;
55
+ var IMPORTANT_SUFFIX_REGEX = /!\s*important\s*$/;
56
+
57
+ /**
58
+ * Walk through all Property nodes in the AST tree recursively.
59
+ * This is faster than esquery for this specific use case as it avoids
60
+ * selector compilation and executes a simple depth-first traversal.
61
+ */
62
+ function walkProperties(node, callback) {
63
+ var _node$arguments;
64
+ if (node.type === 'Property' && node.value) {
65
+ callback(node);
66
+ }
67
+
68
+ // Iterate through object properties
69
+ if ((_node$arguments = node.arguments) !== null && _node$arguments !== void 0 && _node$arguments.length) {
70
+ var _iterator = _createForOfIteratorHelper(node.arguments),
71
+ _step;
72
+ try {
73
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
74
+ var arg = _step.value;
75
+ if (arg.type === 'ObjectExpression' && arg.properties) {
76
+ var _iterator2 = _createForOfIteratorHelper(arg.properties),
77
+ _step2;
78
+ try {
79
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
80
+ var prop = _step2.value;
81
+ walkObjectProperty(prop, callback);
82
+ }
83
+ } catch (err) {
84
+ _iterator2.e(err);
85
+ } finally {
86
+ _iterator2.f();
87
+ }
88
+ }
89
+ }
90
+ } catch (err) {
91
+ _iterator.e(err);
92
+ } finally {
93
+ _iterator.f();
94
+ }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Recursively walk object properties to find nested Property nodes.
100
+ */
101
+ function walkObjectProperty(node, callback) {
102
+ if (node.type === 'Property') {
103
+ var _node$value;
104
+ callback(node);
105
+ // Recursively check nested objects
106
+ if (((_node$value = node.value) === null || _node$value === void 0 ? void 0 : _node$value.type) === 'ObjectExpression' && node.value.properties) {
107
+ var _iterator3 = _createForOfIteratorHelper(node.value.properties),
108
+ _step3;
109
+ try {
110
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
111
+ var prop = _step3.value;
112
+ walkObjectProperty(prop, callback);
113
+ }
114
+ } catch (err) {
115
+ _iterator3.e(err);
116
+ } finally {
117
+ _iterator3.f();
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Check if a value contains !important flag.
125
+ * Uses fast string checks before regex to avoid regex overhead for common cases.
126
+ */
71
127
  function isImportant(node) {
72
128
  if (node.type === 'Literal') {
73
- return typeof node.value === 'string' && importantRegex.test(node.value);
129
+ if (typeof node.value !== 'string') {
130
+ return false;
131
+ }
132
+ // Fast check: string must end with 'important' (after optional whitespace)
133
+ var len = node.value.length;
134
+ if (len < 10) {
135
+ return false;
136
+ } // "!important" is 10 chars minimum
137
+ return IMPORTANT_SUFFIX_REGEX.test(node.value);
74
138
  }
75
139
  if (node.type === 'TemplateLiteral') {
76
- var joinedRaw = node.quasis.map(function (element) {
77
- return element.value.raw;
78
- }).join('');
79
- return importantRegex.test(joinedRaw);
140
+ var _node$quasis;
141
+ if (!((_node$quasis = node.quasis) !== null && _node$quasis !== void 0 && _node$quasis.length)) {
142
+ return false;
143
+ }
144
+ // Only check the last quasi's raw value (most likely to contain the !important)
145
+ var lastQuasi = node.quasis[node.quasis.length - 1];
146
+ return IMPORTANT_SUFFIX_REGEX.test(lastQuasi.value.raw);
80
147
  }
81
148
  return false;
82
149
  }
@@ -137,7 +137,7 @@ var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
137
137
  isXcssCall: isXcssCall
138
138
  });
139
139
  });
140
- } catch (e) {
140
+ } catch (_unused) {
141
141
  context.report({
142
142
  node: key,
143
143
  messageId: 'no-unparsable-selectors',
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.lintSelector = lintSelector;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
- var _constants = require("./constants");
11
10
  var _postcssSelectorParser = require("postcss-selector-parser");
11
+ var _constants = require("./constants");
12
12
  var _sourcePositionUtils = require("./source-position-utils");
13
13
  function lintSelector(args) {
14
14
  checkNoAmbiguousPseudos(args);
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.rule = exports.default = void 0;
7
+ var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
8
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
9
+ var _createRule = require("../utils/create-rule");
10
+ var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
11
+
12
+ /**
13
+ * Gets the key name from a property node
14
+ */
15
+ function getPropertyKeyName(property) {
16
+ if (property.key.type === 'Identifier') {
17
+ return property.key.name;
18
+ }
19
+ if (property.key.type === 'Literal' && typeof property.key.value === 'string') {
20
+ return property.key.value;
21
+ }
22
+ return null;
23
+ }
24
+
25
+ /**
26
+ * Checks if a variable is exported from the module
27
+ */
28
+ function isExported(node, context) {
29
+ var parent = node.parent;
30
+
31
+ // Walk up to find VariableDeclaration
32
+ while (parent && parent.type !== 'VariableDeclaration') {
33
+ parent = parent.parent;
34
+ }
35
+ if (!parent) {
36
+ return false;
37
+ }
38
+
39
+ // Check if the VariableDeclaration is an ExportNamedDeclaration
40
+ var grandParent = parent.parent;
41
+ if (grandParent && grandParent.type === 'ExportNamedDeclaration') {
42
+ return true;
43
+ }
44
+
45
+ // Check if the variable is exported elsewhere in the file via `export { styles }`
46
+ if (node.id.type === 'Identifier') {
47
+ var scope = (0, _contextCompat.getScope)(context, node);
48
+ var variableName = node.id.name;
49
+ var variable = scope.variables.find(function (v) {
50
+ return v.name === variableName;
51
+ });
52
+ if (variable) {
53
+ // Check if any reference is a direct export specifier (e.g., `export { styles }`)
54
+ return variable.references.some(function (ref) {
55
+ var refParent = ref.identifier.parent;
56
+ // Check for direct export: `export { styles }` or `export { styles as something }`
57
+ // In this case, the identifier's parent is an ExportSpecifier
58
+ if (refParent && refParent.type === 'ExportSpecifier') {
59
+ return true;
60
+ }
61
+ // Check for default export: `export default styles`
62
+ if (refParent && refParent.type === 'ExportDefaultDeclaration') {
63
+ return true;
64
+ }
65
+ return false;
66
+ });
67
+ }
68
+ }
69
+ return false;
70
+ }
71
+ var rule = exports.rule = (0, _createRule.createLintRule)({
72
+ meta: {
73
+ name: 'no-unused-cssmap-properties',
74
+ docs: {
75
+ description: 'Detects unused properties in cssMap style objects that are not exported. Helps maintain clean code by identifying style variants that are defined but never used.',
76
+ recommended: true,
77
+ severity: 'warn'
78
+ },
79
+ messages: {
80
+ 'unused-property': 'The "{{propertyName}}" style is defined but never used.'
81
+ },
82
+ type: 'problem'
83
+ },
84
+ create: function create(context) {
85
+ return {
86
+ VariableDeclarator: function VariableDeclarator(node) {
87
+ var _getSourceCode$scopeM;
88
+ if (node.type !== 'VariableDeclarator') {
89
+ return;
90
+ }
91
+
92
+ // Only process if the initializer is a cssMap call
93
+ if (!node.init || node.init.type !== 'CallExpression' || !(0, _isSupportedImport.isCssMap)(node.init.callee, (0, _contextCompat.getScope)(context, node).references, IMPORT_SOURCES)) {
94
+ return;
95
+ }
96
+
97
+ // Skip if the cssMap is exported
98
+ if (isExported(node, context)) {
99
+ return;
100
+ }
101
+
102
+ // Get the cssMap argument (should be an object expression)
103
+ var cssMapArg = node.init.arguments[0];
104
+ if (!cssMapArg || cssMapArg.type !== 'ObjectExpression') {
105
+ return;
106
+ }
107
+
108
+ // Get the variable name
109
+ if (node.id.type !== 'Identifier') {
110
+ return;
111
+ }
112
+ var variableName = node.id.name;
113
+
114
+ // Use getDeclaredVariables to get the variable with all its references
115
+ // across all scopes (including nested function components)
116
+ var declaredVariables = (_getSourceCode$scopeM = (0, _contextCompat.getSourceCode)(context).scopeManager) === null || _getSourceCode$scopeM === void 0 ? void 0 : _getSourceCode$scopeM.getDeclaredVariables(node);
117
+ var variable = declaredVariables === null || declaredVariables === void 0 ? void 0 : declaredVariables.find(function (v) {
118
+ return v.name === variableName;
119
+ });
120
+ if (!variable) {
121
+ return;
122
+ }
123
+
124
+ // Track which properties are defined
125
+ var definedProperties = new Set();
126
+ cssMapArg.properties.forEach(function (prop) {
127
+ if (prop.type === 'Property') {
128
+ var keyName = getPropertyKeyName(prop);
129
+ if (keyName) {
130
+ definedProperties.add(keyName);
131
+ }
132
+ }
133
+ });
134
+
135
+ // Track which properties are used
136
+ var usedProperties = new Set();
137
+ var hasNonPropertyAccess = false;
138
+ variable.references.forEach(function (reference) {
139
+ // Skip the declaration itself
140
+ if (reference.init) {
141
+ return;
142
+ }
143
+ var identifier = reference.identifier;
144
+ var parent = identifier.parent;
145
+
146
+ // Check if it's a member access (e.g., styles.root)
147
+ if (parent && parent.type === 'MemberExpression' && parent.object === identifier) {
148
+ // Check if it's computed (dynamic) property access like styles[dynamicKey]
149
+ if (parent.computed) {
150
+ // Dynamic access - we can't determine which properties are used
151
+ hasNonPropertyAccess = true;
152
+ return;
153
+ }
154
+
155
+ // Static property access
156
+ if (parent.property.type === 'Identifier') {
157
+ usedProperties.add(parent.property.name);
158
+ } else if (parent.property.type === 'Literal' && typeof parent.property.value === 'string') {
159
+ usedProperties.add(parent.property.value);
160
+ }
161
+ } else {
162
+ // The cssMap object is used as a whole (e.g., spread, passed to function, etc.)
163
+ // In this case, we can't determine which properties are used, so mark all as used
164
+ hasNonPropertyAccess = true;
165
+ }
166
+ });
167
+
168
+ // If the object is used as a whole (not just property access), skip checks
169
+ if (hasNonPropertyAccess) {
170
+ return;
171
+ }
172
+
173
+ // Report unused properties
174
+ cssMapArg.properties.forEach(function (prop) {
175
+ if (prop.type === 'Property') {
176
+ var keyName = getPropertyKeyName(prop);
177
+ if (keyName && !usedProperties.has(keyName)) {
178
+ context.report({
179
+ node: prop.key,
180
+ messageId: 'unused-property',
181
+ data: {
182
+ propertyName: keyName
183
+ }
184
+ });
185
+ }
186
+ }
187
+ });
188
+ }
189
+ };
190
+ }
191
+ });
192
+ var _default = exports.default = rule;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::0b2a9d2f41301e40371dbce6d69039df>>
3
+ * @codegen <<SignedSource::93c84481278f52fc66ecbba80094e6e5>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
+
6
7
  import allFlat from './presets/all-flat.codegen';
7
8
  import all from './presets/all.codegen';
8
9
  import recommendedFlat from './presets/recommended-flat.codegen';
@@ -49,8 +50,6 @@ export const plugin = {
49
50
  }
50
51
  };
51
52
  export { rules } from './rules/index.codegen';
52
- export const {
53
- configs,
54
- meta
55
- } = plugin;
53
+ export const configs = plugin.configs;
54
+ export const meta = plugin.meta;
56
55
  export default plugin;
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::4595bc1a07f9da4186e2df84cea56831>>
3
+ * @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
+
6
7
  import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
7
- export default {
8
+ const config = {
8
9
  plugins: {
9
10
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
10
11
  '@atlaskit/design-system': atlaskitDesignSystemPlugin
@@ -26,6 +27,7 @@ export default {
26
27
  '@atlaskit/ui-styling-standard/no-styled': 'error',
27
28
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
28
29
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
30
+ '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
29
31
  '@atlaskit/ui-styling-standard/use-compiled': 'error',
30
32
  '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
31
33
  excludeReactComponents: true,
@@ -41,4 +43,5 @@ export default {
41
43
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
42
44
  }]
43
45
  }
44
- };
46
+ };
47
+ export default config;