@atlaskit/eslint-plugin-design-system 10.9.0 → 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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -0
  3. package/constellation/index/usage.mdx +1 -0
  4. package/constellation/no-custom-icons/usage.mdx +36 -0
  5. package/dist/cjs/presets/all.codegen.js +2 -1
  6. package/dist/cjs/rules/ensure-design-token-usage/index.js +199 -227
  7. package/dist/cjs/rules/index.codegen.js +3 -1
  8. package/dist/cjs/rules/no-custom-icons/checks/has-prop.js +12 -0
  9. package/dist/cjs/rules/no-custom-icons/checks/is-from-import-source.js +42 -0
  10. package/dist/cjs/rules/no-custom-icons/checks/is-imported-jsx-element.js +10 -0
  11. package/dist/cjs/rules/no-custom-icons/index.js +67 -0
  12. package/dist/cjs/rules/no-legacy-icons/index.js +11 -83
  13. package/dist/cjs/rules/use-tokens-typography/index.js +4 -8
  14. package/dist/cjs/rules/utils/error-boundary.js +58 -11
  15. package/dist/es2019/presets/all.codegen.js +2 -1
  16. package/dist/es2019/rules/ensure-design-token-usage/index.js +16 -30
  17. package/dist/es2019/rules/index.codegen.js +3 -1
  18. package/dist/es2019/rules/no-custom-icons/checks/has-prop.js +4 -0
  19. package/dist/es2019/rules/no-custom-icons/checks/is-from-import-source.js +23 -0
  20. package/dist/es2019/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  21. package/dist/es2019/rules/no-custom-icons/index.js +61 -0
  22. package/dist/es2019/rules/no-legacy-icons/index.js +11 -65
  23. package/dist/es2019/rules/use-tokens-typography/index.js +3 -7
  24. package/dist/es2019/rules/utils/error-boundary.js +55 -11
  25. package/dist/esm/presets/all.codegen.js +2 -1
  26. package/dist/esm/rules/ensure-design-token-usage/index.js +199 -227
  27. package/dist/esm/rules/index.codegen.js +3 -1
  28. package/dist/esm/rules/no-custom-icons/checks/has-prop.js +6 -0
  29. package/dist/esm/rules/no-custom-icons/checks/is-from-import-source.js +36 -0
  30. package/dist/esm/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  31. package/dist/esm/rules/no-custom-icons/index.js +61 -0
  32. package/dist/esm/rules/no-legacy-icons/index.js +11 -83
  33. package/dist/esm/rules/use-tokens-typography/index.js +4 -8
  34. package/dist/esm/rules/utils/error-boundary.js +56 -10
  35. package/dist/types/index.codegen.d.ts +1 -0
  36. package/dist/types/presets/all.codegen.d.ts +2 -1
  37. package/dist/types/rules/index.codegen.d.ts +1 -0
  38. package/dist/types/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  39. package/dist/types/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  40. package/dist/types/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  41. package/dist/types/rules/no-custom-icons/index.d.ts +3 -0
  42. package/dist/types/rules/no-legacy-icons/index.d.ts +1 -2
  43. package/dist/types/rules/utils/error-boundary.d.ts +8 -5
  44. package/dist/types-ts4.5/index.codegen.d.ts +1 -0
  45. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  46. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  47. package/dist/types-ts4.5/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  48. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  49. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  50. package/dist/types-ts4.5/rules/no-custom-icons/index.d.ts +3 -0
  51. package/dist/types-ts4.5/rules/no-legacy-icons/index.d.ts +1 -2
  52. package/dist/types-ts4.5/rules/utils/error-boundary.d.ts +8 -5
  53. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## 10.9.0
4
12
 
5
13
  ### Minor 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 | | |
@@ -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',
@@ -36,26 +36,18 @@ var createWithConfig = exports.createWithConfig = function createWithConfig(init
36
36
  failSilently: (userConfig === null || userConfig === void 0 ? void 0 : userConfig.failSilently) || defaultConfig.failSilently
37
37
  };
38
38
  var tokenNode = null;
39
- return {
39
+ return (0, _errorBoundary.errorBoundary)({
40
40
  ImportDeclaration: function ImportDeclaration(node) {
41
- return (0, _errorBoundary.errorBoundary)(function () {
42
- if (node.source.value === '@atlaskit/tokens' && config.applyImport) {
43
- tokenNode = node;
44
- }
45
- }, {
46
- config: config
47
- });
41
+ if (node.source.value === '@atlaskit/tokens' && config.applyImport) {
42
+ tokenNode = node;
43
+ }
48
44
  },
49
45
  // For expressions within template literals (e.g. `color: ${red}`) - color only
50
46
  'TemplateLiteral > Identifier': function TemplateLiteralIdentifier(node) {
51
- return (0, _errorBoundary.errorBoundary)(function () {
52
- if (config.domains.includes('color')) {
53
- return (0, _color.lintTemplateIdentifierForColor)(node, context, config);
54
- }
55
- return;
56
- }, {
57
- config: config
58
- });
47
+ if (config.domains.includes('color')) {
48
+ return (0, _color.lintTemplateIdentifierForColor)(node, context, config);
49
+ }
50
+ return;
59
51
  },
60
52
  // const styles = css({ color: 'red', margin: '4px' }), styled.div({ color: 'red', margin: '4px' })
61
53
  ObjectExpression: function (_ObjectExpression) {
@@ -67,263 +59,243 @@ var createWithConfig = exports.createWithConfig = function createWithConfig(init
67
59
  };
68
60
  return ObjectExpression;
69
61
  }(function (parentNode) {
70
- return (0, _errorBoundary.errorBoundary)(function () {
71
- var _context$getScope = context.getScope(),
72
- references = _context$getScope.references;
73
- /**
74
- * NOTE: This rule doesn't have an `importSources` config option,
75
- * so this will just be equal to DEFAULT_IMPORT_SOURCES (which is fine)
76
- */
77
- var importSources = (0, _isSupportedImport.getImportSources)(context);
62
+ var _context$getScope = context.getScope(),
63
+ references = _context$getScope.references;
64
+ /**
65
+ * NOTE: This rule doesn't have an `importSources` config option,
66
+ * so this will just be equal to DEFAULT_IMPORT_SOURCES (which is fine)
67
+ */
68
+ var importSources = (0, _isSupportedImport.getImportSources)(context);
78
69
 
79
- // To force the correct node type
80
- if (!(0, _eslintCodemodUtils.isNodeOfType)(parentNode, 'ObjectExpression')) {
81
- return;
82
- }
70
+ // To force the correct node type
71
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(parentNode, 'ObjectExpression')) {
72
+ return;
73
+ }
83
74
 
84
- // Return for nested objects - these get handled automatically so without returning we'd be doubling up
85
- if (parentNode.parent.type === 'Property') {
75
+ // Return for nested objects - these get handled automatically so without returning we'd be doubling up
76
+ if (parentNode.parent.type === 'Property') {
77
+ return;
78
+ }
79
+ if ((0, _isNode.isDecendantOfXcssBlock)(parentNode, references, importSources)) {
80
+ return;
81
+ }
82
+ if (!(0, _isNode.isDecendantOfStyleBlock)(parentNode) && !(0, _isNode.isDecendantOfType)(parentNode, 'JSXExpressionContainer')) {
83
+ return;
84
+ }
85
+ function findObjectStyles(node) {
86
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'Property')) {
86
87
  return;
87
88
  }
88
- if ((0, _isNode.isDecendantOfXcssBlock)(parentNode, references, importSources)) {
89
+ if ((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'ObjectExpression')) {
90
+ return node.value.properties.forEach(findObjectStyles);
91
+ }
92
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Identifier') && !(0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Literal')) {
89
93
  return;
90
94
  }
91
- if (!(0, _isNode.isDecendantOfStyleBlock)(parentNode) && !(0, _isNode.isDecendantOfType)(parentNode, 'JSXExpressionContainer')) {
95
+ var propertyName = (0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Identifier') ? node.key.name : String(node.key.value);
96
+
97
+ // Returns which domains to lint against based on rule's config and current property
98
+ var domains = (0, _utils.getDomainsForProperty)(propertyName, config.domains);
99
+ if (domains.length === 0 || (0, _isNode.isDecendantOfGlobalToken)(node.value)) {
92
100
  return;
93
101
  }
94
- function findObjectStyles(node) {
95
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'Property')) {
96
- return;
97
- }
98
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'ObjectExpression')) {
99
- return node.value.properties.forEach(findObjectStyles);
100
- }
101
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Identifier') && !(0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Literal')) {
102
- return;
102
+ if ((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'TemplateLiteral')) {
103
+ var value = (0, _utils.getValueFromTemplateLiteralRaw)(node.value, context);
104
+ if (Array.isArray(value) && value.some(_utils.isCalc)) {
105
+ return context.report({
106
+ node: node,
107
+ messageId: 'noCalcUsage',
108
+ data: {
109
+ payload: "".concat(propertyName)
110
+ }
111
+ });
103
112
  }
104
- var propertyName = (0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Identifier') ? node.key.name : String(node.key.value);
105
-
106
- // Returns which domains to lint against based on rule's config and current property
107
- var domains = (0, _utils.getDomainsForProperty)(propertyName, config.domains);
108
- if (domains.length === 0 || (0, _isNode.isDecendantOfGlobalToken)(node.value)) {
113
+ if (node.value.expressions.some(_isNode.isDecendantOfGlobalToken)) {
109
114
  return;
110
115
  }
111
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'TemplateLiteral')) {
112
- var value = (0, _utils.getValueFromTemplateLiteralRaw)(node.value, context);
113
- if (Array.isArray(value) && value.some(_utils.isCalc)) {
114
- return context.report({
115
- node: node,
116
- messageId: 'noCalcUsage',
117
- data: {
118
- payload: "".concat(propertyName)
119
- }
120
- });
121
- }
122
- if (node.value.expressions.some(_isNode.isDecendantOfGlobalToken)) {
123
- return;
124
- }
125
- }
126
- if (domains.includes('color')) {
127
- return (0, _color.lintObjectForColor)(node, context, config);
128
- }
129
- if (domains.includes('spacing') || domains.includes('shape')) {
130
- /**
131
- * We do this in case the fontSize for a style object is declared alongside the `em` or `lineHeight` declaration.
132
- */
133
- var fontSizeNode = (0, _utils.getPropertyNodeFromParent)('fontSize', parentNode);
134
- var fontSize = fontSizeNode && (0, _utils.getValueForPropertyNode)(fontSizeNode, context);
135
- return (0, _spacing.lintObjectForSpacing)(node, context, config, fontSize, tokenNode);
136
- }
137
116
  }
138
- parentNode.properties.forEach(findObjectStyles);
139
- }, {
140
- config: config
141
- });
117
+ if (domains.includes('color')) {
118
+ return (0, _color.lintObjectForColor)(node, context, config);
119
+ }
120
+ if (domains.includes('spacing') || domains.includes('shape')) {
121
+ /**
122
+ * We do this in case the fontSize for a style object is declared alongside the `em` or `lineHeight` declaration.
123
+ */
124
+ var fontSizeNode = (0, _utils.getPropertyNodeFromParent)('fontSize', parentNode);
125
+ var fontSize = fontSizeNode && (0, _utils.getValueForPropertyNode)(fontSizeNode, context);
126
+ return (0, _spacing.lintObjectForSpacing)(node, context, config, fontSize, tokenNode);
127
+ }
128
+ }
129
+ parentNode.properties.forEach(findObjectStyles);
142
130
  }),
