@atlaskit/eslint-plugin-design-system 9.5.2 → 9.7.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 +991 -410
- package/README.md +1 -0
- package/constellation/index/usage.mdx +1 -0
- package/constellation/use-popup-label/usage.mdx +53 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/icon-label/index.js +16 -12
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/use-popup-label/index.js +90 -0
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/icon-label/index.js +12 -2
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/use-popup-label/index.js +80 -0
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/icon-label/index.js +16 -12
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/use-popup-label/index.js +84 -0
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/use-popup-label/index.d.ts +3 -0
- package/dist/types/rules/use-tokens-typography/utils.d.ts +0 -33
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-popup-label/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +0 -33
- package/package.json +2 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { createLintRule } from '../utils/create-rule';
|
|
5
|
+
var elementsAccessibleNameProps = ['label', 'titleId'];
|
|
6
|
+
var rule = createLintRule({
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'use-popup-label',
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Encourages to provide accessible name for Atlassian Design System Popup component.',
|
|
12
|
+
recommended: true,
|
|
13
|
+
severity: 'warn'
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
missingLabelProp: 'Missing accessible name. If there is no visible content to associate use `label` prop, otherwise pass id of element to `titleId` prop to be associated as label.',
|
|
17
|
+
labelPropShouldHaveContents: 'Define string that labels the interactive element.',
|
|
18
|
+
titleIdShouldHaveValue: '`titleId` should reference the id of element that define accessible name.',
|
|
19
|
+
noBothPropsUsage: 'Do not include both `titleId` and `label` properties. Use `titleId` if the label text is available in the DOM to reference it, otherwise use `label` to provide accessible name explicitly.'
|
|
20
|
+
},
|
|
21
|
+
hasSuggestions: true
|
|
22
|
+
},
|
|
23
|
+
create: function create(context) {
|
|
24
|
+
var contextLocalIdentifier = [];
|
|
25
|
+
return {
|
|
26
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
27
|
+
if (node.source.value === '@atlaskit/popup') {
|
|
28
|
+
if (node.specifiers.length) {
|
|
29
|
+
var defaultImport = node.specifiers.filter(function (spec) {
|
|
30
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
31
|
+
});
|
|
32
|
+
if (defaultImport.length) {
|
|
33
|
+
var local = defaultImport[0].local;
|
|
34
|
+
contextLocalIdentifier.push(local.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
JSXElement: function JSXElement(node) {
|
|
40
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var name = node.openingElement.name.name;
|
|
47
|
+
if (contextLocalIdentifier.includes(name)) {
|
|
48
|
+
var componentRoleDialogProp = node.openingElement.attributes.find(function (attr) {
|
|
49
|
+
return isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier') && attr.value && isNodeOfType(attr.value, 'Literal') && attr.name.name === 'role' && attr.value.value === 'dialog';
|
|
50
|
+
});
|
|
51
|
+
var componentLabelProps = node.openingElement.attributes.filter(function (attr) {
|
|
52
|
+
return isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier') && elementsAccessibleNameProps.includes(attr.name.name);
|
|
53
|
+
});
|
|
54
|
+
if (componentLabelProps.length === 1) {
|
|
55
|
+
var prop = componentLabelProps[0];
|
|
56
|
+
if ('value' in prop && prop.value) {
|
|
57
|
+
if (isNodeOfType(prop.value, 'Literal') && !prop.value.value || isNodeOfType(prop.value, 'JSXExpressionContainer') && !prop.value.expression) {
|
|
58
|
+
context.report({
|
|
59
|
+
node: prop,
|
|
60
|
+
messageId: prop.name.name === 'label' ? 'labelPropShouldHaveContents' : 'titleIdShouldHaveValue'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} else if (componentLabelProps.length > 1) {
|
|
65
|
+
context.report({
|
|
66
|
+
node: node.openingElement,
|
|
67
|
+
messageId: 'noBothPropsUsage'
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
if (componentRoleDialogProp) {
|
|
71
|
+
context.report({
|
|
72
|
+
node: node.openingElement,
|
|
73
|
+
messageId: 'missingLabelProp'
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
export default rule;
|
|
@@ -32,6 +32,7 @@ export declare const configs: {
|
|
|
32
32
|
'@atlaskit/design-system/use-heading': string;
|
|
33
33
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
34
34
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
35
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
35
36
|
'@atlaskit/design-system/use-primitives': string;
|
|
36
37
|
'@atlaskit/design-system/use-primitives-text': string;
|
|
37
38
|
'@atlaskit/design-system/use-tokens-space': string;
|
|
@@ -62,6 +63,7 @@ export declare const configs: {
|
|
|
62
63
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
63
64
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
64
65
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
66
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
65
67
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
66
68
|
};
|
|
67
69
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::5a5b0ed8cf86631274d7d30df4199e5d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
'@atlaskit/design-system/use-heading': string;
|
|
36
36
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
37
37
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
38
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
38
39
|
'@atlaskit/design-system/use-primitives': string;
|
|
39
40
|
'@atlaskit/design-system/use-primitives-text': string;
|
|
40
41
|
'@atlaskit/design-system/use-tokens-space': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::af55c21605e3b8ee7836cb8950a9f713>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -26,6 +26,7 @@ declare const _default: {
|
|
|
26
26
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
27
27
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
28
28
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
29
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
29
30
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -32,6 +32,7 @@ declare const _default: {
|
|
|
32
32
|
'use-heading': import("eslint").Rule.RuleModule;
|
|
33
33
|
'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
|
|
34
34
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
35
|
+
'use-popup-label': import("eslint").Rule.RuleModule;
|
|
35
36
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
36
37
|
'use-primitives-text': import("eslint").Rule.RuleModule;
|
|
37
38
|
'use-tokens-space': import("eslint").Rule.RuleModule;
|
|
@@ -127,39 +127,6 @@ export declare const fontFamilyTokens: ({
|
|
|
127
127
|
name: string;
|
|
128
128
|
path: string[];
|
|
129
129
|
cleanName: string;
|
|
130
|
-
} | {
|
|
131
|
-
attributes: {
|
|
132
|
-
group: string;
|
|
133
|
-
state: string;
|
|
134
|
-
introduced: string;
|
|
135
|
-
deprecated: string;
|
|
136
|
-
description: string;
|
|
137
|
-
responsiveSmallerVariant?: undefined;
|
|
138
|
-
};
|
|
139
|
-
value: string;
|
|
140
|
-
filePath: string;
|
|
141
|
-
isSource: boolean;
|
|
142
|
-
original: {
|
|
143
|
-
attributes: {
|
|
144
|
-
group: string;
|
|
145
|
-
state: string;
|
|
146
|
-
introduced: string;
|
|
147
|
-
deprecated: string;
|
|
148
|
-
description: string;
|
|
149
|
-
responsiveSmallerVariant?: undefined;
|
|
150
|
-
};
|
|
151
|
-
value: {
|
|
152
|
-
fontWeight: string;
|
|
153
|
-
fontSize: string;
|
|
154
|
-
lineHeight: string;
|
|
155
|
-
fontFamily: string;
|
|
156
|
-
fontStyle: string;
|
|
157
|
-
letterSpacing: string;
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
name: string;
|
|
161
|
-
path: string[];
|
|
162
|
-
cleanName: string;
|
|
163
130
|
} | {
|
|
164
131
|
attributes: {
|
|
165
132
|
group: string;
|
|
@@ -32,6 +32,7 @@ export declare const configs: {
|
|
|
32
32
|
'@atlaskit/design-system/use-heading': string;
|
|
33
33
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
34
34
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
35
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
35
36
|
'@atlaskit/design-system/use-primitives': string;
|
|
36
37
|
'@atlaskit/design-system/use-primitives-text': string;
|
|
37
38
|
'@atlaskit/design-system/use-tokens-space': string;
|
|
@@ -62,6 +63,7 @@ export declare const configs: {
|
|
|
62
63
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
63
64
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
64
65
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
66
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
65
67
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
66
68
|
};
|
|
67
69
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::5a5b0ed8cf86631274d7d30df4199e5d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
'@atlaskit/design-system/use-heading': string;
|
|
36
36
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
37
37
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
38
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
38
39
|
'@atlaskit/design-system/use-primitives': string;
|
|
39
40
|
'@atlaskit/design-system/use-primitives-text': string;
|
|
40
41
|
'@atlaskit/design-system/use-tokens-space': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::af55c21605e3b8ee7836cb8950a9f713>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -26,6 +26,7 @@ declare const _default: {
|
|
|
26
26
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
27
27
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
28
28
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
29
|
+
'@atlaskit/design-system/use-popup-label': string;
|
|
29
30
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -36,6 +36,7 @@ declare const _default: {
|
|
|
36
36
|
'use-heading': import("eslint").Rule.RuleModule;
|
|
37
37
|
'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
|
|
38
38
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
39
|
+
'use-popup-label': import("eslint").Rule.RuleModule;
|
|
39
40
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
40
41
|
'use-primitives-text': import("eslint").Rule.RuleModule;
|
|
41
42
|
'use-tokens-space': import("eslint").Rule.RuleModule;
|
|
@@ -127,39 +127,6 @@ export declare const fontFamilyTokens: ({
|
|
|
127
127
|
name: string;
|
|
128
128
|
path: string[];
|
|
129
129
|
cleanName: string;
|
|
130
|
-
} | {
|
|
131
|
-
attributes: {
|
|
132
|
-
group: string;
|
|
133
|
-
state: string;
|
|
134
|
-
introduced: string;
|
|
135
|
-
deprecated: string;
|
|
136
|
-
description: string;
|
|
137
|
-
responsiveSmallerVariant?: undefined;
|
|
138
|
-
};
|
|
139
|
-
value: string;
|
|
140
|
-
filePath: string;
|
|
141
|
-
isSource: boolean;
|
|
142
|
-
original: {
|
|
143
|
-
attributes: {
|
|
144
|
-
group: string;
|
|
145
|
-
state: string;
|
|
146
|
-
introduced: string;
|
|
147
|
-
deprecated: string;
|
|
148
|
-
description: string;
|
|
149
|
-
responsiveSmallerVariant?: undefined;
|
|
150
|
-
};
|
|
151
|
-
value: {
|
|
152
|
-
fontWeight: string;
|
|
153
|
-
fontSize: string;
|
|
154
|
-
lineHeight: string;
|
|
155
|
-
fontFamily: string;
|
|
156
|
-
fontStyle: string;
|
|
157
|
-
letterSpacing: string;
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
name: string;
|
|
161
|
-
path: string[];
|
|
162
|
-
cleanName: string;
|
|
163
130
|
} | {
|
|
164
131
|
attributes: {
|
|
165
132
|
group: string;
|
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.
|
|
4
|
+
"version": "9.7.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"semver": "^7.5.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@af/formatting": "*",
|
|
56
57
|
"@atlaskit/ds-lib": "^2.3.0",
|
|
57
58
|
"@atlaskit/theme": "^12.7.0",
|
|
58
59
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
@@ -66,7 +67,6 @@
|
|
|
66
67
|
"eslint": "^8.49.0",
|
|
67
68
|
"jscodeshift": "^0.13.0",
|
|
68
69
|
"outdent": "^0.5.0",
|
|
69
|
-
"prettier": "^2.8.0",
|
|
70
70
|
"react": "^16.8.0",
|
|
71
71
|
"ts-jest": "26.5.6",
|
|
72
72
|
"ts-node": "^10.9.1",
|