@atlaskit/eslint-plugin-design-system 9.1.0 → 9.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 9.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#84330](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84330) [`391be0d8e414`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/391be0d8e414) - - `prefer-primitives`: This rule is now deprecated. Please use `use-primitives` instead.
8
+ - `ensure-design-token-usage/preview`: This rule is now deprecated. Please use `use-tokens-space` instead.
9
+
3
10
  ## 9.1.0
4
11
 
5
12
  ### Minor Changes
@@ -6,25 +6,31 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _ensureDesignTokenUsage = require("../ensure-design-token-usage");
10
9
  var _ruleMeta = _interopRequireDefault(require("../ensure-design-token-usage/rule-meta"));
11
10
  var _createRule = require("../utils/create-rule");
12
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- var defaultConfig = {
15
- domains: ['spacing'],
16
- applyImport: true,
17
- shouldEnforceFallbacks: false
18
- };
19
13
  var rule = (0, _createRule.createLintRule)({
20
14
  meta: _objectSpread(_objectSpread({}, _ruleMeta.default), {}, {
21
15
  name: 'ensure-design-token-usage/preview',
16
+ deprecated: true,
17
+ replacedBy: ['@atlaskit/design-system/use-tokens-space'],
22
18
  docs: _objectSpread(_objectSpread({}, _ruleMeta.default.docs), {}, {
23
19
  description: 'Enforces usage of pre-release design tokens rather than hard-coded values.',
24
20
  recommended: false,
25
21
  severity: 'warn'
26
22
  })
27
23
  }),
28
- create: (0, _ensureDesignTokenUsage.createWithConfig)(defaultConfig)
24
+ create: function create() {
25
+ /**
26
+ * We can't just outright delete the ESLint rule, since:
27
+ * ```
28
+ * // eslint-disable @eslint-plugin/design-system/ensure-design-token-usage/preview
29
+ * ```
30
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
31
+ * we can change the implementation of the rule so that it never reports.
32
+ */
33
+ return {};
34
+ }
29
35
  });
30
36
  var _default = exports.default = rule;
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _eslintCodemodUtils = require("eslint-codemod-utils");
8
7
  var _createRule = require("../utils/create-rule");
9
- var _utils = require("./utils");
10
- // eslint-disable-next-line import/no-extraneous-dependencies
11
-
12
8
  var primitiveDocsUrl = 'https://go.atlassian.com/dst-prefer-primitives';
13
9
  var rule = (0, _createRule.createLintRule)({
14
10
  meta: {
15
11
  name: 'prefer-primitives',
16
12
  type: 'suggestion',
17
13
  hasSuggestions: false,
14
+ deprecated: true,
15
+ replacedBy: ['@atlaskit/design-system/use-primitives'],
18
16
  docs: {
19
17
  description: 'Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule.',
20
18
  recommended: false,
@@ -24,84 +22,16 @@ var rule = (0, _createRule.createLintRule)({
24
22
  preferPrimitives: "This \"{{element}}\" may be able to be replaced with a primitive component. See ".concat(primitiveDocsUrl, " for guidance.")
25
23
  }
26
24
  },
27
- create: function create(context) {
28
- return {
29
- // Look for HTML elements - <div>, <span>
30
- // Look for styled calls/templates - styled.div(...), styled.span`...`
31
- JSXOpeningElement: function JSXOpeningElement(node) {
32
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXOpeningElement')) {
33
- return;
34
- }
35
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node.name, 'JSXIdentifier')) {
36
- return;
37
- }
38
- var suggest = (0, _utils.shouldSuggest)(node === null || node === void 0 ? void 0 : node.parent);
39
- if (suggest) {
40
- context.report({
41
- node: node,
42
- messageId: 'preferPrimitives',
43
- data: {
44
- element: node.name.name
45
- }
46
- });
47
- }
48
- },
49
- // styled.x`` | styled2.x`` | styled.div()
50
- 'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': function MemberExpressionObjectNameStyledMemberExpressionObjectNameStyled2(node) {
51
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'MemberExpression')) {
52
- return;
53
- }
54
-
55
- // styled.div``
56
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.property, 'Identifier')) {
57
- if (_utils.validPrimitiveElements.has(node.property.name)) {
58
- var styledIdentifier = node.object.name;
59
- var elementName = node.property.name;
60
-
61
- // Including the `styled.` portion in the message to help makers understand it's not just the `div` element that should be replaced
62
- var reportName = "".concat(styledIdentifier, ".").concat(elementName); // styled.div
63
-
64
- context.report({
65
- node: node,
66
- messageId: 'preferPrimitives',
67
- data: {
68
- element: reportName
69
- }
70
- });
71
- }
72
- }
73
- },
74
- // styled(X)``
75
- 'CallExpression[callee.name="styled"]': function CallExpressionCalleeNameStyled(node) {
76
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
77
- return;
78
- }
79
-
80
- // styled('div')`` - We only care about 'div'/'span', ignore extending other components
81
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.arguments[0], 'Literal')) {
82
- var argValue = node.arguments[0].raw;
83
- if (typeof argValue === 'string') {
84
- var suggest = _utils.validPrimitiveElements.has(argValue.replaceAll("'", '') // argValue will have '' around the element name, strip it out for this test
85
- );
86
- if (suggest) {
87
- var styledIdentifier = node.callee.name;
88
- var elementName = argValue;
89
-
90
- // Including the `styled()` portion in the message to help makers understand it's not just the `div` element that should be replaced
91
- var reportName = "".concat(styledIdentifier, "(").concat(elementName, ")"); // styled('div')
92
-
93
- context.report({
94
- node: node,
95
- messageId: 'preferPrimitives',
96
- data: {
97
- element: reportName
98
- }
99
- });
100
- }
101
- }
102
- }
103
- }
104
- };
25
+ create: function create() {
26
+ /**
27
+ * We can't just outright delete the ESLint rule, since:
28
+ * ```
29
+ * // eslint-disable @eslint-plugin/design-system/prefer-primitives
30
+ * ```
31
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
32
+ * we can change the implementation of the rule so that it never reports.
33
+ */
34
+ return {};
105
35
  }
