@atlaskit/eslint-plugin-ui-styling-standard 3.0.3 → 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.
Files changed (63) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +28 -28
  3. package/dist/cjs/rules/convert-props-syntax/index.js +1 -1
  4. package/dist/cjs/rules/enforce-style-prop/index.js +1 -1
  5. package/dist/cjs/rules/local-cx-xcss/index.js +1 -1
  6. package/dist/cjs/rules/no-array-arguments/index.js +1 -1
  7. package/dist/cjs/rules/no-atlaskit-theme/index.js +1 -1
  8. package/dist/cjs/rules/no-classname-prop/index.js +1 -1
  9. package/dist/cjs/rules/no-container-queries/index.js +22 -23
  10. package/dist/cjs/rules/no-dynamic-styles/index.js +1 -1
  11. package/dist/cjs/rules/no-exported-styles/index.js +1 -1
  12. package/dist/cjs/rules/no-global-styles/index.js +2 -2
  13. package/dist/cjs/rules/no-important-styles/index.js +1 -1
  14. package/dist/cjs/rules/no-imported-style-values/index.js +9 -3
  15. package/dist/cjs/rules/no-nested-selectors/index.js +4 -2
  16. package/dist/cjs/rules/no-styled/index.js +1 -1
  17. package/dist/cjs/rules/no-unsafe-selectors/index.js +10 -10
  18. package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +6 -1
  19. package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +5 -0
  20. package/dist/cjs/rules/no-unused-cssmap-properties/index.js +1 -1
  21. package/dist/cjs/rules/utils/parse-selector.js +6 -0
  22. package/dist/es2019/rules/convert-props-syntax/index.js +1 -1
  23. package/dist/es2019/rules/enforce-style-prop/index.js +1 -1
  24. package/dist/es2019/rules/local-cx-xcss/index.js +1 -1
  25. package/dist/es2019/rules/no-array-arguments/index.js +1 -1
  26. package/dist/es2019/rules/no-atlaskit-theme/index.js +1 -1
  27. package/dist/es2019/rules/no-classname-prop/index.js +1 -1
  28. package/dist/es2019/rules/no-container-queries/index.js +22 -23
  29. package/dist/es2019/rules/no-dynamic-styles/index.js +1 -1
  30. package/dist/es2019/rules/no-exported-styles/index.js +1 -1
  31. package/dist/es2019/rules/no-global-styles/index.js +2 -2
  32. package/dist/es2019/rules/no-important-styles/index.js +1 -1
  33. package/dist/es2019/rules/no-imported-style-values/index.js +10 -4
  34. package/dist/es2019/rules/no-nested-selectors/index.js +2 -2
  35. package/dist/es2019/rules/no-styled/index.js +1 -1
  36. package/dist/es2019/rules/no-unsafe-selectors/index.js +10 -10
  37. package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +7 -1
  38. package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +5 -0
  39. package/dist/es2019/rules/no-unused-cssmap-properties/index.js +1 -1
  40. package/dist/es2019/rules/utils/parse-selector.js +6 -0
  41. package/dist/esm/rules/convert-props-syntax/index.js +1 -1
  42. package/dist/esm/rules/enforce-style-prop/index.js +1 -1
  43. package/dist/esm/rules/local-cx-xcss/index.js +1 -1
  44. package/dist/esm/rules/no-array-arguments/index.js +1 -1
  45. package/dist/esm/rules/no-atlaskit-theme/index.js +1 -1
  46. package/dist/esm/rules/no-classname-prop/index.js +1 -1
  47. package/dist/esm/rules/no-container-queries/index.js +22 -23
  48. package/dist/esm/rules/no-dynamic-styles/index.js +1 -1
  49. package/dist/esm/rules/no-exported-styles/index.js +1 -1
  50. package/dist/esm/rules/no-global-styles/index.js +2 -2
  51. package/dist/esm/rules/no-important-styles/index.js +1 -1
  52. package/dist/esm/rules/no-imported-style-values/index.js +9 -3
  53. package/dist/esm/rules/no-nested-selectors/index.js +4 -2
  54. package/dist/esm/rules/no-styled/index.js +1 -1
  55. package/dist/esm/rules/no-unsafe-selectors/index.js +10 -10
  56. package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +7 -1
  57. package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +5 -0
  58. package/dist/esm/rules/no-unused-cssmap-properties/index.js +1 -1
  59. package/dist/esm/rules/utils/parse-selector.js +6 -0
  60. package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +16 -2
  61. package/dist/types/rules/no-unsafe-selectors/source-position-utils.d.ts +9 -4
  62. package/dist/types/rules/utils/parse-selector.d.ts +17 -4
  63. package/package.json +4 -3
