@atlaskit/eslint-plugin-design-system 13.20.0 → 13.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2896429aaa267`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2896429aaa267) -
8
+ Update the no-custom-icons eslint rule to include checking for custom svg usage
9
+
3
10
  ## 13.20.0
4
11
 
5
12
  ### Minor Changes
@@ -30,11 +30,12 @@ var rule = (0, _createRule.createLintRule)({
30
30
  additionalProperties: false
31
31
  }],
32
32
  messages: {
33
- noCustomIcons: "Custom icons from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.\n[Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide)."
33
+ noCustomIcons: "Custom icons/svgs from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.\n[Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide)."
34
34
  }
35
35
  },
36
36
  create: function create(context) {
37
37
  var _context$options$;
38
+ var isIconSvg = (0, _isFromImportSource.createIsFromImportSourceFor)('@atlaskit/icon/svg');
38
39
  var isIconBase = (0, _isFromImportSource.createIsFromImportSourceFor)('@atlaskit/icon', '@atlaskit/icon/base');
39
40
 
40
41
  // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
@@ -43,14 +44,25 @@ var rule = (0, _createRule.createLintRule)({
43
44
  centralLocation = _ref$centralLocation === void 0 ? '' : _ref$centralLocation,
44
45
  _ref$failSilently = _ref.failSilently,
45
46
  failSilently = _ref$failSilently === void 0 ? false : _ref$failSilently;
47
+ function checkNode(node) {
48
+ isIconBase.importDeclarationHook(node);
49
+ isIconSvg.importDeclarationHook(node);
50
+ }
46
51
  var locationMessage = centralLocation ? ", move the icon to '".concat(centralLocation, "', or, if it's a third party logo, migrate to a standard <svg> element with a `label`.") : '';
47
52
  return (0, _errorBoundary.errorBoundary)({
48
53
  JSXElement: function JSXElement(node) {
49
- var _isIconBase$getImport;
50
- if (!isIconBase(node) || !(0, _hasProp.hasProp)(node, 'glyph')) {
54
+ var isSvg = isIconSvg(node);
55
+ var isBase = isIconBase(node);
56
+ // Not an icon import
57
+ if (!isSvg && (!isBase || !(0, _hasProp.hasProp)(node, 'glyph'))) {
51
58
  return;
52
59
  }
53
- var importSource = (_isIconBase$getImport = isIconBase.getImportSource(node)) !== null && _isIconBase$getImport !== void 0 ? _isIconBase$getImport : '';
60
+ var importSource = '';
61
+ if (isSvg) {
62
+ importSource = isIconSvg.getImportSource(node);
63
+ } else if (isBase) {
64
+ importSource = isIconBase.getImportSource(node);
65
+ }
54
66
  context.report({
55
67
  node: node.openingElement,
56
68
  messageId: 'noCustomIcons',
@@ -60,7 +72,7 @@ var rule = (0, _createRule.createLintRule)({
60
72
  }
61
73
  });
62
74
  },
63
- ImportDeclaration: isIconBase.importDeclarationHook
75
+ ImportDeclaration: checkNode
64
76
  }, failSilently);
65
77
  }
66
78
  });
@@ -24,12 +24,13 @@ const rule = createLintRule({
24
24
  additionalProperties: false
25
25
  }],
26
26
  messages: {
27
- noCustomIcons: `Custom icons from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.
27
+ noCustomIcons: `Custom icons/svgs from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.
28
28
  [Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide).`
29
29
  }
30
30
  },
