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

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 (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/rules/enforce-style-prop/index.js +1 -1
  3. package/dist/cjs/rules/local-cx-xcss/index.js +1 -1
  4. package/dist/cjs/rules/no-array-arguments/index.js +1 -1
  5. package/dist/cjs/rules/no-atlaskit-theme/index.js +1 -1
  6. package/dist/cjs/rules/no-classname-prop/index.js +1 -1
  7. package/dist/cjs/rules/no-container-queries/index.js +5 -5
  8. package/dist/cjs/rules/no-dynamic-styles/index.js +1 -1
  9. package/dist/cjs/rules/no-exported-styles/index.js +1 -1
  10. package/dist/cjs/rules/no-global-styles/index.js +2 -2
  11. package/dist/cjs/rules/no-important-styles/index.js +1 -1
  12. package/dist/cjs/rules/no-imported-style-values/index.js +9 -3
  13. package/dist/cjs/rules/no-nested-selectors/index.js +1 -1
  14. package/dist/cjs/rules/no-styled/index.js +1 -1
  15. package/dist/cjs/rules/no-unsafe-selectors/index.js +11 -11
  16. package/dist/cjs/rules/no-unused-cssmap-properties/index.js +1 -1
  17. package/dist/cjs/rules/use-compiled/index.js +1 -1
  18. package/dist/es2019/rules/enforce-style-prop/index.js +1 -1
  19. package/dist/es2019/rules/local-cx-xcss/index.js +1 -1
  20. package/dist/es2019/rules/no-array-arguments/index.js +1 -1
  21. package/dist/es2019/rules/no-atlaskit-theme/index.js +1 -1
  22. package/dist/es2019/rules/no-classname-prop/index.js +1 -1
  23. package/dist/es2019/rules/no-container-queries/index.js +5 -5
  24. package/dist/es2019/rules/no-dynamic-styles/index.js +1 -1
  25. package/dist/es2019/rules/no-exported-styles/index.js +1 -1
  26. package/dist/es2019/rules/no-global-styles/index.js +2 -2
  27. package/dist/es2019/rules/no-important-styles/index.js +1 -1
  28. package/dist/es2019/rules/no-imported-style-values/index.js +10 -4
  29. package/dist/es2019/rules/no-nested-selectors/index.js +1 -1
  30. package/dist/es2019/rules/no-styled/index.js +1 -1
  31. package/dist/es2019/rules/no-unsafe-selectors/index.js +11 -11
  32. package/dist/es2019/rules/no-unused-cssmap-properties/index.js +1 -1
  33. package/dist/es2019/rules/use-compiled/index.js +1 -1
  34. package/dist/esm/rules/enforce-style-prop/index.js +1 -1
  35. package/dist/esm/rules/local-cx-xcss/index.js +1 -1
  36. package/dist/esm/rules/no-array-arguments/index.js +1 -1
  37. package/dist/esm/rules/no-atlaskit-theme/index.js +1 -1
  38. package/dist/esm/rules/no-classname-prop/index.js +1 -1
  39. package/dist/esm/rules/no-container-queries/index.js +5 -5
  40. package/dist/esm/rules/no-dynamic-styles/index.js +1 -1
  41. package/dist/esm/rules/no-exported-styles/index.js +1 -1
  42. package/dist/esm/rules/no-global-styles/index.js +2 -2
  43. package/dist/esm/rules/no-important-styles/index.js +1 -1
  44. package/dist/esm/rules/no-imported-style-values/index.js +9 -3
  45. package/dist/esm/rules/no-nested-selectors/index.js +1 -1
  46. package/dist/esm/rules/no-styled/index.js +1 -1
  47. package/dist/esm/rules/no-unsafe-selectors/index.js +11 -11
  48. package/dist/esm/rules/no-unused-cssmap-properties/index.js +1 -1
  49. package/dist/esm/rules/use-compiled/index.js +1 -1
  50. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 3.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1215148c363e4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1215148c363e4) -