@@ -99,11 +99,11 @@ const rule = createLintRule({
99
99
  severity: 'error'
100
100
  },
101
101
  messages: {
102
- 'no-container-queries': "Use a named container declared in this file and a width/height condition; type the static query key with satisfies and the default Container import from @atlaskit/css/at-rules/container.",
103
- 'no-container-style-queries': "Replace the style query with an explicit prop and local cssMap variant, or use a width/height-based query when size is the intended condition.",
104
- 'no-unbound-container-queries': "Name the container in the same file and reference it in the query, for example containerName: \"card\" with \"@container card (min-width: 30rem)\".",
105
- 'no-mismatched-container-name': "Use the same container name in this @container query and the containerName declaration in this file; rename the mismatched declaration or query.",
106
- 'no-non-dimension-container-queries': "Use a width/height condition for this named local container. Represent other conditions as explicit props selecting local styles."
102
+ 'no-container-queries': 'Use a named container declared in this file and a width/height condition; type the static query key with satisfies and the default Container import from @atlaskit/css/at-rules/container.',
103
+ 'no-container-style-queries': 'Replace the style query with an explicit prop and local cssMap variant, or use a width/height-based query when size is the intended condition.',
104
+ 'no-unbound-container-queries': 'Name the container in the same file and reference it in the query, for example containerName: "card" with "@container card (min-width: 30rem)".',
105
+ 'no-mismatched-container-name': 'Use the same container name in this @container query and the containerName declaration in this file; rename the mismatched declaration or query.',
106
+ 'no-non-dimension-container-queries': 'Use a width/height condition for this named local container. Represent other conditions as explicit props selecting local styles.'
107
107
  },
108
108
  type: 'problem',
109
109
  schema
@@ -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
  }
@@ -24,7 +24,7 @@ const rule = createLintRule({
24
24
  },
25
25
  schema,
26
26
  messages: {
27
- 'no-dynamic-styles': "Declare static variants with cssMap() and select the variant in JSX; pass values known only at runtime through the style prop."
27
+ 'no-dynamic-styles': 'Declare static variants with cssMap() and select the variant in JSX; pass values known only at runtime through the style prop.'
28
28
  },
29
29
  type: 'problem'
30
30
  },
@@ -23,7 +23,7 @@ const rule = createLintRule({
23
23
  severity: 'error'
24
24
  },
25
25
  messages: {
26
- 'no-exported-styles': "Keep css, cssMap, keyframes, styled and xcss declarations in the file that uses them. Export a component to share its styling instead of exporting style values."
26
+ 'no-exported-styles': 'Keep css, cssMap, keyframes, styled and xcss declarations in the file that uses them. Export a component to share its styling instead of exporting style values.'
27
27
  },
28
28
  type: 'problem',
29
29
  schema
@@ -17,8 +17,8 @@ const rule = createLintRule({
17
17
  severity: 'error'
18
18
  },
19
19
  messages: {
20
- 'no-global-styles': "Move global declarations into local cssMap() or css() styles on their owning elements. Use @atlaskit/css-reset only for the supported global reset.",
21
- 'no-css-modules': "Replace the CSS-file import with local cssMap() or css() declarations from @atlaskit/css and apply them on the owning elements; preserve the imported styles during migration."
20
+ 'no-global-styles': 'Move global declarations into local cssMap() or css() styles on their owning elements. Use @atlaskit/css-reset only for the supported global reset.',
21
+ 'no-css-modules': 'Replace the CSS-file import with local cssMap() or css() declarations from @atlaskit/css and apply them on the owning elements; preserve the imported styles during migration.'
22
22
  },
23
23
  type: 'problem'
24
24
  },
@@ -12,7 +12,7 @@ const rule = createLintRuleWithTypedConfig({
12
12
  severity: 'error'
13
13
  },
14
14
  messages: {
15
- 'no-important-styles': "Remove !important and apply the intended style directly to the owning element; resolve conflicting declarations through local style composition."
15
+ 'no-important-styles': 'Remove !important and apply the intended style directly to the owning element; resolve conflicting declarations through local style composition.'
16
16
  },
17
17
  type: 'problem',
18
18
  schema: {
@@ -5,6 +5,7 @@ import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
5
5
  import { findVariable } from '@atlaskit/eslint-utils/find-variable';
6
6
  import { getImportSources, hasStyleObjectArguments, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
7
7
  import { createLintRule } from '../utils/create-rule';
8
+ import { isTypeWrapper } from '../utils/is-type-wrapper';
8
9
  const schema = [{
9
10
  type: 'object',
10
11
  properties: {
@@ -112,7 +113,7 @@ const rule = createLintRule({
112
113
  severity: 'error'
113
114
  },
114
115
  messages: {
115
- 'no-imported-style-values': "Declare and use these styles in the same file. Share a component across files instead of importing css, cssMap, styled, keyframes or xcss values."
116
+ 'no-imported-style-values': 'Declare and use these styles in the same file. Share a component across files instead of importing css, cssMap, styled, keyframes or xcss values.'
116
117
  },
117
118
  type: 'problem',
118
119
  schema
@@ -130,6 +131,7 @@ const rule = createLintRule({
130
131
  }
131
132
  };
132
133
  const isValidCx = (jsxAttribute, identifier) => {
134
+ var _callExpression;
133
135
  /**
134
136
  * We don't want to allow `cx` for `css` (or `style`)
135
137
  */
@@ -138,15 +140,19 @@ const rule = createLintRule({
138
140
  }
139
141
 
140
142
  /**
141
- * Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
143
+ * Allow `xcss={cx(...)}` through type-only wrappers, but not runtime wrappers.
142
144
  */
143
145
 
144
146
  const jsxExpression = jsxAttribute.value;
145
147
  if ((jsxExpression === null || jsxExpression === void 0 ? void 0 : jsxExpression.type) !== 'JSXExpressionContainer') {
146
148
  return false;
147
149
  }
148
- const callExpression = jsxExpression.expression;
149
- if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
150
+ let callExpression = jsxExpression.expression;
151
+ while (isTypeWrapper(callExpression)) {
152
+ // ESTree does not model TypeScript wrappers; each has an expression child.
153
+ callExpression = callExpression.expression;
154
+ }
155
+ if (((_callExpression = callExpression) === null || _callExpression === void 0 ? void 0 : _callExpression.type) !== 'CallExpression') {
150
156
  return false;
151
157
  }
152
158
  if (callExpression.callee !== identifier) {
@@ -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({
@@ -48,7 +48,7 @@ const rule = createLintRuleWithTypedConfig({
48
48
  severity: 'error'
49
49
  },
50
50
  messages: {
51
- 'no-nested-selectors': "Apply local styles directly to the child element instead of selecting it through a parent or external context; pass explicit props for conditional variants."
51
+ 'no-nested-selectors': 'Apply local styles directly to the child element instead of selecting it through a parent or external context; pass explicit props for conditional variants.'
52
52
  },
53
53
  type: 'problem',
54
54
  schema: {
@@ -10,7 +10,7 @@ const rule = createLintRule({
10
10
  severity: 'error'
11
11
  },
12
12
  messages: {
13
- 'no-styled': "Replace styled with module-scoped cssMap() or css() from @atlaskit/css and apply styles on the element; pass runtime-only values through style."
13
+ 'no-styled': 'Replace styled with module-scoped cssMap() or css() from @atlaskit/css and apply styles on the element; pass runtime-only values through style.'
14
14
  },
15
15
  type: 'problem'
16
16
  },
@@ -74,23 +74,23 @@ const rule = createLintRuleWithTypedConfig({
74
74
  /**
75
75
  * Selector messages
76
76
  */
77
- 'no-ambiguous-pseudos': "Prefix the pseudo-selector with & when it targets this element (for example &:hover); apply descendant styles directly to the child instead.",
78
- 'no-increased-specificity': "Replace chained nesting selectors such as && with one & selector, then resolve competing styles through local composition.",
79
- 'no-restricted-pseudos': "The {{pseudo}} pseudo-selector is unsupported. Use an allowed local pseudo such as &:hover, or pass explicit state as a prop and select a local cssMap variant.",
80
- 'no-legacy-pseudo-element-syntax': "Use a double colon for pseudo-elements, for example &::before or &::after, instead of the legacy single-colon syntax.",
77
+ 'no-ambiguous-pseudos': 'Prefix the pseudo-selector with & when it targets this element (for example &:hover); apply descendant styles directly to the child instead.',
78
+ 'no-increased-specificity': 'Replace chained nesting selectors such as && with one & selector, then resolve competing styles through local composition.',
79
+ 'no-restricted-pseudos': 'The {{pseudo}} pseudo-selector is unsupported. Use an allowed local pseudo such as &:hover, or pass explicit state as a prop and select a local cssMap variant.',
80
+ 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements, for example &::before or &::after, instead of the legacy single-colon syntax.',
81
81
  'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed. Correct its CSS syntax; if it is valid, report the selector and reproduction to #help-ui-styling-standard.",
82
- 'no-selectors-object': "Move selectors out of the selectors object into supported local style keys; apply child styles directly to each child element.",
82
+ 'no-selectors-object': 'Move selectors out of the selectors object into supported local style keys; apply child styles directly to each child element.',
83
83
  /**
84
84
  * At-rule messages
85
85
  */
86
- 'no-keyframes-at-rules': "Replace the @keyframes at-rule with keyframes() from @compiled/react and reference its result through animationName.",
87
- 'no-restricted-at-rules': "{{atRule}} is unsupported. Use a supported @media, @supports or @property rule; for runtime conditions select a local style variant in JavaScript.",
88
- 'no-grouped-at-rules': "Flatten grouped at-rules into complete keys, for example \"@media (min-width: 48rem)\" instead of an \"@media\" object containing conditions.",
89
- 'no-noncanonical-media-query': "Match the literal query to its imported @atlaskit/css/at-rules type, including the exact breakpoint, units and comparison operator.",
86
+ 'no-keyframes-at-rules': 'Replace the @keyframes at-rule with keyframes() from @compiled/react and reference its result through animationName.',
87
+ 'no-restricted-at-rules': '{{atRule}} is unsupported. Use a supported @media, @supports or @property rule; for runtime conditions select a local style variant in JavaScript.',
88
+ 'no-grouped-at-rules': 'Flatten grouped at-rules into complete keys, for example "@media (min-width: 48rem)" instead of an "@media" object containing conditions.',
89
+ 'no-noncanonical-media-query': 'Match the literal query to its imported @atlaskit/css/at-rules type, including the exact breakpoint, units and comparison operator.',
90
90
  /**
91
91
  * Suggestion messages
92
92
  */
93
- 'insert-nesting-selector': "Insert & before this pseudo-selector to target the element itself, for example &:hover."
93
+ 'insert-nesting-selector': 'Insert & before this pseudo-selector to target the element itself, for example &:hover.'
94
94
  },
95
95
  schema: {
96
96
  type: 'object',
@@ -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
@@ -69,7 +69,7 @@ const rule = createLintRule({
69
69
  severity: 'warn'
70
70
  },
71
71
  messages: {
72
- 'unused-property': "The \"{{propertyName}}\" style is never used. Remove it from cssMap, or apply it to the intended element if the style is still required."
72
+ 'unused-property': 'The "{{propertyName}}" style is never used. Remove it from cssMap, or apply it to the intended element if the style is still required.'
73
73
  },
74
74
  type: 'problem'
75
75
  },
@@ -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
  },
@@ -178,7 +178,7 @@ var rule = createLintRule({
178
178
  severity: 'error'
179
179
  },
180
180
  messages: {
181
- 'enforce-style-prop': "Move static style values into module-scoped cssMap() or css() declarations and apply them with css or xcss; keep only runtime values in style."
181
+ 'enforce-style-prop': 'Move static style values into module-scoped cssMap() or css() declarations and apply them with css or xcss; keep only runtime values in style.'
182
182
  },
183
183
  type: 'problem'
184
184
  },
@@ -21,7 +21,7 @@ var rule = createLintRule({
21
21
  severity: 'error'
22
22
  },
23
23
  messages: {
24
- 'local-cx-xcss': "Call cx() directly inside the xcss prop, for example xcss={cx(styles.base, active && styles.active)}, instead of storing its result elsewhere."
24
+ 'local-cx-xcss': 'Call cx() directly inside the xcss prop, for example xcss={cx(styles.base, active && styles.active)}, instead of storing its result elsewhere.'
25
25
  },
26
26
  type: 'problem'
27
27
  },
@@ -25,7 +25,7 @@ var rule = createLintRule({
25
25
  severity: 'error'
26
26
  },
27
27
  messages: {
28
- 'no-array-arguments': "Pass style objects as separate arguments instead of wrapping arguments in an array; delete an empty array argument."
28
+ 'no-array-arguments': 'Pass style objects as separate arguments instead of wrapping arguments in an array; delete an empty array argument.'
29
29
  },
30
30
  type: 'problem',
31
31
  fixable: 'code',
@@ -8,7 +8,7 @@ var rule = createLintRule({
8
8
  severity: 'error'
9
9
  },
10
10
  messages: {
11
- 'no-atlaskit-theme': "Replace @atlaskit/theme imports with semantic token() values from @atlaskit/tokens or the matching ADS component; migrate each imported helper before removing the import."
11
+ 'no-atlaskit-theme': 'Replace @atlaskit/theme imports with semantic token() values from @atlaskit/tokens or the matching ADS component; migrate each imported helper before removing the import.'
12
12
  },
13
13
  type: 'problem'
14
14
  },
@@ -15,7 +15,7 @@ var rule = createLintRule({
15
15
  severity: 'error'
16
16
  },
17
17
  messages: {
18
- 'no-classname-prop': "Apply local styles through css instead of className. Use supported component props or its bounded xcss interface for component customization."
18
+ 'no-classname-prop': 'Apply local styles through css instead of className. Use supported component props or its bounded xcss interface for component customization.'
19
19
  },
20
20
  type: 'problem'
21
21
  },
@@ -109,11 +109,11 @@ var rule = createLintRule({
109
109
  severity: 'error'
110
110
  },
111
111
  messages: {
112
- 'no-container-queries': "Use a named container declared in this file and a width/height condition; type the static query key with satisfies and the default Container import from @atlaskit/css/at-rules/container.",
113
- 'no-container-style-queries': "Replace the style query with an explicit prop and local cssMap variant, or use a width/height-based query when size is the intended condition.",
114
- 'no-unbound-container-queries': "Name the container in the same file and reference it in the query, for example containerName: \"card\" with \"@container card (min-width: 30rem)\".",
115
- 'no-mismatched-container-name': "Use the same container name in this @container query and the containerName declaration in this file; rename the mismatched declaration or query.",
116
- 'no-non-dimension-container-queries': "Use a width/height condition for this named local container. Represent other conditions as explicit props selecting local styles."
112
+ 'no-container-queries': 'Use a named container declared in this file and a width/height condition; type the static query key with satisfies and the default Container import from @atlaskit/css/at-rules/container.',
113
+ 'no-container-style-queries': 'Replace the style query with an explicit prop and local cssMap variant, or use a width/height-based query when size is the intended condition.',
114
+ 'no-unbound-container-queries': 'Name the container in the same file and reference it in the query, for example containerName: "card" with "@container card (min-width: 30rem)".',
115
+ 'no-mismatched-container-name': 'Use the same container name in this @container query and the containerName declaration in this file; rename the mismatched declaration or query.',
116
+ 'no-non-dimension-container-queries': 'Use a width/height condition for this named local container. Represent other conditions as explicit props selecting local styles.'
117
117
  },
118
118
  type: 'problem',
119
119
  schema: schema
@@ -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
  }
@@ -27,7 +27,7 @@ var rule = createLintRule({
27
27
  },
28
28
  schema: schema,
29
29
  messages: {
30
- 'no-dynamic-styles': "Declare static variants with cssMap() and select the variant in JSX; pass values known only at runtime through the style prop."
30
+ 'no-dynamic-styles': 'Declare static variants with cssMap() and select the variant in JSX; pass values known only at runtime through the style prop.'
31
31
  },
32
32
  type: 'problem'
33
33
  },
@@ -23,7 +23,7 @@ var rule = createLintRule({
23
23
  severity: 'error'
24
24
  },
25
25
  messages: {
26
- 'no-exported-styles': "Keep css, cssMap, keyframes, styled and xcss declarations in the file that uses them. Export a component to share its styling instead of exporting style values."
26
+ 'no-exported-styles': 'Keep css, cssMap, keyframes, styled and xcss declarations in the file that uses them. Export a component to share its styling instead of exporting style values.'
27
27
  },
28
28
  type: 'problem',
29
29
  schema: schema
@@ -20,8 +20,8 @@ var rule = createLintRule({
20
20
  severity: 'error'
21
21
  },
22
22
  messages: {
23
- 'no-global-styles': "Move global declarations into local cssMap() or css() styles on their owning elements. Use @atlaskit/css-reset only for the supported global reset.",
24
- 'no-css-modules': "Replace the CSS-file import with local cssMap() or css() declarations from @atlaskit/css and apply them on the owning elements; preserve the imported styles during migration."
23
+ 'no-global-styles': 'Move global declarations into local cssMap() or css() styles on their owning elements. Use @atlaskit/css-reset only for the supported global reset.',
24
+ 'no-css-modules': 'Replace the CSS-file import with local cssMap() or css() declarations from @atlaskit/css and apply them on the owning elements; preserve the imported styles during migration.'
25
25
  },
26
26
  type: 'problem'
27
27
  },
@@ -12,7 +12,7 @@ var rule = createLintRuleWithTypedConfig({
12
12
  severity: 'error'
13
13
  },
14
14
  messages: {
15
- 'no-important-styles': "Remove !important and apply the intended style directly to the owning element; resolve conflicting declarations through local style composition."
15
+ 'no-important-styles': 'Remove !important and apply the intended style directly to the owning element; resolve conflicting declarations through local style composition.'
16
16
  },
17
17
  type: 'problem',
18
18
  schema: {
@@ -8,6 +8,7 @@ import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
8
8
  import { findVariable } from '@atlaskit/eslint-utils/find-variable';
9
9
  import { getImportSources, hasStyleObjectArguments, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
10
10
  import { createLintRule } from '../utils/create-rule';
11
+ import { isTypeWrapper } from '../utils/is-type-wrapper';
11
12
  var schema = [{
12
13
  type: 'object',
13
14
  properties: {
@@ -116,7 +117,7 @@ var rule = createLintRule({
116
117
  severity: 'error'
117
118
  },
118
119
  messages: {
119
- 'no-imported-style-values': "Declare and use these styles in the same file. Share a component across files instead of importing css, cssMap, styled, keyframes or xcss values."
120
+ 'no-imported-style-values': 'Declare and use these styles in the same file. Share a component across files instead of importing css, cssMap, styled, keyframes or xcss values.'
120
121
  },
121
122
  type: 'problem',
122
123
  schema: schema
@@ -143,6 +144,7 @@ var rule = createLintRule({
143
144
  }
144
145
  };
145
146
  var isValidCx = function isValidCx(jsxAttribute, identifier) {
147
+ var _callExpression;
146
148
  /**
147
149
  * We don't want to allow `cx` for `css` (or `style`)
148
150
  */
@@ -151,7 +153,7 @@ var rule = createLintRule({
151
153
  }
152
154
 
153
155
  /**
154
- * Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
156
+ * Allow `xcss={cx(...)}` through type-only wrappers, but not runtime wrappers.
155
157
  */
156
158
 
157
159
  var jsxExpression = jsxAttribute.value;
@@ -159,7 +161,11 @@ var rule = createLintRule({
159
161
  return false;
160
162
  }
161
163
  var callExpression = jsxExpression.expression;
162
- if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
164
+ while (isTypeWrapper(callExpression)) {
165
+ // ESTree does not model TypeScript wrappers; each has an expression child.
166
+ callExpression = callExpression.expression;
167
+ }
168
+ if (((_callExpression = callExpression) === null || _callExpression === void 0 ? void 0 : _callExpression.type) !== 'CallExpression') {
163
169
  return false;
164
170
  }
165
171
  if (callExpression.callee !== identifier) {
@@ -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({
@@ -56,7 +58,7 @@ var rule = createLintRuleWithTypedConfig({
56
58
  severity: 'error'
57
59
  },
58
60
  messages: {
59
- 'no-nested-selectors': "Apply local styles directly to the child element instead of selecting it through a parent or external context; pass explicit props for conditional variants."
61
+ 'no-nested-selectors': 'Apply local styles directly to the child element instead of selecting it through a parent or external context; pass explicit props for conditional variants.'
60
62
  },
61
63
  type: 'problem',
62
64
  schema: {
@@ -10,7 +10,7 @@ var rule = createLintRule({
10
10
  severity: 'error'
11
11
  },
12
12
  messages: {
13
- 'no-styled': "Replace styled with module-scoped cssMap() or css() from @atlaskit/css and apply styles on the element; pass runtime-only values through style."
13
+ 'no-styled': 'Replace styled with module-scoped cssMap() or css() from @atlaskit/css and apply styles on the element; pass runtime-only values through style.'
14
14
  },
15
15
  type: 'problem'
16
16
  },
@@ -95,23 +95,23 @@ var rule = createLintRuleWithTypedConfig({
95
95
  /**
96
96
  * Selector messages
97
97
  */
98
- 'no-ambiguous-pseudos': "Prefix the pseudo-selector with & when it targets this element (for example &:hover); apply descendant styles directly to the child instead.",
99
- 'no-increased-specificity': "Replace chained nesting selectors such as && with one & selector, then resolve competing styles through local composition.",
100
- 'no-restricted-pseudos': "The {{pseudo}} pseudo-selector is unsupported. Use an allowed local pseudo such as &:hover, or pass explicit state as a prop and select a local cssMap variant.",
101
- 'no-legacy-pseudo-element-syntax': "Use a double colon for pseudo-elements, for example &::before or &::after, instead of the legacy single-colon syntax.",
98
+ 'no-ambiguous-pseudos': 'Prefix the pseudo-selector with & when it targets this element (for example &:hover); apply descendant styles directly to the child instead.',
99
+ 'no-increased-specificity': 'Replace chained nesting selectors such as && with one & selector, then resolve competing styles through local composition.',
100
+ 'no-restricted-pseudos': 'The {{pseudo}} pseudo-selector is unsupported. Use an allowed local pseudo such as &:hover, or pass explicit state as a prop and select a local cssMap variant.',
101
+ 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements, for example &::before or &::after, instead of the legacy single-colon syntax.',
102
102
  'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed. Correct its CSS syntax; if it is valid, report the selector and reproduction to #help-ui-styling-standard.",
103
- 'no-selectors-object': "Move selectors out of the selectors object into supported local style keys; apply child styles directly to each child element.",
103
+ 'no-selectors-object': 'Move selectors out of the selectors object into supported local style keys; apply child styles directly to each child element.',
104
104
  /**
105
105
  * At-rule messages
106
106
  */
107
- 'no-keyframes-at-rules': "Replace the @keyframes at-rule with keyframes() from @compiled/react and reference its result through animationName.",
108
- 'no-restricted-at-rules': "{{atRule}} is unsupported. Use a supported @media, @supports or @property rule; for runtime conditions select a local style variant in JavaScript.",
109
- 'no-grouped-at-rules': "Flatten grouped at-rules into complete keys, for example \"@media (min-width: 48rem)\" instead of an \"@media\" object containing conditions.",
110
- 'no-noncanonical-media-query': "Match the literal query to its imported @atlaskit/css/at-rules type, including the exact breakpoint, units and comparison operator.",
107
+ 'no-keyframes-at-rules': 'Replace the @keyframes at-rule with keyframes() from @compiled/react and reference its result through animationName.',
108
+ 'no-restricted-at-rules': '{{atRule}} is unsupported. Use a supported @media, @supports or @property rule; for runtime conditions select a local style variant in JavaScript.',
109
+ 'no-grouped-at-rules': 'Flatten grouped at-rules into complete keys, for example "@media (min-width: 48rem)" instead of an "@media" object containing conditions.',
110
+ 'no-noncanonical-media-query': 'Match the literal query to its imported @atlaskit/css/at-rules type, including the exact breakpoint, units and comparison operator.',
111
111
  /**
112
112
  * Suggestion messages
113
113
  */
114
- 'insert-nesting-selector': "Insert & before this pseudo-selector to target the element itself, for example &:hover."
114
+ 'insert-nesting-selector': 'Insert & before this pseudo-selector to target the element itself, for example &:hover.'
115
115
  },
116
116
  schema: {
117
117
  type: 'object',
@@ -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;