143
131
  // CSSTemplateLiteral and StyledTemplateLiteral
144
132
  // const cssTemplateLiteral = css`color: red; padding: 12px`;
145
133
  // const styledTemplateLiteral = styled.p`color: red; padding: 8px`;
146
134
  'TaggedTemplateExpression[tag.name="css"],TaggedTemplateExpression[tag.object.name="styled"],TaggedTemplateExpression[tag.callee.name="styled"]': function TaggedTemplateExpressionTagNameCssTaggedTemplateExpressionTagObjectNameStyledTaggedTemplateExpressionTagCalleeNameStyled(node) {
147
- return (0, _errorBoundary.errorBoundary)(function () {
148
- // To force the correct node type
149
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'TaggedTemplateExpression')) {
150
- return;
151
- }
152
- var processedCssLines = (0, _utils.processCssNode)(node, context);
153
- if (!processedCssLines) {
154
- // if we can't get a processed css we bail
155
- return;
135
+ // To force the correct node type
136
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'TaggedTemplateExpression')) {
137
+ return;
138
+ }
139
+ var processedCssLines = (0, _utils.processCssNode)(node, context);
140
+ if (!processedCssLines) {
141
+ // if we can't get a processed css we bail
142
+ return;
143
+ }
144
+ var globalFontSize = (0, _utils.getFontSizeValueInScope)(processedCssLines);
145
+ var textForSource = context.getSourceCode().getText(node.quasi);
146
+ var allReplacedValues = [];
147
+ var completeSource = processedCssLines.reduce(function (currentSource, _ref) {
148
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
149
+ resolvedCssLine = _ref2[0],
150
+ originalCssLine = _ref2[1];
151
+ var _resolvedCssLine$spli = resolvedCssLine.split(':'),
152
+ _resolvedCssLine$spli2 = (0, _slicedToArray2.default)(_resolvedCssLine$spli, 2),
153
+ originalProperty = _resolvedCssLine$spli2[0],
154
+ resolvedCssValues = _resolvedCssLine$spli2[1];
155
+ var _originalCssLine$spli = originalCssLine.split(':'),
156
+ _originalCssLine$spli2 = (0, _slicedToArray2.default)(_originalCssLine$spli, 2),
157
+ _ = _originalCssLine$spli2[0],
158
+ originalCssValues = _originalCssLine$spli2[1];
159
+ var propertyName = (0, _utils.convertHyphenatedNameToCamelCase)(originalProperty);
160
+ var isFontFamily = /fontFamily/.test(propertyName);
161
+ var replacedValuesPerProperty = [originalProperty];
162
+ var domains = (0, _utils.getDomainsForProperty)(propertyName, config.domains);
163
+ if (domains.length === 0 || !resolvedCssValues) {
164
+ // in both of these cases no changes should be made to the current property
165
+ return currentSource;
156
166
  }
157
- var globalFontSize = (0, _utils.getFontSizeValueInScope)(processedCssLines);
158
- var textForSource = context.getSourceCode().getText(node.quasi);
159
- var allReplacedValues = [];
160
- var completeSource = processedCssLines.reduce(function (currentSource, _ref) {
161
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
162
- resolvedCssLine = _ref2[0],
163
- originalCssLine = _ref2[1];
164
- var _resolvedCssLine$spli = resolvedCssLine.split(':'),
165
- _resolvedCssLine$spli2 = (0, _slicedToArray2.default)(_resolvedCssLine$spli, 2),
166
- originalProperty = _resolvedCssLine$spli2[0],
167
- resolvedCssValues = _resolvedCssLine$spli2[1];
168
- var _originalCssLine$spli = originalCssLine.split(':'),
169
- _originalCssLine$spli2 = (0, _slicedToArray2.default)(_originalCssLine$spli, 2),
170
- _ = _originalCssLine$spli2[0],
171
- originalCssValues = _originalCssLine$spli2[1];
172
- var propertyName = (0, _utils.convertHyphenatedNameToCamelCase)(originalProperty);
173
- var isFontFamily = /fontFamily/.test(propertyName);
174
- var replacedValuesPerProperty = [originalProperty];
175
- var domains = (0, _utils.getDomainsForProperty)(propertyName, config.domains);
176
- if (domains.length === 0 || !resolvedCssValues) {
177
- // in both of these cases no changes should be made to the current property
167
+ if (domains.includes('color')) {
168
+ if ((0, _utils.includesTokenString)(resolvedCssValues.trim())) {
178
169
  return currentSource;
179
170
  }
180
- if (domains.includes('color')) {
181
- if ((0, _utils.includesTokenString)(resolvedCssValues.trim())) {
182
- return currentSource;
183
- }
184
- if ((0, _isColor.includesHardCodedColor)(resolvedCssValues)) {
185
- context.report({
186
- messageId: 'hardCodedColor',
187
- node: node
188
- });
189
- return currentSource;
190
- }
171
+ if ((0, _isColor.includesHardCodedColor)(resolvedCssValues)) {
172
+ context.report({
173
+ messageId: 'hardCodedColor',
174
+ node: node
175
+ });
176
+ return currentSource;
177
+ }
178
+ }
179
+ if (domains.includes('spacing') || domains.includes('shape')) {
180
+ if (!(0, _utils.isValidSpacingValue)(resolvedCssValues, globalFontSize)) {
181
+ // no changes should be made to the current property
182
+ return currentSource;
191
183
  }
192
- if (domains.includes('spacing') || domains.includes('shape')) {
193
- if (!(0, _utils.isValidSpacingValue)(resolvedCssValues, globalFontSize)) {
194
- // no changes should be made to the current property
195
- return currentSource;
196
- }
197
-
198
- // gets the values from the associated property, numeric values or NaN
199
- var processedNumericValues = (0, _utils.getValueFromShorthand)(resolvedCssValues);
200
- var processedValues = (0, _utils.splitShorthandValues)(resolvedCssValues);
201
- // only splits shorthand values but it does not transform NaNs so tokens are preserved
202
- var originalValues = (0, _utils.splitShorthandValues)(originalCssValues);
203
-
204
- // reconstructing the string
205
- // should replace what it can and preserve the raw value for everything else
206
184
 
207
- var replacementValue = processedNumericValues
208
- // put together resolved value and original value on a tuple
209
- .map(function (value, index) {
210
- return [
211
- // if emToPX conversion fails we'll default to original value
212
- (0, _utils.emToPixels)(value, globalFontSize) || value, processedValues[index], originalValues[index]];
213
- }).map(function (_ref3) {
214
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 3),
215
- numericOrNanValue = _ref4[0],
216
- pxValue = _ref4[1],
217
- originalValue = _ref4[2];
218
- if (!originalValue) {
219
- return originalValue;
220
- }
221
- if ((0, _utils.isCalc)(originalValue)) {
222
- context.report({
223
- node: node,
224
- messageId: 'noCalcUsage',
225
- data: {
226
- payload: "".concat(propertyName)
227
- }
228
- });
229
- return originalValue;
230
- }
231
- if ((0, _utils.isTokenValueString)(originalValue)) {
232
- // if the value is already valid, nothing to report or replace
233
- return originalValue;
234
- }
185
+ // gets the values from the associated property, numeric values or NaN
186
+ var processedNumericValues = (0, _utils.getValueFromShorthand)(resolvedCssValues);
187
+ var processedValues = (0, _utils.splitShorthandValues)(resolvedCssValues);
188
+ // only splits shorthand values but it does not transform NaNs so tokens are preserved
189
+ var originalValues = (0, _utils.splitShorthandValues)(originalCssValues);
235
190
 
236
- // do not replace 0 or auto with tokens
237
- if ((0, _utils.isZero)(pxValue) || (0, _utils.isAuto)(pxValue)) {
238
- return originalValue;
239
- }
240
- if (isNaN(numericOrNanValue) && !isFontFamily) {
241
- // do not report if we have nothing to replace with
242
- return originalValue;
243
- }
191
+ // reconstructing the string
192
+ // should replace what it can and preserve the raw value for everything else
244
193
 
245
- // value is numeric or fontFamily, and needs replacing we'll report first
194
+ var replacementValue = processedNumericValues
195
+ // put together resolved value and original value on a tuple
196
+ .map(function (value, index) {
197
+ return [
198
+ // if emToPX conversion fails we'll default to original value
199
+ (0, _utils.emToPixels)(value, globalFontSize) || value, processedValues[index], originalValues[index]];
200
+ }).map(function (_ref3) {
201
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 3),
202
+ numericOrNanValue = _ref4[0],
203
+ pxValue = _ref4[1],
204
+ originalValue = _ref4[2];
205
+ if (!originalValue) {
206
+ return originalValue;
207
+ }
208
+ if ((0, _utils.isCalc)(originalValue)) {
246
209
  context.report({
247
210
  node: node,
248
- messageId: 'noRawSpacingValues',
211
+ messageId: 'noCalcUsage',
249
212
  data: {
250
- payload: "".concat(propertyName, ":").concat(numericOrNanValue)
213
+ payload: "".concat(propertyName)
251
214
  }
252
215
  });
216
+ return originalValue;
217
+ }
218
+ if ((0, _utils.isTokenValueString)(originalValue)) {
219
+ // if the value is already valid, nothing to report or replace
220
+ return originalValue;
221
+ }
253
222
 
254
- // from here on we know value is numeric or a font family, so it might or might not have a token equivalent
255
- var replacementNode = (0, _utils.getTokenReplacement)(propertyName, numericOrNanValue);
256
- if (!replacementNode) {
257
- return originalValue;
258
- }
259
- var replacementToken = '${' + replacementNode.toString() + '}';
260
- replacedValuesPerProperty.push(isFontFamily ? numericOrNanValue.trim() : pxValue);
261
- return replacementToken;
262
- }).join(' ');
263
- if (replacedValuesPerProperty.length > 1) {
264
- // first value is the property name, so it will always have at least 1
265
- allReplacedValues.push(replacedValuesPerProperty);
223
+ // do not replace 0 or auto with tokens
224
+ if ((0, _utils.isZero)(pxValue) || (0, _utils.isAuto)(pxValue)) {
225
+ return originalValue;
226
+ }
227
+ if (isNaN(numericOrNanValue) && !isFontFamily) {
228
+ // do not report if we have nothing to replace with
229
+ return originalValue;
266
230
  }
267
231
 
268
- // replace property:val with new property:val
269
- var replacedCssLine = currentSource.replace(originalCssLine, // padding: ${gridSize()}px;
270
- "".concat(originalProperty, ": ").concat(replacementValue));
271
- if (!replacedCssLine) {
272
- return currentSource;
232
+ // value is numeric or fontFamily, and needs replacing we'll report first
233
+ context.report({
234
+ node: node,
235
+ messageId: 'noRawSpacingValues',
236
+ data: {
237
+ payload: "".concat(propertyName, ":").concat(numericOrNanValue)
238
+ }
239
+ });
240
+
241
+ // from here on we know value is numeric or a font family, so it might or might not have a token equivalent
242
+ var replacementNode = (0, _utils.getTokenReplacement)(propertyName, numericOrNanValue);
243
+ if (!replacementNode) {
244
+ return originalValue;
273
245
  }
274
- return replacedCssLine;
246
+ var replacementToken = '${' + replacementNode.toString() + '}';
247
+ replacedValuesPerProperty.push(isFontFamily ? numericOrNanValue.trim() : pxValue);
248
+ return replacementToken;
249
+ }).join(' ');
250
+ if (replacedValuesPerProperty.length > 1) {
251
+ // first value is the property name, so it will always have at least 1
252
+ allReplacedValues.push(replacedValuesPerProperty);
275
253
  }
276
- return currentSource;
277
- }, textForSource);
278
- if (completeSource !== textForSource) {
279
- // means we found some replacement values, we'll give the option to fix them
280
254
 
281
- context.report({
282
- node: node,
283
- messageId: 'autofixesPossible',
284
- fix: function fix(fixer) {
285
- return (!tokenNode && config.applyImport ? [(0, _utils.insertTokensImport)(fixer)] : []).concat([fixer.replaceText(node.quasi, completeSource)]);
286
- }
287
- });
255
+ // replace property:val with new property:val
256
+ var replacedCssLine = currentSource.replace(originalCssLine, // padding: ${gridSize()}px;
257
+ "".concat(originalProperty, ": ").concat(replacementValue));
258
+ if (!replacedCssLine) {
259
+ return currentSource;
260
+ }
261
+ return replacedCssLine;
288
262
  }
289
- }, {
290
- config: config
291
- });
263
+ return currentSource;
264
+ }, textForSource);
265
+ if (completeSource !== textForSource) {
266
+ // means we found some replacement values, we'll give the option to fix them
267
+
268
+ context.report({
269
+ node: node,
270
+ messageId: 'autofixesPossible',
271
+ fix: function fix(fixer) {
272
+ return (!tokenNode && config.applyImport ? [(0, _utils.insertTokensImport)(fixer)] : []).concat([fixer.replaceText(node.quasi, completeSource)]);
273
+ }
274
+ });
275
+ }
292
276
  },
293
277
  // For inline JSX styles - literals (e.g. <Test color="red"/>) - color only
294
278
  'JSXAttribute > Literal': function JSXAttributeLiteral(node) {
295
- return (0, _errorBoundary.errorBoundary)(function () {
296
- if (config.domains.includes('color')) {
297
- return (0, _color.lintJSXLiteralForColor)(node, context, config);
298
- }
299
- return;
300
- }, {
301
- config: config
302
- });
279
+ if (config.domains.includes('color')) {
280
+ return (0, _color.lintJSXLiteralForColor)(node, context, config);
281
+ }
282
+ return;
303
283
  },
304
284
  // For inline JSX styles - members (e.g. <Test color={color.red}/>) - color only
305
285
  'JSXExpressionContainer > MemberExpression': function JSXExpressionContainerMemberExpression(node) {
306
- return (0, _errorBoundary.errorBoundary)(function () {
307
- if (config.domains.includes('color')) {
308
- return (0, _color.lintJSXMemberForColor)(node, context, config);
309
- }
310
- return;
311
- }, {
312
- config: config
313
- });
286
+ if (config.domains.includes('color')) {
287
+ return (0, _color.lintJSXMemberForColor)(node, context, config);
288
+ }
289
+ return;
314
290
  },
315
291
  // For inline JSX styles - identifiers (e.g. <Test color={red}/>) - color only
316
292
  'JSXExpressionContainer > Identifier': function JSXExpressionContainerIdentifier(node) {
317
- return (0, _errorBoundary.errorBoundary)(function () {
318
- if (config.domains.includes('color')) {
319
- return (0, _color.lintJSXIdentifierForColor)(node, context, config);
320
- }
321
- return;
322
- }, {
323
- config: config
324
- });
293
+ if (config.domains.includes('color')) {
294
+ return (0, _color.lintJSXIdentifierForColor)(node, context, config);
295
+ }
296
+ return;
325
297
  }
326
- };
298
+ }, config);
327
299
  };
328
300
  };
329
301
  var rule = (0, _createRule.createLintRule)({
@@ -11,6 +11,7 @@ var _ensureDesignTokenUsagePreview = _interopRequireDefault(require("./ensure-de
11
11
  var _iconLabel = _interopRequireDefault(require("./icon-label"));
12
12
  var _noBannedImports = _interopRequireDefault(require("./no-banned-imports"));
13
13
  var _noCssTaggedTemplateExpression = _interopRequireDefault(require("./no-css-tagged-template-expression"));
14
+ var _noCustomIcons = _interopRequireDefault(require("./no-custom-icons"));
14
15
  var _noDeprecatedApis = _interopRequireDefault(require("./no-deprecated-apis"));
15
16
  var _noDeprecatedDesignTokenUsage = _interopRequireDefault(require("./no-deprecated-design-token-usage"));
16
17
  var _noDeprecatedImports = _interopRequireDefault(require("./no-deprecated-imports"));
@@ -47,7 +48,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
47
48
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
48
49
  /**
49
50
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
50
- * @codegen <<SignedSource::b359d356c482db0087ddfce5bd105403>>
51
+ * @codegen <<SignedSource::402e6eb5433560b1032e5ed926bb5564>>
51
52
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
52
53
  */
53
54
  var _default = exports.default = {
@@ -57,6 +58,7 @@ var _default = exports.default = {
57
58
  'icon-label': _iconLabel.default,
58
59
  'no-banned-imports': _noBannedImports.default,
59
60
  'no-css-tagged-template-expression': _noCssTaggedTemplateExpression.default,
61
+ 'no-custom-icons': _noCustomIcons.default,
60
62
  'no-deprecated-apis': _noDeprecatedApis.default,
61
63
  'no-deprecated-design-token-usage': _noDeprecatedDesignTokenUsage.default,
62
64
  'no-deprecated-imports': _noDeprecatedImports.default,
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasProp = hasProp;
7
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
8
+ function hasProp(node, propName) {
9
+ return (0, _eslintCodemodUtils.isNodeOfType)(node.openingElement, 'JSXOpeningElement') && node.openingElement.attributes.some(function (a) {
10
+ return a.type === 'JSXAttribute' && a.name.name === propName;
11
+ });
12
+ }