8
+ Fix false positives for type-wrapped cx calls in xcss.
9
+
10
+ ## 3.0.3
11
+
12
+ ### Patch Changes
13
+
14
+ - [`64ee18b2949bf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64ee18b2949bf) -
15
+ Give styling rule diagnostics concrete migration and recovery steps, and replace stale Emotion
16
+ guidance with Compiled examples.
17
+ - Updated dependencies
18
+
3
19
  ## 3.0.2
4
20
 
5
21
  ### Patch Changes
@@ -184,7 +184,7 @@ var rule = (0, _createRule.createLintRule)({
184
184
  severity: 'error'
185
185
  },
186
186
  messages: {
187
- 'enforce-style-prop': 'Avoid adding static values to the style prop. Use the css prop for static styles instead.'
187
+ '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.'
188
188
  },
189
189
  type: 'problem'
190
190
  },
@@ -27,7 +27,7 @@ var rule = (0, _createRule.createLintRule)({
27
27
  severity: 'error'
28
28
  },
29
29
  messages: {
30
- 'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
30
+ '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.'
31
31
  },
32
32
  type: 'problem'
33
33
  },
@@ -31,7 +31,7 @@ var rule = (0, _createRule.createLintRule)({
31
31
  severity: 'error'
32
32
  },
33
33
  messages: {
34
- 'no-array-arguments': "Don't pass multiple value in an array. Pass them as multiple arguments instead."
34
+ 'no-array-arguments': 'Pass style objects as separate arguments instead of wrapping arguments in an array; delete an empty array argument.'
35
35
  },
36
36
  type: 'problem',
37
37
  fixable: 'code',
@@ -14,7 +14,7 @@ var rule = (0, _createRule.createLintRule)({
14
14
  severity: 'error'
15
15
  },
16
16
  messages: {
17
- 'no-atlaskit-theme': 'Do not import `@atlaskit/theme`. Use `@atlaskit/tokens` or Atlassian Design System components instead.'
17
+ '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.'
18
18
  },
19
19
  type: 'problem'
20
20
  },
@@ -21,7 +21,7 @@ var rule = (0, _createRule.createLintRule)({
21
21
  severity: 'error'
22
22
  },
23
23
  messages: {
24
- 'no-classname-prop': 'Avoid `className` because it invites the use of unsafe global styles and is impossible to determine via local tooling.'
24
+ 'no-classname-prop': 'Apply local styles through css instead of className. Use supported component props or its bounded xcss interface for component customization.'
25
25
  },
26
26
  type: 'problem'
27
27
  },
@@ -116,11 +116,11 @@ var rule = (0, _createRule.createLintRule)({
116
116
  severity: 'error'
117
117
  },
118
118
  messages: {
119
- 'no-container-queries': '@container queries must use a named container declared in the same file and a width/height-based condition.',
120
- 'no-container-style-queries': 'Style queries are not allowed. Use a width/height-based @container query instead.',
121
- 'no-unbound-container-queries': 'Container queries must include a container name, for example @container card (min-width: 30rem).',
122
- 'no-mismatched-container-name': 'The @container name must match a containerName declared in the same file.',
123
- 'no-non-dimension-container-queries': 'Container queries must be dimension-based (width or height); style and other feature queries are not allowed.'
119
+ '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.',
120
+ '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.',
121
+ '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)".',
122
+ '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.',
123
+ 'no-non-dimension-container-queries': 'Use a width/height condition for this named local container. Represent other conditions as explicit props selecting local styles.'
124
124
  },
125
125
  type: 'problem',
126
126
  schema: schema
@@ -34,7 +34,7 @@ var rule = (0, _createRule.createLintRule)({
34
34
  },
35
35
  schema: schema,
36
36
  messages: {
37
- 'no-dynamic-styles': 'Dynamic styles are not allowed. Instead use the style prop to apply styles derived from component props.'
37
+ 'no-dynamic-styles': 'Declare static variants with cssMap() and select the variant in JSX; pass values known only at runtime through the style prop.'
38
38
  },
39
39
  type: 'problem'
40
40
  },
@@ -29,7 +29,7 @@ var rule = (0, _createRule.createLintRule)({
29
29
  severity: 'error'
30
30
  },
31
31
  messages: {
32
- 'no-exported-styles': 'Styles from css, cssMap, keyframes, styled and xcss should not be exported. All styles should be defined and used in the same file instead.'
32
+ '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.'
33
33
  },
34
34
  type: 'problem',
35
35
  schema: schema
@@ -26,8 +26,8 @@ var rule = (0, _createRule.createLintRule)({
26
26
  severity: 'error'
27
27
  },
28
28
  messages: {
29
- 'no-global-styles': 'Global styles are not allowed.',
30
- 'no-css-modules': 'Importing CSS files is not allowed.'
29
+ '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.',
30
+ '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.'
31
31
  },
32
32
  type: 'problem'
33
33
  },
@@ -18,7 +18,7 @@ var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
18
18
  severity: 'error'
19
19
  },
20
20
  messages: {
21
- 'no-important-styles': 'Important style declarations are disallowed. Refactor so the `!important` flag is not needed.'
21
+ 'no-important-styles': 'Remove !important and apply the intended style directly to the owning element; resolve conflicting declarations through local style composition.'
22
22
  },
23
23
  type: 'problem',
24
24
  schema: {
@@ -12,6 +12,7 @@ var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
12
12
  var _findVariable = require("@atlaskit/eslint-utils/find-variable");
13
13
  var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
14
14
  var _createRule = require("../utils/create-rule");
15
+ var _isTypeWrapper = require("../utils/is-type-wrapper");
15
16
  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; } } }; }
16
17
  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; } }
17
18
  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; }
@@ -123,7 +124,7 @@ var rule = (0, _createRule.createLintRule)({
123
124
  severity: 'error'
124
125
  },
125
126
  messages: {
126
- 'no-imported-style-values': 'Styles should not be imported to use in css, cssMap, styled, keyframes or xcss calls. All styles should be defined and used in the same file instead.'
127
+ '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.'
127
128
  },
128
129
  type: 'problem',
129
130
  schema: schema
@@ -150,6 +151,7 @@ var rule = (0, _createRule.createLintRule)({
150
151
  }
151
152
  };
152
153
  var isValidCx = function isValidCx(jsxAttribute, identifier) {
154
+ var _callExpression;
153
155
  /**
154
156
  * We don't want to allow `cx` for `css` (or `style`)
155
157
  */
@@ -158,7 +160,7 @@ var rule = (0, _createRule.createLintRule)({
158
160
  }
159
161
 
160
162
  /**
161
- * Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
163
+ * Allow `xcss={cx(...)}` through type-only wrappers, but not runtime wrappers.
162
164
  */
163
165
 
164
166
  var jsxExpression = jsxAttribute.value;
@@ -166,7 +168,11 @@ var rule = (0, _createRule.createLintRule)({
166
168
  return false;
167
169
  }
168
170
  var callExpression = jsxExpression.expression;
169
- if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
171
+ while ((0, _isTypeWrapper.isTypeWrapper)(callExpression)) {
172
+ // ESTree does not model TypeScript wrappers; each has an expression child.
173
+ callExpression = callExpression.expression;
174
+ }
175
+ if (((_callExpression = callExpression) === null || _callExpression === void 0 ? void 0 : _callExpression.type) !== 'CallExpression') {
170
176
  return false;
171
177
  }
172
178
  if (callExpression.callee !== identifier) {
@@ -63,7 +63,7 @@ var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
63
63
  severity: 'error'
64
64
  },
65
65
  messages: {
66
- 'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
66
+ '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.'
67
67
  },
68
68
  type: 'problem',
69
69
  schema: {
@@ -16,7 +16,7 @@ var rule = (0, _createRule.createLintRule)({
16
16
  severity: 'error'
17
17
  },
18
18
  messages: {
19
- 'no-styled': "Avoid usages of styled, eg. styled.div, styled('div'), styled(Component), etc."
19
+ '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.'
20
20
  },
21
21
  type: 'problem'
22
22
  },
@@ -101,23 +101,23 @@ var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
101
101
  /**
102
102
  * Selector messages
103
103
  */
104
- 'no-ambiguous-pseudos': 'Pseudo-classes and pseudo-elements without a leading selector are ambiguous. Use a more explicit selector.',
105
- 'no-increased-specificity': 'Do not chain the nesting selector.',
106
- 'no-restricted-pseudos': 'The {{pseudo}} pseudo is not allowed.',
107
- 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements. The single colon syntax is not supported for all pseudo-elements.',
108
- 'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed and is likely an authoring mistake. If you think this is an error reach out in #help-ui-styling-standard.",
109
- 'no-selectors-object': 'Do not use the selectors object. Both nested and advanced selectors should be avoided.',
104
+ 'no-ambiguous-pseudos': 'Prefix the pseudo-selector with & when it targets this element (for example &:hover); apply descendant styles directly to the child instead.',
105
+ 'no-increased-specificity': 'Replace chained nesting selectors such as && with one & selector, then resolve competing styles through local composition.',
106
+ '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.',
107
+ 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements, for example &::before or &::after, instead of the legacy single-colon syntax.',
108
+ '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.",
109
+ 'no-selectors-object': 'Move selectors out of the selectors object into supported local style keys; apply child styles directly to each child element.',
110
110
  /**
111
111
  * At-rule messages
112
112
  */
113
- 'no-keyframes-at-rules': 'Use the CSS-in-JS `keyframes` API instead of `@keyframes` at-rules.',
114
- 'no-restricted-at-rules': '{{atRule}} at-rule is not allowed.',
115
- 'no-grouped-at-rules': 'Do not group at-rules. Write flattened at-rules instead.',
116
- 'no-noncanonical-media-query': 'Use the exact media query represented by the imported @atlaskit/css/at-rules type.',
113
+ 'no-keyframes-at-rules': 'Replace the @keyframes at-rule with keyframes() from @compiled/react and reference its result through animationName.',
114
+ '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.',
115
+ 'no-grouped-at-rules': 'Flatten grouped at-rules into complete keys, for example "@media (min-width: 48rem)" instead of an "@media" object containing conditions.',
116
+ 'no-noncanonical-media-query': 'Match the literal query to its imported @atlaskit/css/at-rules type, including the exact breakpoint, units and comparison operator.',
117
117
  /**
118
118
  * Suggestion messages
119
119
  */
120
- 'insert-nesting-selector': 'Insert a nesting selector `&` to target the element itself. This is usually the intended behavior.'
120
+ 'insert-nesting-selector': 'Insert & before this pseudo-selector to target the element itself, for example &:hover.'
121
121
  },
122
122
  schema: {
123
123
  type: 'object',
@@ -77,7 +77,7 @@ var rule = (0, _createRule.createLintRule)({
77
77
  severity: 'warn'
78
78
  },
79
79
  messages: {
80
- 'unused-property': 'The "{{propertyName}}" style is defined but never used.'
80
+ '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.'
81
81
  },
82
82
  type: 'problem'
83
83
  },
@@ -60,7 +60,7 @@ var rule = (0, _createRule.createLintRule)({
60
60
  severity: 'error'
61
61
  },
62
62
  messages: {
63
- 'use-compiled': "Use '@atlaskit/css' or '@compiled/react' instead of '{{importSource}}'"
63
+ 'use-compiled': "Migrate '{{importSource}}' styling to @atlaskit/css or @compiled/react, updating imports and usages together. Verify the component rather than mixing styling engines on it."
64
64
  },
65
65
  schema: schema
66
66
  },
@@ -180,7 +180,7 @@ const rule = createLintRule({
180
180
  severity: 'error'
181
181
  },
182
182
  messages: {
183
- 'enforce-style-prop': 'Avoid adding static values to the style prop. Use the css prop for static styles instead.'
183
+ '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.'
184
184
  },
185
185
  type: 'problem'
186
186
  },
@@ -21,7 +21,7 @@ const rule = createLintRule({
21
21
  severity: 'error'
22
22
  },
23
23
  messages: {
24
- 'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
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
  },
@@ -22,7 +22,7 @@ const rule = createLintRule({
22
22
  severity: 'error'
23
23
  },
24
24
  messages: {
25
- 'no-array-arguments': "Don't pass multiple value in an array. Pass them as multiple arguments instead."
25
+ 'no-array-arguments': 'Pass style objects as separate arguments instead of wrapping arguments in an array; delete an empty array argument.'
26
26
  },
27
27
  type: 'problem',
28
28
  fixable: 'code',
@@ -8,7 +8,7 @@ const rule = createLintRule({
8
8
  severity: 'error'
9
9
  },
10
10
  messages: {
11
- 'no-atlaskit-theme': 'Do not import `@atlaskit/theme`. Use `@atlaskit/tokens` or Atlassian Design System components instead.'
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 @@ const rule = createLintRule({
15
15
  severity: 'error'
16
16
  },
17
17
  messages: {
18
- 'no-classname-prop': 'Avoid `className` because it invites the use of unsafe global styles and is impossible to determine via local tooling.'
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
  },
@@ -99,11 +99,11 @@ const rule = createLintRule({
99
99
  severity: 'error'
100
100
  },
101
101
  messages: {
102
- 'no-container-queries': '@container queries must use a named container declared in the same file and a width/height-based condition.',
103
- 'no-container-style-queries': 'Style queries are not allowed. Use a width/height-based @container query instead.',
104
- 'no-unbound-container-queries': 'Container queries must include a container name, for example @container card (min-width: 30rem).',
105
- 'no-mismatched-container-name': 'The @container name must match a containerName declared in the same file.',
106
- 'no-non-dimension-container-queries': 'Container queries must be dimension-based (width or height); style and other feature queries are not allowed.'
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
@@ -24,7 +24,7 @@ const rule = createLintRule({
24
24
  },
25
25
  schema,
26
26
  messages: {
27
- 'no-dynamic-styles': 'Dynamic styles are not allowed. Instead use the style prop to apply styles derived from component props.'
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': 'Styles from css, cssMap, keyframes, styled and xcss should not be exported. All styles should be defined and used in the same file instead.'
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': 'Global styles are not allowed.',
21
- 'no-css-modules': 'Importing CSS files is not allowed.'
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': 'Important style declarations are disallowed. Refactor so the `!important` flag is not needed.'
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': 'Styles should not be imported to use in css, cssMap, styled, keyframes or xcss calls. All styles should be defined and used in the same file instead.'
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) {
@@ -48,7 +48,7 @@ const rule = createLintRuleWithTypedConfig({
48
48
  severity: 'error'
49
49
  },
50
50
  messages: {
51
- 'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
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': "Avoid usages of styled, eg. styled.div, styled('div'), styled(Component), etc."
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': 'Pseudo-classes and pseudo-elements without a leading selector are ambiguous. Use a more explicit selector.',
78
- 'no-increased-specificity': 'Do not chain the nesting selector.',
79
- 'no-restricted-pseudos': 'The {{pseudo}} pseudo is not allowed.',
80
- 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements. The single colon syntax is not supported for all pseudo-elements.',
81
- 'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed and is likely an authoring mistake. If you think this is an error reach out in #help-ui-styling-standard.",
82
- 'no-selectors-object': 'Do not use the selectors object. Both nested and advanced selectors should be avoided.',
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
+ '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.',
83
83
  /**
84
84
  * At-rule messages
85
85
  */
86
- 'no-keyframes-at-rules': 'Use the CSS-in-JS `keyframes` API instead of `@keyframes` at-rules.',
87
- 'no-restricted-at-rules': '{{atRule}} at-rule is not allowed.',
88
- 'no-grouped-at-rules': 'Do not group at-rules. Write flattened at-rules instead.',
89
- 'no-noncanonical-media-query': 'Use the exact media query represented by the imported @atlaskit/css/at-rules type.',
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 a nesting selector `&` to target the element itself. This is usually the intended behavior.'
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',
@@ -69,7 +69,7 @@ const rule = createLintRule({
69
69
  severity: 'warn'
70
70
  },
71
71
  messages: {
72
- 'unused-property': 'The "{{propertyName}}" style is defined but never used.'
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
  },
@@ -48,7 +48,7 @@ const rule = createLintRule({
48
48
  severity: 'error'
49
49
  },
50
50
  messages: {
51
- 'use-compiled': `Use '@atlaskit/css' or '@compiled/react' instead of '{{importSource}}'`
51
+ 'use-compiled': "Migrate '{{importSource}}' styling to @atlaskit/css or @compiled/react, updating imports and usages together. Verify the component rather than mixing styling engines on it."
52
52
  },
53
53
  schema
54
54
  },
@@ -178,7 +178,7 @@ var rule = createLintRule({
178
178
  severity: 'error'
179
179
  },
180
180
  messages: {
181
- 'enforce-style-prop': 'Avoid adding static values to the style prop. Use the css prop for static styles instead.'
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': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
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': "Don't pass multiple value in an array. Pass them as multiple arguments instead."
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': 'Do not import `@atlaskit/theme`. Use `@atlaskit/tokens` or Atlassian Design System components instead.'
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': 'Avoid `className` because it invites the use of unsafe global styles and is impossible to determine via local tooling.'
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': '@container queries must use a named container declared in the same file and a width/height-based condition.',
113
- 'no-container-style-queries': 'Style queries are not allowed. Use a width/height-based @container query instead.',
114
- 'no-unbound-container-queries': 'Container queries must include a container name, for example @container card (min-width: 30rem).',
115
- 'no-mismatched-container-name': 'The @container name must match a containerName declared in the same file.',
116
- 'no-non-dimension-container-queries': 'Container queries must be dimension-based (width or height); style and other feature queries are not allowed.'
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
@@ -27,7 +27,7 @@ var rule = createLintRule({
27
27
  },
28
28
  schema: schema,
29
29
  messages: {
30
- 'no-dynamic-styles': 'Dynamic styles are not allowed. Instead use the style prop to apply styles derived from component props.'
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': 'Styles from css, cssMap, keyframes, styled and xcss should not be exported. All styles should be defined and used in the same file instead.'
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': 'Global styles are not allowed.',
24
- 'no-css-modules': 'Importing CSS files is not allowed.'
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': 'Important style declarations are disallowed. Refactor so the `!important` flag is not needed.'
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': 'Styles should not be imported to use in css, cssMap, styled, keyframes or xcss calls. All styles should be defined and used in the same file instead.'
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) {
@@ -56,7 +56,7 @@ var rule = createLintRuleWithTypedConfig({
56
56
  severity: 'error'
57
57
  },
58
58
  messages: {
59
- 'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
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.'
60
60
  },
61
61
  type: 'problem',
62
62
  schema: {
@@ -10,7 +10,7 @@ var rule = createLintRule({
10
10
  severity: 'error'
11
11
  },
12
12
  messages: {
13
- 'no-styled': "Avoid usages of styled, eg. styled.div, styled('div'), styled(Component), etc."
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': 'Pseudo-classes and pseudo-elements without a leading selector are ambiguous. Use a more explicit selector.',
99
- 'no-increased-specificity': 'Do not chain the nesting selector.',
100
- 'no-restricted-pseudos': 'The {{pseudo}} pseudo is not allowed.',
101
- 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements. The single colon syntax is not supported for all pseudo-elements.',
102
- 'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed and is likely an authoring mistake. If you think this is an error reach out in #help-ui-styling-standard.",
103
- 'no-selectors-object': 'Do not use the selectors object. Both nested and advanced selectors should be avoided.',
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
+ '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.',
104
104
  /**
105
105
  * At-rule messages
106
106
  */
107
- 'no-keyframes-at-rules': 'Use the CSS-in-JS `keyframes` API instead of `@keyframes` at-rules.',
108
- 'no-restricted-at-rules': '{{atRule}} at-rule is not allowed.',
109
- 'no-grouped-at-rules': 'Do not group at-rules. Write flattened at-rules instead.',
110
- 'no-noncanonical-media-query': 'Use the exact media query represented by the imported @atlaskit/css/at-rules type.',
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 a nesting selector `&` to target the element itself. This is usually the intended behavior.'
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',
@@ -71,7 +71,7 @@ var rule = createLintRule({
71
71
  severity: 'warn'
72
72
  },
73
73
  messages: {
74
- 'unused-property': 'The "{{propertyName}}" style is defined but never used.'
74
+ '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.'
75
75
  },
76
76
  type: 'problem'
77
77
  },
@@ -53,7 +53,7 @@ var rule = createLintRule({
53
53
  severity: 'error'
54
54
  },
55
55
  messages: {
56
- 'use-compiled': "Use '@atlaskit/css' or '@compiled/react' instead of '{{importSource}}'"
56
+ 'use-compiled': "Migrate '{{importSource}}' styling to @atlaskit/css or @compiled/react, updating imports and usages together. Verify the component rather than mixing styling engines on it."
57
57
  },
58
58
  schema: schema
59
59
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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.13.0",
31
+ "@atlaskit/eslint-plugin-design-system": "^16.15.0",
32
32
  "@atlaskit/eslint-utils": "^3.1.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@typescript-eslint/utils": "^8.64.0",