@atlaskit/eslint-plugin-ui-styling-standard 3.0.4 → 3.0.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 3.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f7d67770416b8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f7d67770416b8) -
8
+ `no-container-queries` collects container names with a `Property` visitor instead of walking the
9
+ whole file again with estraverse.
10
+
3
11
  ## 3.0.4
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -40,33 +40,33 @@ module.exports = {
40
40
  <!-- START_RULE_TABLE_CODEGEN -->
41
41
  <!-- @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
42
42
 
43
- | Rule | Description | Recommended | Fixable | Suggestions |
44
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
45
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/atlaskit-theme/README.md">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | | | |
46
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/convert-props-syntax/README.md">convert-props-syntax</a> | Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries. | Yes | Yes | |
47
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/enforce-style-prop/README.md">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
48
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
49
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-array-arguments/README.md">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
50
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-atlaskit-theme/README.md">no-atlaskit-theme</a> | Disallow imports from `@atlaskit/theme` | Yes | | |
51
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
52
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
53
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
54
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-exported-styles/README.md">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
55
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-global-styles/README.md">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
56
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
57
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-imported-style-values/README.md">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
58
- | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
59
- | <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 | | |
60
- | <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 |
61
- | <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 | | |
62
- | <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 | | |
63
- | <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 | |
64
- | <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 | |
65
- | <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 | |
66
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
67
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
68
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
69
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-invalid-css-map/usage">@atlaskit/design-system/no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
70
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-map-scoped/usage">@atlaskit/design-system/no-css-map-scoped</a> | Disallows usage of the experimental `cssMapScoped` API from `@compiled/react`. This API is internal and is not part of the public Compiled CSS-in-JS interface. | Yes | | |
43
+ | Rule | Description | Recommended | Fixable | Suggestions |
44
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
45
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/atlaskit-theme/README.md">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | | | |
46
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/convert-props-syntax/README.md">convert-props-syntax</a> | Convert props syntax that is unsupported by `styled-components@<4` or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries. | Yes | Yes | |
47
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/enforce-style-prop/README.md">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
48
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
49
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-array-arguments/README.md">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
50
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-atlaskit-theme/README.md">no-atlaskit-theme</a> | Disallow imports from `@atlaskit/theme` | Yes | | |
51
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
52
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
53
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
54
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-exported-styles/README.md">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
55
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-global-styles/README.md">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
56
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
57
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-imported-style-values/README.md">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
58
+ | <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
59
+ | <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 | | |
60
+ | <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 |
61
+ | <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 | | |
62
+ | <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 | | |
63
+ | <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 | |
64
+ | <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 | |
65
+ | <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 | |
66
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
67
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
68
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
69
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-invalid-css-map/usage">@atlaskit/design-system/no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
70
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-map-scoped/usage">@atlaskit/design-system/no-css-map-scoped</a> | Disallows usage of the experimental `cssMapScoped` API from `@compiled/react`. This API is internal and is not part of the public Compiled CSS-in-JS interface. | Yes | | |
71
71
 
72
72
  <!-- END_RULE_TABLE_CODEGEN -->
@@ -373,7 +373,7 @@ var rule = (0, _createRule.createLintRule)({
373
373
  meta: {
374
374
  name: 'convert-props-syntax',
375
375
  docs: {
376
- description: 'Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
376
+ description: 'Convert props syntax that is unsupported by `styled-components@<4` or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
377
377
  recommended: true,
378
378
  severity: 'error'
379
379
  },
@@ -128,29 +128,28 @@ var rule = (0, _createRule.createLintRule)({
128
128
  create: function create(context) {
129
129
  var importSources = (0, _isSupportedImport.getImportSources)(context);
130
130
  var containerNames = new Set();
131
+ var styleCalls = [];
131
132
  return {
132
- Program: function Program(node) {
133
- _estraverse.default.traverse(node, {
134
- enter: function enter(child) {
135
- if (child.type !== 'Property') {
136
- return;
137
- }
138
- var property = child;
139
- if (isContainerDeclaration(property.key)) {
140
- var id = getStaticString(property.value);
141
- if (id) {
142
- containerNames.add(id);
143
- }
144
- }
145
- },
146
- fallback: 'iteration'
147
- });
133
+ Property: function Property(node) {
134
+ var property = node;
135
+ if (isContainerDeclaration(property.key)) {
136
+ var id = getStaticString(property.value);
137
+ if (id) {
138
+ containerNames.add(id);
139
+ }
140
+ }
148
141
  },
149
142
  CallExpression: function CallExpression(node) {
150
143
  var _getScope = (0, _contextCompat.getScope)(context, node),
151
144
  references = _getScope.references;
152
145
  if ((0, _isSupportedImport.isCss)(node.callee, references, importSources) || (0, _isSupportedImport.isStyled)(node.callee, references, importSources) || (0, _isSupportedImport.isKeyframes)(node.callee, references, importSources) || (0, _isSupportedImport.isCssMap)(node.callee, references, importSources) || (0, _isSupportedImport.isXcss)(node.callee, references, importSources)) {
153
- _estraverse.default.traverse(node, {
146
+ styleCalls.push(node);
147
+ }
148
+ },
149
+ // Container names can be declared after the style call that uses them, so check queries once the file is visited
150
+ 'Program:exit': function ProgramExit() {
151
+ styleCalls.forEach(function (styleCall) {
152
+ _estraverse.default.traverse(styleCall, {
154
153
  enter: function enter(node) {
155
154
  if (node.type !== 'Property') {
156
155
  return;
@@ -175,7 +174,7 @@ var rule = (0, _createRule.createLintRule)({
175
174
  */
176
175
  fallback: 'iteration'
177
176
  });
178
- }
177
+ });
179
178
  }
180
179
  };
181
180
  }
@@ -51,7 +51,9 @@ function isAllowedSelector(selector) {
51
51
  var isHeadAllowed = (0, _postcssSelectorParser.isNesting)(head) || (0, _postcssSelectorParser.isPseudo)(head);
52
52
 
53
53
  // All remaining nodes must be pseudo selectors.
54
- var isTailAllowed = tail.every(_postcssSelectorParser.isPseudo);
54
+ var isTailAllowed = tail.every(function (node) {
55
+ return (0, _postcssSelectorParser.isPseudo)(node);
56
+ });
55
57
  return isHeadAllowed && isTailAllowed;
56
58
  }
57
59
  var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
@@ -14,6 +14,11 @@ var _sourcePositionUtils = require("./source-position-utils");
14
14
  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; } } }; }
15
15
  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; } }
16
16
  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; }
17
+ /**
18
+ * Structural stand-ins for postcss-selector-parser types. Importing Selector /
19
+ * Pseudo / Nesting under TSRS expands into an infinite Container/Diff cycle.
20
+ */
21
+
17
22
  function lintSelector(args) {
18
23
  checkNoAmbiguousPseudos(args);
19
24
  var pseudos = [];
@@ -237,7 +242,7 @@ function checkNoIncreasedSpecificity(_ref4, nestings) {
237
242
  var lastNesting = nesting;
238
243
  while ((0, _postcssSelectorParser.isNesting)(next)) {
239
244
  lastNesting = next;
240
- next = next.next();
245
+ next = lastNesting.next();
241
246
  }
242
247
  var _getRangeFromNode = (0, _sourcePositionUtils.getRangeFromNode)({
243
248
  node: nesting,
@@ -4,6 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getRangeFromNode = getRangeFromNode;
7
+ /**
8
+ * Structural stand-in for postcss-selector-parser's Node. Avoid importing that
9
+ * Node type — under TSRS it expands into an infinite Container/Diff cycle.
10
+ */
11
+
7
12
  function getRangeFromNode(_ref) {
8
13
  var node = _ref.node,
9
14
  sourceNode = _ref.sourceNode;
@@ -8,6 +8,12 @@ exports.parseSelector = parseSelector;
8
8
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
9
  var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
10
10
  var cssSelectorProcessor = (0, _postcssSelectorParser.default)();
11
+
12
+ /**
13
+ * Structural stand-in for postcss-selector-parser's Root AST. Avoid returning the
14
+ * library's Selector/Container types — under TSRS they expand into an infinite cycle.
15
+ */
16
+
11
17
  var selectorCache = new WeakMap();
12
18
 
13
19
  /**
@@ -269,7 +269,7 @@ const rule = createLintRule({
269
269
  meta: {
270
270
  name: 'convert-props-syntax',
271
271
  docs: {
272
- description: 'Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
272
+ description: 'Convert props syntax that is unsupported by `styled-components@<4` or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
273
273
  recommended: true,
274
274
  severity: 'error'
275
275
  },
@@ -111,30 +111,29 @@ const rule = createLintRule({
111
111
  create(context) {
112
112
  const importSources = getImportSources(context);
113
113
  const containerNames = new Set();
114
+ const styleCalls = [];
114
115
  return {
115
- Program(node) {
116
- estraverse.traverse(node, {
117
- enter(child) {
118
- if (child.type !== 'Property') {
119
- return;
120
- }
121
- const property = child;
122
- if (isContainerDeclaration(property.key)) {
123
- const id = getStaticString(property.value);
124
- if (id) {
125
- containerNames.add(id);
126
- }
127
- }
128
- },
129
- fallback: 'iteration'
130
- });
116
+ Property(node) {
117
+ const property = node;
118
+ if (isContainerDeclaration(property.key)) {
119
+ const id = getStaticString(property.value);
120
+ if (id) {
121
+ containerNames.add(id);
122
+ }
123
+ }
131
124
  },
132
125
  CallExpression(node) {
133
126
  const {
134
127
  references
135
128
  } = getScope(context, node);
136
129
  if (isCss(node.callee, references, importSources) || isStyled(node.callee, references, importSources) || isKeyframes(node.callee, references, importSources) || isCssMap(node.callee, references, importSources) || isXcss(node.callee, references, importSources)) {
137
- estraverse.traverse(node, {
130
+ styleCalls.push(node);
131
+ }
132
+ },
133
+ // Container names can be declared after the style call that uses them, so check queries once the file is visited
134
+ 'Program:exit'() {
135
+ styleCalls.forEach(styleCall => {
136
+ estraverse.traverse(styleCall, {
138
137
  enter(node) {
139
138
  if (node.type !== 'Property') {
140
139
  return;
@@ -159,7 +158,7 @@ const rule = createLintRule({
159
158
  */
160
159
  fallback: 'iteration'
161
160
  });
162
- }
161
+ });
163
162
  }
164
163
  };
165
164
  }
@@ -36,7 +36,7 @@ function isAllowedSelector(selector) {
36
36
  const isHeadAllowed = isNesting(head) || isPseudo(head);
37
37
 
38
38
  // All remaining nodes must be pseudo selectors.
39
- const isTailAllowed = tail.every(isPseudo);
39
+ const isTailAllowed = tail.every(node => isPseudo(node));
40
40
  return isHeadAllowed && isTailAllowed;
41
41
  }
42
42
  const rule = createLintRuleWithTypedConfig({
@@ -2,6 +2,12 @@ import { isNesting, isPseudo } from 'postcss-selector-parser';
2
2
  import { allowedPseudos } from './constants';
3
3
  import { getSourceLocationFromRange } from './get-source-location-from-range';
4
4
  import { getRangeFromNode } from './source-position-utils';
5
+
6
+ /**
7
+ * Structural stand-ins for postcss-selector-parser types. Importing Selector /
8
+ * Pseudo / Nesting under TSRS expands into an infinite Container/Diff cycle.
9
+ */
10
+
5
11
  export function lintSelector(args) {
6
12
  checkNoAmbiguousPseudos(args);
7
13
  const pseudos = [];
@@ -175,7 +181,7 @@ function checkNoIncreasedSpecificity({
175
181
  let lastNesting = nesting;
176
182
  while (isNesting(next)) {
177
183
  lastNesting = next;
178
- next = next.next();
184
+ next = lastNesting.next();
179
185
  }
180
186
  const [start] = getRangeFromNode({
181
187
  node: nesting,
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Structural stand-in for postcss-selector-parser's Node. Avoid importing that
3
+ * Node type — under TSRS it expands into an infinite Container/Diff cycle.
4
+ */
5
+
1
6
  export function getRangeFromNode({
2
7
  node,
3
8
  sourceNode
@@ -1,6 +1,12 @@
1
1
  import cssSelectorParser from 'postcss-selector-parser';
2
2
  import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
3
3
  const cssSelectorProcessor = cssSelectorParser();
4
+
5
+ /**
6
+ * Structural stand-in for postcss-selector-parser's Root AST. Avoid returning the
7
+ * library's Selector/Container types — under TSRS they expand into an infinite cycle.
8
+ */
9
+
4
10
  const selectorCache = new WeakMap();
5
11
 
6
12
  /**
@@ -367,7 +367,7 @@ var rule = createLintRule({
367
367
  meta: {
368
368
  name: 'convert-props-syntax',
369
369
  docs: {
370
- description: 'Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
370
+ description: 'Convert props syntax that is unsupported by `styled-components@<4` or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries.',
371
371
  recommended: true,
372
372
  severity: 'error'
373
373
  },
@@ -121,29 +121,28 @@ var rule = createLintRule({
121
121
  create: function create(context) {
122
122
  var importSources = getImportSources(context);
123
123
  var containerNames = new Set();
124
+ var styleCalls = [];
124
125
  return {
125
- Program: function Program(node) {
126
- estraverse.traverse(node, {
127
- enter: function enter(child) {
128
- if (child.type !== 'Property') {
129
- return;
130
- }
131
- var property = child;
132
- if (isContainerDeclaration(property.key)) {
133
- var id = getStaticString(property.value);
134
- if (id) {
135
- containerNames.add(id);
136
- }
137
- }
138
- },
139
- fallback: 'iteration'
140
- });
126
+ Property: function Property(node) {
127
+ var property = node;
128
+ if (isContainerDeclaration(property.key)) {
129
+ var id = getStaticString(property.value);
130
+ if (id) {
131
+ containerNames.add(id);
132
+ }
133
+ }
141
134
  },
142
135
  CallExpression: function CallExpression(node) {
143
136
  var _getScope = getScope(context, node),
144
137
  references = _getScope.references;
145
138
  if (isCss(node.callee, references, importSources) || isStyled(node.callee, references, importSources) || isKeyframes(node.callee, references, importSources) || isCssMap(node.callee, references, importSources) || isXcss(node.callee, references, importSources)) {
146
- estraverse.traverse(node, {
139
+ styleCalls.push(node);
140
+ }
141
+ },
142
+ // Container names can be declared after the style call that uses them, so check queries once the file is visited
143
+ 'Program:exit': function ProgramExit() {
144
+ styleCalls.forEach(function (styleCall) {
145
+ estraverse.traverse(styleCall, {
147
146
  enter: function enter(node) {
148
147
  if (node.type !== 'Property') {
149
148
  return;
@@ -168,7 +167,7 @@ var rule = createLintRule({
168
167
  */
169
168
  fallback: 'iteration'
170
169
  });
171
- }
170
+ });
172
171
  }
173
172
  };
174
173
  }
@@ -44,7 +44,9 @@ function isAllowedSelector(selector) {
44
44
  var isHeadAllowed = isNesting(head) || isPseudo(head);
45
45
 
46
46
  // All remaining nodes must be pseudo selectors.
47
- var isTailAllowed = tail.every(isPseudo);
47
+ var isTailAllowed = tail.every(function (node) {
48
+ return isPseudo(node);
49
+ });
48
50
  return isHeadAllowed && isTailAllowed;
49
51
  }
50
52
  var rule = createLintRuleWithTypedConfig({
@@ -7,6 +7,12 @@ import { isNesting, isPseudo } from 'postcss-selector-parser';
7
7
  import { allowedPseudos } from './constants';
8
8
  import { getSourceLocationFromRange } from './get-source-location-from-range';
9
9
  import { getRangeFromNode } from './source-position-utils';
10
+
11
+ /**
12
+ * Structural stand-ins for postcss-selector-parser types. Importing Selector /
13
+ * Pseudo / Nesting under TSRS expands into an infinite Container/Diff cycle.
14
+ */
15
+
10
16
  export function lintSelector(args) {
11
17
  checkNoAmbiguousPseudos(args);
12
18
  var pseudos = [];
@@ -230,7 +236,7 @@ function checkNoIncreasedSpecificity(_ref4, nestings) {
230
236
  var lastNesting = nesting;
231
237
  while (isNesting(next)) {
232
238
  lastNesting = next;
233
- next = next.next();
239
+ next = lastNesting.next();
234
240
  }
235
241
  var _getRangeFromNode = getRangeFromNode({
236
242
  node: nesting,
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Structural stand-in for postcss-selector-parser's Node. Avoid importing that
3
+ * Node type — under TSRS it expands into an infinite Container/Diff cycle.
4
+ */
5
+
1
6
  export function getRangeFromNode(_ref) {
2
7
  var node = _ref.node,
3
8
  sourceNode = _ref.sourceNode;
@@ -1,6 +1,12 @@
1
1
  import cssSelectorParser from 'postcss-selector-parser';
2
2
  import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
3
3
  var cssSelectorProcessor = cssSelectorParser();
4
+
5
+ /**
6
+ * Structural stand-in for postcss-selector-parser's Root AST. Avoid returning the
7
+ * library's Selector/Container types — under TSRS they expand into an infinite cycle.
8
+ */
9
+
4
10
  var selectorCache = new WeakMap();
5
11
 
6
12
  /**
@@ -1,10 +1,24 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import type * as ESTree from 'eslint-codemod-utils';
3
- import { type Selector } from 'postcss-selector-parser';
3
+ /**
4
+ * Structural stand-ins for postcss-selector-parser types. Importing Selector /
5
+ * Pseudo / Nesting under TSRS expands into an infinite Container/Diff cycle.
6
+ */
7
+ type SelectorNodeLike = {
8
+ type: string;
9
+ sourceIndex: number;
10
+ value: string;
11
+ prev: () => unknown;
12
+ next: () => unknown;
13
+ };
14
+ type SelectorLike = {
15
+ first: SelectorNodeLike;
16
+ walk: (callback: (node: unknown) => false | undefined) => void;
17
+ };
4
18
  type CheckArgs = {
5
19
  context: Rule.RuleContext;
6
20
  sourceNode: ESTree.Node;
7
- selector: Selector;
21
+ selector: SelectorLike;
8
22
  config: {
9
23
  shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: boolean;
10
24
  };
@@ -1,13 +1,18 @@
1
1
  import type * as ESTree from 'eslint-codemod-utils';
2
- import { type Node as SelectorNode } from 'postcss-selector-parser';
3
2
  type Range = [number, number];
3
+ /**
4
+ * Structural stand-in for postcss-selector-parser's Node. Avoid importing that
5
+ * Node type — under TSRS it expands into an infinite Container/Diff cycle.
6
+ */
7
+ type SelectorNodeWithValue = {
8
+ sourceIndex: number;
9
+ value: string;
10
+ };
4
11
  export declare function getRangeFromNode({ node, sourceNode, }: {
5
12
  /**
6
13
  * The selector AST node to get the range of.
7
14
  */
8
- node: SelectorNode & {
9
- value: string;
10
- };
15
+ node: SelectorNodeWithValue;
11
16
  /**
12
17
  * The source ESTree node whose value was parsed to obtain the selector AST.
13
18
  *
@@ -1,9 +1,22 @@
1
1
  import type { Rule } from 'eslint';
2
- import cssSelectorParser from 'postcss-selector-parser';
3
- declare const cssSelectorProcessor: ReturnType<typeof cssSelectorParser>;
4
- type ParsedSelector = ReturnType<typeof cssSelectorProcessor.astSync>;
2
+ /**
3
+ * Structural stand-in for postcss-selector-parser's Root AST. Avoid returning the
4
+ * library's Selector/Container types — under TSRS they expand into an infinite cycle.
5
+ */
6
+ export type ParsedSelector = {
7
+ nodes: Array<{
8
+ nodes: unknown[];
9
+ first: {
10
+ type: string;
11
+ sourceIndex: number;
12
+ value: string;
13
+ prev: () => unknown;
14
+ next: () => unknown;
15
+ };
16
+ walk: (callback: (node: unknown) => false | undefined) => void;
17
+ }>;
18
+ };
5
19
  /**
6
20
  * Parse each selector once per linted source file. Consumers treat the returned AST as read-only.
7
21
  */
8
22
  export declare function parseSelector(context: Rule.RuleContext, selectorText: string): ParsedSelector;
9
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "atlaskit:src": "src/index.tsx",
30
30
  "dependencies": {
31
- "@atlaskit/eslint-plugin-design-system": "^16.15.0",
31
+ "@atlaskit/eslint-plugin-design-system": "^16.16.0",
32
32
  "@atlaskit/eslint-utils": "^3.1.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@typescript-eslint/utils": "^8.64.0",
@@ -42,8 +42,9 @@
42
42
  "postcss-selector-parser": "^6.0.16"
43
43
  },
44
44
  "devDependencies": {
45
+ "@af/codegen-utils": "workspace:^",
45
46
  "@af/formatting": "workspace:^",
46
- "@atlaskit/ds-lib": "^8.0.0",
47
+ "@atlaskit/ds-lib": "^9.0.0",
47
48
  "@atlassian/codegen": "^0.3.0",
48
49
  "@atlassian/ts-loader": "^0.1.0",
49
50
  "@eslint/eslintrc": "^3.0.2",