@atlaskit/eslint-plugin-design-system 10.2.0 → 10.3.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 (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/constellation/no-html-anchor/usage.mdx +6 -0
  3. package/constellation/no-unsafe-design-token-usage/usage.mdx +1 -1
  4. package/dist/cjs/rules/no-html-anchor/node-types/supported.js +6 -0
  5. package/dist/cjs/rules/use-heading/transformers/native-elements.js +3 -0
  6. package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +3 -0
  7. package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +8 -0
  8. package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +3 -0
  9. package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +3 -0
  10. package/dist/es2019/rules/no-html-anchor/node-types/supported.js +6 -0
  11. package/dist/es2019/rules/use-heading/transformers/native-elements.js +3 -0
  12. package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +3 -0
  13. package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +8 -0
  14. package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +3 -0
  15. package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +3 -0
  16. package/dist/esm/rules/no-html-anchor/node-types/supported.js +6 -0
  17. package/dist/esm/rules/use-heading/transformers/native-elements.js +3 -0
  18. package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +3 -0
  19. package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +8 -0
  20. package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +3 -0
  21. package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +3 -0
  22. package/dist/types/rules/use-heading/transformers/native-elements.d.ts +1 -1
  23. package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +1 -1
  24. package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -1
  25. package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +1 -1
  26. package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +1 -1
  27. package/dist/types-ts4.5/rules/use-heading/transformers/native-elements.d.ts +1 -1
  28. package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +1 -1
  29. package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -1
  30. package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +1 -1
  31. package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +1 -1
  32. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 10.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#102286](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102286)
8
+ [`8c56c1feba06`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8c56c1feba06) -
9
+ Adds support for `role="button"` in `no-html-anchor` rule
10
+
11
+ ## 10.2.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#101749](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101749)
16
+ [`08a34b7d741c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/08a34b7d741c) -
17
+ use-primitives-text and use-heading lint rules to not target elements with no children.
18
+
3
19
  ## 10.2.0
4
20
 
5
21
  ### Minor Changes
@@ -21,6 +21,12 @@ This rule marks code as violations when it finds native HTML anchor elements.
21
21
  ^ Using a native HTML `<a>`
22
22
  Hello, World!
23
23
  </a>
24
+
25
+ <div role="link" tabIndex="0" data-href="https://www.atlassian.com">
26
+ ^^^^^^^^^^^ Using `role="link"` to create links
27
+ Hello, World!
28
+ </div>
29
+
24
30
  ```
25
31
 
26
32
  ### Correct
@@ -41,7 +41,7 @@ This rule comes with options to aid in migrating to design tokens.
41
41
  ### fallbackUsage
42
42
 
43
43
  - `forced`: Fallback values must always be provided
44
- - `none`: Fallback values must never be provided. (Fixer will remove is provided)
44
+ - `none`: Fallback values must never be provided. (Fixer will remove if provided)
45
45
  - `optional`: Fallbacks are optional
46
46
 
47
47
  ### shouldEnforceFallbacks (deprecated)
@@ -11,6 +11,12 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
11
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
12
  var supportedElements = [{
13
13
  name: 'a'
14
+ }, {
15
+ name: '*',
16
+ attributes: [{
17
+ name: 'role',
18
+ values: ['link']
19
+ }]
14
20
  }];
15
21
 
16
22
  /**
@@ -53,6 +53,9 @@ var NativeElements = exports.NativeElements = {
53
53
  if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
54
54
  return false;
55
55
  }
56
+ if (!node.children.length) {
57
+ return false;
58
+ }
56
59
  if (!node.parent) {
57
60
  return false;
58
61
  }
@@ -51,6 +51,9 @@ var EmphasisElements = exports.EmphasisElements = {
51
51
  if (elementName !== 'em') {
52
52
  return false;
53
53
  }
54
+ if (!node.children.length) {
55
+ return false;
56
+ }
54
57
 
55
58
  // Element has no unallowed props
56
59
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, _common.allowedAttrs)) {
@@ -91,6 +91,14 @@ var ParagraphElements = exports.ParagraphElements = {
91
91
  }
92
92
  };
93
93
  }
94
+ if (!node.children.length) {
95
+ return {
96
+ success: false,
97
+ refs: {
98
+ siblings: []
99
+ }
100
+ };
101
+ }
94
102
 
95
103
  // All siblings have to be paragraph elements with no unallowed props
96
104
  if (!(0, _eslintCodemodUtils.isNodeOfType)(node.parent, 'JSXElement')) {
@@ -51,6 +51,9 @@ var SpanElements = exports.SpanElements = {
51
51
  if (elementName !== 'span') {
52
52
  return false;
53
53
  }
54
+ if (!node.children.length) {
55
+ return false;
56
+ }
54
57
 
55
58
  // Element has no unallowed props
56
59
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, _common.allowedAttrs)) {
@@ -51,6 +51,9 @@ var StrongElements = exports.StrongElements = {
51
51
  if (elementName !== 'strong') {
52
52
  return false;
53
53
  }
54
+ if (!node.children.length) {
55
+ return false;
56
+ }
54
57
 
55
58
  // Element has no unallowed props
56
59
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, _common.allowedAttrs)) {
@@ -2,6 +2,12 @@ import { isNodeOfType } from 'eslint-codemod-utils';
2
2
  import * as ast from '../../../ast-nodes';
3
3
  const supportedElements = [{
4
4
  name: 'a'
5
+ }, {
6
+ name: '*',
7
+ attributes: [{
8
+ name: 'role',
9
+ values: ['link']
10
+ }]
5
11
  }];
6
12
 
7
13
  /**
@@ -44,6 +44,9 @@ export const NativeElements = {
44
44
  if (!isNodeOfType(node, 'JSXElement')) {
45
45
  return false;
46
46
  }
47
+ if (!node.children.length) {
48
+ return false;
49
+ }
47
50
  if (!node.parent) {
48
51
  return false;
49
52
  }
@@ -42,6 +42,9 @@ export const EmphasisElements = {
42
42
  if (elementName !== 'em') {
43
43
  return false;
44
44
  }
45
+ if (!node.children.length) {
46
+ return false;
47
+ }
45
48
 
46
49
  // Element has no unallowed props
47
50
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -83,6 +83,14 @@ export const ParagraphElements = {
83
83
  }
84
84
  };
85
85
  }
86
+ if (!node.children.length) {
87
+ return {
88
+ success: false,
89
+ refs: {
90
+ siblings: []
91
+ }
92
+ };
93
+ }
86
94
 
87
95
  // All siblings have to be paragraph elements with no unallowed props
88
96
  if (!isNodeOfType(node.parent, 'JSXElement')) {
@@ -42,6 +42,9 @@ export const SpanElements = {
42
42
  if (elementName !== 'span') {
43
43
  return false;
44
44
  }
45
+ if (!node.children.length) {
46
+ return false;
47
+ }
45
48
 
46
49
  // Element has no unallowed props
47
50
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -42,6 +42,9 @@ export const StrongElements = {
42
42
  if (elementName !== 'strong') {
43
43
  return false;
44
44
  }
45
+ if (!node.children.length) {
46
+ return false;
47
+ }
45
48
 
46
49
  // Element has no unallowed props
47
50
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -2,6 +2,12 @@ import { isNodeOfType } from 'eslint-codemod-utils';
2
2
  import * as ast from '../../../ast-nodes';
3
3
  var supportedElements = [{
4
4
  name: 'a'
5
+ }, {
6
+ name: '*',
7
+ attributes: [{
8
+ name: 'role',
9
+ values: ['link']
10
+ }]
5
11
  }];
6
12
 
7
13
  /**
@@ -43,6 +43,9 @@ export var NativeElements = {
43
43
  if (!isNodeOfType(node, 'JSXElement')) {
44
44
  return false;
45
45
  }
46
+ if (!node.children.length) {
47
+ return false;
48
+ }
46
49
  if (!node.parent) {
47
50
  return false;
48
51
  }
@@ -41,6 +41,9 @@ export var EmphasisElements = {
41
41
  if (elementName !== 'em') {
42
42
  return false;
43
43
  }
44
+ if (!node.children.length) {
45
+ return false;
46
+ }
44
47
 
45
48
  // Element has no unallowed props
46
49
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -81,6 +81,14 @@ export var ParagraphElements = {
81
81
  }
82
82
  };
83
83
  }
84
+ if (!node.children.length) {
85
+ return {
86
+ success: false,
87
+ refs: {
88
+ siblings: []
89
+ }
90
+ };
91
+ }
84
92
 
85
93
  // All siblings have to be paragraph elements with no unallowed props
86
94
  if (!isNodeOfType(node.parent, 'JSXElement')) {
@@ -41,6 +41,9 @@ export var SpanElements = {
41
41
  if (elementName !== 'span') {
42
42
  return false;
43
43
  }
44
+ if (!node.children.length) {
45
+ return false;
46
+ }
44
47
 
45
48
  // Element has no unallowed props
46
49
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -41,6 +41,9 @@ export var StrongElements = {
41
41
  if (elementName !== 'strong') {
42
42
  return false;
43
43
  }
44
+ if (!node.children.length) {
45
+ return false;
46
+ }
44
47
 
45
48
  // Element has no unallowed props
46
49
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement, JSXIdentifier, JSXOpeningElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  type ValidTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
5
  interface ValidHeadingElement extends JSXElement {
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const EmphasisElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  type CheckResult = {
5
5
  success: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const SpanElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const StrongElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement, JSXIdentifier, JSXOpeningElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  type ValidTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
5
  interface ValidHeadingElement extends JSXElement {
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const EmphasisElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  type CheckResult = {
5
5
  success: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const SpanElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXElement } from 'eslint-codemod-utils';
2
+ import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
4
  export declare const StrongElements: {
5
5
  lint(node: Rule.Node, { context, config }: MetaData): void;
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": "10.2.0",
4
+ "version": "10.3.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -41,7 +41,7 @@
41
41
  "react": "^16.8.0 || ^17.0.0 || ~18.2.0"
42
42
  },
43
43
  "dependencies": {
44
- "@atlaskit/eslint-utils": "^1.3.0",
44
+ "@atlaskit/eslint-utils": "^1.4.0",
45
45
  "@atlaskit/tokens": "*",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "@typescript-eslint/utils": "^5.48.1",