106
36
  });
107
37
  var _default = exports.default = rule;
@@ -1,15 +1,11 @@
1
- import { createWithConfig } from '../ensure-design-token-usage';
2
1
  import ruleMeta from '../ensure-design-token-usage/rule-meta';
3
2
  import { createLintRule } from '../utils/create-rule';
4
- const defaultConfig = {
5
- domains: ['spacing'],
6
- applyImport: true,
7
- shouldEnforceFallbacks: false
8
- };
9
3
  const rule = createLintRule({
10
4
  meta: {
11
5
  ...ruleMeta,
12
6
  name: 'ensure-design-token-usage/preview',
7
+ deprecated: true,
8
+ replacedBy: ['@atlaskit/design-system/use-tokens-space'],
13
9
  docs: {
14
10
  ...ruleMeta.docs,
15
11
  description: 'Enforces usage of pre-release design tokens rather than hard-coded values.',
@@ -17,6 +13,16 @@ const rule = createLintRule({
17
13
  severity: 'warn'
18
14
  }
19
15
  },
20
- create: createWithConfig(defaultConfig)
16
+ create() {
17
+ /**
18
+ * We can't just outright delete the ESLint rule, since:
19
+ * ```
20
+ * // eslint-disable @eslint-plugin/design-system/ensure-design-token-usage/preview
21
+ * ```
22
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
23
+ * we can change the implementation of the rule so that it never reports.
24
+ */
25
+ return {};
26
+ }
21
27
  });
22
28
  export default rule;
@@ -1,14 +1,12 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
-
3
- import { isNodeOfType } from 'eslint-codemod-utils';
4
1
  import { createLintRule } from '../utils/create-rule';
5
- import { shouldSuggest, validPrimitiveElements } from './utils';
6
2
  const primitiveDocsUrl = 'https://go.atlassian.com/dst-prefer-primitives';
7
3
  const rule = createLintRule({
8
4
  meta: {
9
5
  name: 'prefer-primitives',
10
6
  type: 'suggestion',
11
7
  hasSuggestions: false,
8
+ deprecated: true,
9
+ replacedBy: ['@atlaskit/design-system/use-primitives'],
12
10
  docs: {
13
11
  description: 'Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule.',
14
12
  recommended: false,
@@ -18,85 +16,16 @@ const rule = createLintRule({
18
16
  preferPrimitives: `This "{{element}}" may be able to be replaced with a primitive component. See ${primitiveDocsUrl} for guidance.`
19
17
  }
20
18
  },
21
- create(context) {
22
- return {
23
- // Look for HTML elements - <div>, <span>
24
- // Look for styled calls/templates - styled.div(...), styled.span`...`
25
-
26
- JSXOpeningElement(node) {
27
- if (!isNodeOfType(node, 'JSXOpeningElement')) {
28
- return;
29
- }
30
- if (!isNodeOfType(node.name, 'JSXIdentifier')) {
31
- return;
32
- }
33
- const suggest = shouldSuggest(node === null || node === void 0 ? void 0 : node.parent);
34
- if (suggest) {
35
- context.report({
36
- node: node,
37
- messageId: 'preferPrimitives',
38
- data: {
39
- element: node.name.name
40
- }
41
- });
42
- }
43
- },
44
- // styled.x`` | styled2.x`` | styled.div()
45
- 'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': node => {
46
- if (!isNodeOfType(node, 'MemberExpression')) {
47
- return;
48
- }
49
-
50
- // styled.div``
51
- if (isNodeOfType(node.property, 'Identifier')) {
52
- if (validPrimitiveElements.has(node.property.name)) {
53
- const styledIdentifier = node.object.name;
54
- const elementName = node.property.name;
55
-
56
- // Including the `styled.` portion in the message to help makers understand it's not just the `div` element that should be replaced
57
- const reportName = `${styledIdentifier}.${elementName}`; // styled.div
58
-
59
- context.report({
60
- node: node,
61
- messageId: 'preferPrimitives',
62
- data: {
63
- element: reportName
64
- }
65
- });
66
- }
67
- }
68
- },
69
- // styled(X)``
70
- 'CallExpression[callee.name="styled"]': node => {
71
- if (!isNodeOfType(node, 'CallExpression')) {
72
- return;
73
- }
74
-
75
- // styled('div')`` - We only care about 'div'/'span', ignore extending other components
76
- if (isNodeOfType(node.arguments[0], 'Literal')) {
77
- const argValue = node.arguments[0].raw;
78
- if (typeof argValue === 'string') {
79
- const suggest = validPrimitiveElements.has(argValue.replaceAll(`'`, '') // argValue will have '' around the element name, strip it out for this test
80
- );
81
- if (suggest) {
82
- const styledIdentifier = node.callee.name;
83
- const elementName = argValue;
84
-
85
- // Including the `styled()` portion in the message to help makers understand it's not just the `div` element that should be replaced
86
- const reportName = `${styledIdentifier}(${elementName})`; // styled('div')
87
-
88
- context.report({
89
- node: node,
90
- messageId: 'preferPrimitives',
91
- data: {
92
- element: reportName
93
- }
94
- });
95
- }
96
- }
97
- }
98
- }
99
- };
19
+ create() {
20
+ /**
21
+ * We can't just outright delete the ESLint rule, since:
22
+ * ```
23
+ * // eslint-disable @eslint-plugin/design-system/prefer-primitives
24
+ * ```
25
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
26
+ * we can change the implementation of the rule so that it never reports.
27
+ */
28
+ return {};
100
29
  }
101
30
  });
102
31
  export default rule;
@@ -1,23 +1,29 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { createWithConfig } from '../ensure-design-token-usage';
5
4
  import ruleMeta from '../ensure-design-token-usage/rule-meta';
6
5
  import { createLintRule } from '../utils/create-rule';
7
- var defaultConfig = {
8
- domains: ['spacing'],
9
- applyImport: true,
10
- shouldEnforceFallbacks: false
11
- };
12
6
  var rule = createLintRule({
13
7
  meta: _objectSpread(_objectSpread({}, ruleMeta), {}, {
14
8
  name: 'ensure-design-token-usage/preview',
9
+ deprecated: true,
10
+ replacedBy: ['@atlaskit/design-system/use-tokens-space'],
15
11
  docs: _objectSpread(_objectSpread({}, ruleMeta.docs), {}, {
16
12
  description: 'Enforces usage of pre-release design tokens rather than hard-coded values.',
17
13
  recommended: false,
18
14
  severity: 'warn'
19
15
  })
20
16
  }),
21
- create: createWithConfig(defaultConfig)
17
+ create: function create() {
18
+ /**
19
+ * We can't just outright delete the ESLint rule, since:
20
+ * ```
21
+ * // eslint-disable @eslint-plugin/design-system/ensure-design-token-usage/preview
22
+ * ```
23
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
24
+ * we can change the implementation of the rule so that it never reports.
25
+ */
26
+ return {};
27
+ }
22
28
  });
23
29
  export default rule;
@@ -1,14 +1,12 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
-
3
- import { isNodeOfType } from 'eslint-codemod-utils';
4
1
  import { createLintRule } from '../utils/create-rule';
5
- import { shouldSuggest, validPrimitiveElements } from './utils';
6
2
  var primitiveDocsUrl = 'https://go.atlassian.com/dst-prefer-primitives';
7
3
  var rule = createLintRule({
8
4
  meta: {
9
5
  name: 'prefer-primitives',
10
6
  type: 'suggestion',
11
7
  hasSuggestions: false,
8
+ deprecated: true,
9
+ replacedBy: ['@atlaskit/design-system/use-primitives'],
12
10
  docs: {
13
11
  description: 'Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule.',
14
12
  recommended: false,
@@ -18,84 +16,16 @@ var rule = createLintRule({
18
16
  preferPrimitives: "This \"{{element}}\" may be able to be replaced with a primitive component. See ".concat(primitiveDocsUrl, " for guidance.")
19
17
  }
20
18
  },
21
- create: function create(context) {
22
- return {
23
- // Look for HTML elements - <div>, <span>
24
- // Look for styled calls/templates - styled.div(...), styled.span`...`
25
- JSXOpeningElement: function JSXOpeningElement(node) {
26
- if (!isNodeOfType(node, 'JSXOpeningElement')) {
27
- return;
28
- }
29
- if (!isNodeOfType(node.name, 'JSXIdentifier')) {
30
- return;
31
- }
32
- var suggest = shouldSuggest(node === null || node === void 0 ? void 0 : node.parent);
33
- if (suggest) {
34
- context.report({
35
- node: node,
36
- messageId: 'preferPrimitives',
37
- data: {
38
- element: node.name.name
39
- }
40
- });
41
- }
42
- },
43
- // styled.x`` | styled2.x`` | styled.div()
44
- 'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': function MemberExpressionObjectNameStyledMemberExpressionObjectNameStyled2(node) {
45
- if (!isNodeOfType(node, 'MemberExpression')) {
46
- return;
47
- }
48
-
49
- // styled.div``
50
- if (isNodeOfType(node.property, 'Identifier')) {
51
- if (validPrimitiveElements.has(node.property.name)) {
52
- var styledIdentifier = node.object.name;
53
- var elementName = node.property.name;
54
-
55
- // Including the `styled.` portion in the message to help makers understand it's not just the `div` element that should be replaced
56
- var reportName = "".concat(styledIdentifier, ".").concat(elementName); // styled.div
57
-
58
- context.report({
59
- node: node,
60
- messageId: 'preferPrimitives',
61
- data: {
62
- element: reportName
63
- }
64
- });
65
- }
66
- }
67
- },
68
- // styled(X)``
69
- 'CallExpression[callee.name="styled"]': function CallExpressionCalleeNameStyled(node) {
70
- if (!isNodeOfType(node, 'CallExpression')) {
71
- return;
72
- }
73
-
74
- // styled('div')`` - We only care about 'div'/'span', ignore extending other components
75
- if (isNodeOfType(node.arguments[0], 'Literal')) {
76
- var argValue = node.arguments[0].raw;
77
- if (typeof argValue === 'string') {
78
- var suggest = validPrimitiveElements.has(argValue.replaceAll("'", '') // argValue will have '' around the element name, strip it out for this test
79
- );
80
- if (suggest) {
81
- var styledIdentifier = node.callee.name;
82
- var elementName = argValue;
83
-
84
- // Including the `styled()` portion in the message to help makers understand it's not just the `div` element that should be replaced
85
- var reportName = "".concat(styledIdentifier, "(").concat(elementName, ")"); // styled('div')
86
-
87
- context.report({
88
- node: node,
89
- messageId: 'preferPrimitives',
90
- data: {
91
- element: reportName
92
- }
93
- });
94
- }
95
- }
96
- }
97
- }
98
- };
19
+ create: function create() {
20
+ /**
21
+ * We can't just outright delete the ESLint rule, since:
22
+ * ```
23
+ * // eslint-disable @eslint-plugin/design-system/prefer-primitives
24
+ * ```
25
+ * will cause CI to fail if the rule definition doesn't exist. So, instead
26
+ * we can change the implementation of the rule so that it never reports.
27
+ */
28
+ return {};
99
29
  }
100
30
  });
101
31
  export default rule;
@@ -1,3 +1,2 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
1
+ declare const rule: import("eslint").Rule.RuleModule;
3
2
  export default rule;
@@ -1,3 +1,2 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
1
+ declare const rule: import("eslint").Rule.RuleModule;
3
2
  export default rule;
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": "9.1.0",
4
+ "version": "9.2.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {