@atlaskit/eslint-plugin-design-system 10.8.2 → 10.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/constellation/consistent-css-prop-usage/usage.mdx +9 -0
  4. package/constellation/index/usage.mdx +1 -0
  5. package/constellation/no-custom-icons/usage.mdx +36 -0
  6. package/dist/cjs/presets/all.codegen.js +2 -1
  7. package/dist/cjs/rules/consistent-css-prop-usage/index.js +19 -2
  8. package/dist/cjs/rules/ensure-design-token-usage/index.js +199 -227
  9. package/dist/cjs/rules/index.codegen.js +3 -1
  10. package/dist/cjs/rules/no-custom-icons/checks/has-prop.js +12 -0
  11. package/dist/cjs/rules/no-custom-icons/checks/is-from-import-source.js +42 -0
  12. package/dist/cjs/rules/no-custom-icons/checks/is-imported-jsx-element.js +10 -0
  13. package/dist/cjs/rules/no-custom-icons/index.js +67 -0
  14. package/dist/cjs/rules/no-legacy-icons/index.js +11 -83
  15. package/dist/cjs/rules/use-tokens-typography/index.js +4 -8
  16. package/dist/cjs/rules/utils/error-boundary.js +58 -11
  17. package/dist/es2019/presets/all.codegen.js +2 -1
  18. package/dist/es2019/rules/consistent-css-prop-usage/index.js +19 -2
  19. package/dist/es2019/rules/ensure-design-token-usage/index.js +16 -30
  20. package/dist/es2019/rules/index.codegen.js +3 -1
  21. package/dist/es2019/rules/no-custom-icons/checks/has-prop.js +4 -0
  22. package/dist/es2019/rules/no-custom-icons/checks/is-from-import-source.js +23 -0
  23. package/dist/es2019/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  24. package/dist/es2019/rules/no-custom-icons/index.js +61 -0
  25. package/dist/es2019/rules/no-legacy-icons/index.js +11 -65
  26. package/dist/es2019/rules/use-tokens-typography/index.js +3 -7
  27. package/dist/es2019/rules/utils/error-boundary.js +55 -11
  28. package/dist/esm/presets/all.codegen.js +2 -1
  29. package/dist/esm/rules/consistent-css-prop-usage/index.js +19 -2
  30. package/dist/esm/rules/ensure-design-token-usage/index.js +199 -227
  31. package/dist/esm/rules/index.codegen.js +3 -1
  32. package/dist/esm/rules/no-custom-icons/checks/has-prop.js +6 -0
  33. package/dist/esm/rules/no-custom-icons/checks/is-from-import-source.js +36 -0
  34. package/dist/esm/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  35. package/dist/esm/rules/no-custom-icons/index.js +61 -0
  36. package/dist/esm/rules/no-legacy-icons/index.js +11 -83
  37. package/dist/esm/rules/use-tokens-typography/index.js +4 -8
  38. package/dist/esm/rules/utils/error-boundary.js +56 -10
  39. package/dist/types/index.codegen.d.ts +1 -0
  40. package/dist/types/presets/all.codegen.d.ts +2 -1
  41. package/dist/types/rules/consistent-css-prop-usage/types.d.ts +1 -0
  42. package/dist/types/rules/index.codegen.d.ts +1 -0
  43. package/dist/types/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  44. package/dist/types/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  45. package/dist/types/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  46. package/dist/types/rules/no-custom-icons/index.d.ts +3 -0
  47. package/dist/types/rules/no-legacy-icons/index.d.ts +1 -2
  48. package/dist/types/rules/utils/error-boundary.d.ts +8 -5
  49. package/dist/types-ts4.5/index.codegen.d.ts +1 -0
  50. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  51. package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +1 -0
  52. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  53. package/dist/types-ts4.5/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  54. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  55. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  56. package/dist/types-ts4.5/rules/no-custom-icons/index.d.ts +3 -0
  57. package/dist/types-ts4.5/rules/no-legacy-icons/index.d.ts +1 -2
  58. package/dist/types-ts4.5/rules/utils/error-boundary.d.ts +8 -5
  59. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 10.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#116426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116426)
8
+ [`29d6c074c76ea`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/29d6c074c76ea) -
9
+ Add lint rule to detect use of custom icons
10
+
11
+ ## 10.9.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#116062](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116062)
16
+ [`2959497ccf910`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2959497ccf910) -
17
+ Adds `shouldAlwaysCheckXcss` config option to `consistent-css-prop-usage` to lint the `xcss` prop
18
+ even when `excludeReactComponents` is enabled.
19
+
3
20
  ## 10.8.2
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -55,6 +55,7 @@ module.exports = {
55
55
  | <a href="./src/rules/icon-label/README.md">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
56
56
  | <a href="./src/rules/no-banned-imports/README.md">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
57
57
  | <a href="./src/rules/no-css-tagged-template-expression/README.md">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
58
+ | <a href="./src/rules/no-custom-icons/README.md">no-custom-icons</a> | Enforces custom glyph icons are used. | | | |
58
59
  | <a href="./src/rules/no-deprecated-apis/README.md">no-deprecated-apis</a> | Disallow using deprecated APIs. | Yes | | |
59
60
  | <a href="./src/rules/no-deprecated-design-token-usage/README.md">no-deprecated-design-token-usage</a> | Disallow using deprecated design tokens. | Yes | Yes | |
60
61
  | <a href="./src/rules/no-deprecated-imports/README.md">no-deprecated-imports</a> | Disallow importing deprecated modules. | Yes | | |
@@ -193,6 +193,15 @@ assume that an element is a React component if its name starts with a capital le
193
193
 
194
194
  This is `false` by default.
195
195
 
196
+ ### shouldAlwaysCheckXcss
197
+
198
+ Overrides `excludeReactComponents` specifically for the `xcss` prop.
199
+
200
+ This means that even if `excludeReactComponents` is `true`, you can still lint the `xcss` prop by
201
+ setting `shouldAlwaysCheckXcss` to `true`.
202
+
203
+ This is `false` by default.
204
+
196
205
  ### autoFix
197
206
 
198
207
  When set to `true`, this rule will turn on the autofixer. Set this to `false` if you do not want the
@@ -18,6 +18,7 @@ This plugin contains rules that should be used when working with the
18
18
  | <a href="/components/eslint-plugin-design-system/icon-label/usage">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
19
19
  | <a href="/components/eslint-plugin-design-system/no-banned-imports/usage">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
20
20
  | <a href="/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
21
+ | <a href="/components/eslint-plugin-design-system/no-custom-icons/usage">no-custom-icons</a> | Enforces custom glyph icons are used. | | | |
21
22
  | <a href="/components/eslint-plugin-design-system/no-deprecated-apis/usage">no-deprecated-apis</a> | Disallow using deprecated APIs. | Yes | | |
22
23
  | <a href="/components/eslint-plugin-design-system/no-deprecated-design-token-usage/usage">no-deprecated-design-token-usage</a> | Disallow using deprecated design tokens. | Yes | Yes | |
23
24
  | <a href="/components/eslint-plugin-design-system/no-deprecated-imports/usage">no-deprecated-imports</a> | Disallow importing deprecated modules. | Yes | | |
@@ -0,0 +1,36 @@
1
+ # no-custom-icons
2
+
3
+ Icons are being updated with new designs, a simplified set of available icons and sizes, as well as
4
+ more consistent padding and spacing.
5
+
6
+ The new icon components allows your components to align with the new visual language - either by
7
+ default, or when enabled via a feature flag.
8
+
9
+ Custom icons are no longer supported, and should either be replaced with an existing icon from the
10
+ `@atlaskit/icon` or `@atlassian/icon-lab` packages, or contributed to those packages.
11
+
12
+ During the migration process, any custom icons should be moved into a central location to disable
13
+ this error and allow the icon to be quickly replaced. What location to display in the error can be
14
+ configured via the legacyIconPackages option.
15
+
16
+ ## Examples
17
+
18
+ This rule identifies usages of custom icons from `@atlaskit/icon` or `@atlaskit/icon/base`.
19
+
20
+ ### Incorrect
21
+
22
+ ```js
23
+ import Icon from '@atlaskit/icon';
24
+ ^^^^^^^^^^^^^^^^^ custom icon import
25
+
26
+ <Icon label="Activity" glyph="...">
27
+ ^^^^^^^^^^^^^^^^^^^^^^^ custom icon
28
+ ```
29
+
30
+ ### Correct
31
+
32
+ ```js
33
+ import AddIcon from '@atlaskit/icon/core/add';
34
+
35
+ <AddIcon label="" />;
36
+ ```
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::9bb5329713677543f16019954484ae2f>>
9
+ * @codegen <<SignedSource::ab43b6e1a867d07b9a27eae78d48834a>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
  var _default = exports.default = {
@@ -18,6 +18,7 @@ var _default = exports.default = {
18
18
  '@atlaskit/design-system/icon-label': 'warn',
19
19
  '@atlaskit/design-system/no-banned-imports': 'error',
20
20
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
21
+ '@atlaskit/design-system/no-custom-icons': 'warn',
21
22
  '@atlaskit/design-system/no-deprecated-apis': 'error',
22
23
  '@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
23
24
  '@atlaskit/design-system/no-deprecated-imports': 'error',
@@ -497,7 +497,8 @@ var defaultConfig = {
497
497
  cssImportSource: _isSupportedImport.CSS_IN_JS_IMPORTS.compiled,
498
498
  xcssImportSource: _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitPrimitives,
499
499
  excludeReactComponents: false,
500
- autoFix: true
500
+ autoFix: true,
501
+ shouldAlwaysCheckXcss: false
501
502
  };
502
503
  var rule = (0, _createRule.createLintRule)({
503
504
  meta: {
@@ -540,6 +541,9 @@ var rule = (0, _createRule.createLintRule)({
540
541
  excludeReactComponents: {
541
542
  type: 'boolean'
542
543
  },
544
+ shouldAlwaysCheckXcss: {
545
+ type: 'boolean'
546
+ },
543
547
  autoFix: {
544
548
  type: 'boolean'
545
549
  }
@@ -554,7 +558,20 @@ var rule = (0, _createRule.createLintRule)({
554
558
  var node = nodeOriginal;
555
559
  var name = node.name,
556
560
  value = node.value;
557
- if (mergedConfig.excludeReactComponents && node.parent.type === 'JSXOpeningElement') {
561
+
562
+ /**
563
+ * We skip linting `xcss` attributes if:
564
+ *
565
+ * - excludeReactComponents === true
566
+ * - shouldAlwaysCheckXcss === false
567
+ *
568
+ * In the future we may want to remove `shouldAlwaysCheckXcss`
569
+ * and just always lint `xcss`, regardless of `excludeReactComponents`
570
+ */
571
+ if (mergedConfig.excludeReactComponents && name.name === 'xcss' && !mergedConfig.shouldAlwaysCheckXcss) {
572
+ return;
573
+ }
574
+ if (mergedConfig.excludeReactComponents && node.parent.type === 'JSXOpeningElement' && name.name === 'css') {
558
575
  // e.g. <item.before />
559
576
  if (node.parent.name.type === 'JSXMemberExpression') {
560
577
  return;