31
31
  create(context) {
32
32
  var _context$options$;
33
+ const isIconSvg = createIsFromImportSourceFor('@atlaskit/icon/svg');
33
34
  const isIconBase = createIsFromImportSourceFor('@atlaskit/icon', '@atlaskit/icon/base');
34
35
 
35
36
  // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
@@ -37,14 +38,25 @@ const rule = createLintRule({
37
38
  centralLocation = '',
38
39
  failSilently = false
39
40
  } = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {};
41
+ function checkNode(node) {
42
+ isIconBase.importDeclarationHook(node);
43
+ isIconSvg.importDeclarationHook(node);
44
+ }
40
45
  const locationMessage = centralLocation ? `, move the icon to '${centralLocation}', or, if it's a third party logo, migrate to a standard <svg> element with a \`label\`.` : '';
41
46
  return errorBoundary({
42
47
  JSXElement(node) {
43
- var _isIconBase$getImport;
44
- if (!isIconBase(node) || !hasProp(node, 'glyph')) {
48
+ const isSvg = isIconSvg(node);
49
+ const isBase = isIconBase(node);
50
+ // Not an icon import
51
+ if (!isSvg && (!isBase || !hasProp(node, 'glyph'))) {
45
52
  return;
46
53
  }
47
- const importSource = (_isIconBase$getImport = isIconBase.getImportSource(node)) !== null && _isIconBase$getImport !== void 0 ? _isIconBase$getImport : '';
54
+ let importSource = '';
55
+ if (isSvg) {
56
+ importSource = isIconSvg.getImportSource(node);
57
+ } else if (isBase) {
58
+ importSource = isIconBase.getImportSource(node);
59
+ }
48
60
  context.report({
49
61
  node: node.openingElement,
50
62
  messageId: 'noCustomIcons',
@@ -54,7 +66,7 @@ const rule = createLintRule({
54
66
  }
55
67
  });
56
68
  },
57
- ImportDeclaration: isIconBase.importDeclarationHook
69
+ ImportDeclaration: checkNode
58
70
  }, failSilently);
59
71
  }
60
72
  });
@@ -24,11 +24,12 @@ var rule = createLintRule({
24
24
  additionalProperties: false
25
25
  }],
26
26
  messages: {
27
- noCustomIcons: "Custom icons from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.\n[Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide)."
27
+ noCustomIcons: "Custom icons/svgs from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.\n[Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide)."
28
28
  }
29
29
  },
30
30
  create: function create(context) {
31
31
  var _context$options$;
32
+ var isIconSvg = createIsFromImportSourceFor('@atlaskit/icon/svg');
32
33
  var isIconBase = createIsFromImportSourceFor('@atlaskit/icon', '@atlaskit/icon/base');
33
34
 
34
35
  // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
@@ -37,14 +38,25 @@ var rule = createLintRule({
37
38
  centralLocation = _ref$centralLocation === void 0 ? '' : _ref$centralLocation,
38
39
  _ref$failSilently = _ref.failSilently,
39
40
  failSilently = _ref$failSilently === void 0 ? false : _ref$failSilently;
41
+ function checkNode(node) {
42
+ isIconBase.importDeclarationHook(node);
43
+ isIconSvg.importDeclarationHook(node);
44
+ }
40
45
  var locationMessage = centralLocation ? ", move the icon to '".concat(centralLocation, "', or, if it's a third party logo, migrate to a standard <svg> element with a `label`.") : '';
41
46
  return errorBoundary({
42
47
  JSXElement: function JSXElement(node) {
43
- var _isIconBase$getImport;
44
- if (!isIconBase(node) || !hasProp(node, 'glyph')) {
48
+ var isSvg = isIconSvg(node);
49
+ var isBase = isIconBase(node);
50
+ // Not an icon import
51
+ if (!isSvg && (!isBase || !hasProp(node, 'glyph'))) {
45
52
  return;
46
53
  }
47
- var importSource = (_isIconBase$getImport = isIconBase.getImportSource(node)) !== null && _isIconBase$getImport !== void 0 ? _isIconBase$getImport : '';
54
+ var importSource = '';
55
+ if (isSvg) {
56
+ importSource = isIconSvg.getImportSource(node);
57
+ } else if (isBase) {
58
+ importSource = isIconBase.getImportSource(node);
59
+ }
48
60
  context.report({
49
61
  node: node.openingElement,
50
62
  messageId: 'noCustomIcons',
@@ -54,7 +66,7 @@ var rule = createLintRule({
54
66
  }
55
67
  });
56
68
  },
57
- ImportDeclaration: isIconBase.importDeclarationHook
69
+ ImportDeclaration: checkNode
58
70
  }, failSilently);
59
71
  }
60
72
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.20.0",
4
+ "version": "13.20.1",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/eslint-utils": "^2.0.0",
46
46
  "@atlaskit/icon": "^28.1.0",
47
47
  "@atlaskit/icon-lab": "^5.7.0",
48
- "@atlaskit/tokens": "^6.1.0",
48
+ "@atlaskit/tokens": "^6.3.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "@typescript-eslint/utils": "^7.1.0",
51
51
  "ajv": "^6.12.6",