@atlaskit/eslint-plugin-design-system 10.12.5 → 10.14.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 +30 -0
- package/README.md +3 -3
- package/dist/cjs/presets/all.codegen.js +4 -5
- package/dist/cjs/presets/recommended.codegen.js +4 -5
- package/dist/cjs/rules/no-empty-styled-expression/index.js +1 -2
- package/dist/cjs/rules/no-exported-css/index.js +1 -2
- package/dist/cjs/rules/no-exported-keyframes/index.js +1 -2
- package/dist/cjs/rules/no-invalid-css-map/index.js +4 -1
- package/dist/cjs/rules/no-legacy-icons/helpers.js +3 -3
- package/dist/cjs/rules/use-heading/config/index.js +2 -1
- package/dist/cjs/rules/use-heading/transformers/native-elements.js +61 -31
- package/dist/cjs/rules/use-primitives-text/config/index.js +2 -1
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +56 -32
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +48 -26
- package/dist/es2019/presets/all.codegen.js +4 -5
- package/dist/es2019/presets/recommended.codegen.js +4 -5
- package/dist/es2019/rules/no-empty-styled-expression/index.js +1 -2
- package/dist/es2019/rules/no-exported-css/index.js +1 -2
- package/dist/es2019/rules/no-exported-keyframes/index.js +1 -2
- package/dist/es2019/rules/no-invalid-css-map/index.js +4 -1
- package/dist/es2019/rules/no-legacy-icons/helpers.js +3 -3
- package/dist/es2019/rules/use-heading/config/index.js +2 -1
- package/dist/es2019/rules/use-heading/transformers/native-elements.js +60 -29
- package/dist/es2019/rules/use-primitives-text/config/index.js +2 -1
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +47 -24
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +63 -52
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +55 -30
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +47 -24
- package/dist/esm/presets/all.codegen.js +4 -5
- package/dist/esm/presets/recommended.codegen.js +4 -5
- package/dist/esm/rules/no-empty-styled-expression/index.js +1 -2
- package/dist/esm/rules/no-exported-css/index.js +1 -2
- package/dist/esm/rules/no-exported-keyframes/index.js +1 -2
- package/dist/esm/rules/no-invalid-css-map/index.js +4 -1
- package/dist/esm/rules/no-legacy-icons/helpers.js +3 -3
- package/dist/esm/rules/use-heading/config/index.js +2 -1
- package/dist/esm/rules/use-heading/transformers/native-elements.js +61 -31
- package/dist/esm/rules/use-primitives-text/config/index.js +2 -1
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +56 -32
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +48 -26
- package/dist/types/index.codegen.d.ts +6 -8
- package/dist/types/presets/all.codegen.d.ts +4 -5
- package/dist/types/presets/recommended.codegen.d.ts +4 -5
- package/dist/types/rules/ensure-design-token-usage/rule-meta.d.ts +43 -2
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +13 -1
- package/dist/types/rules/use-heading/config/index.d.ts +2 -1
- package/dist/types/rules/use-heading/transformers/native-elements.d.ts +5 -1
- package/dist/types/rules/use-primitives-text/config/index.d.ts +1 -0
- package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
- package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
- package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
- package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
- package/dist/types-ts4.5/index.codegen.d.ts +6 -8
- package/dist/types-ts4.5/presets/all.codegen.d.ts +4 -5
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +4 -5
- package/dist/types-ts4.5/rules/ensure-design-token-usage/rule-meta.d.ts +43 -2
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +13 -1
- package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-heading/transformers/native-elements.d.ts +5 -1
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
- package/package.json +2 -2
|
@@ -16,53 +16,75 @@ export var EmphasisElements = {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Check whether all criteria needed to make a transformation are met
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} : {
|
|
35
|
-
suggest: [{
|
|
36
|
-
desc: "Convert to Text",
|
|
19
|
+
var _EmphasisElements$_ch = EmphasisElements._check(node, {
|
|
20
|
+
context: context,
|
|
21
|
+
config: config
|
|
22
|
+
}),
|
|
23
|
+
success = _EmphasisElements$_ch.success,
|
|
24
|
+
autoFixable = _EmphasisElements$_ch.autoFixable;
|
|
25
|
+
if (success && autoFixable) {
|
|
26
|
+
var fix = EmphasisElements._fix(node, {
|
|
27
|
+
context: context,
|
|
28
|
+
config: config
|
|
29
|
+
});
|
|
30
|
+
context.report(_objectSpread({
|
|
31
|
+
node: node.openingElement,
|
|
32
|
+
messageId: 'preferPrimitivesText'
|
|
33
|
+
}, config.enableUnsafeAutofix ? {
|
|
37
34
|
fix: fix
|
|
38
|
-
}
|
|
39
|
-
|
|
35
|
+
} : {
|
|
36
|
+
suggest: [{
|
|
37
|
+
desc: "Convert to Text",
|
|
38
|
+
fix: fix
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
} else if (success && config.enableUnsafeReport) {
|
|
42
|
+
context.report({
|
|
43
|
+
node: node.openingElement,
|
|
44
|
+
messageId: 'preferPrimitivesText'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
},
|
|
41
48
|
_check: function _check(node, _ref2) {
|
|
42
49
|
var context = _ref2.context,
|
|
43
50
|
config = _ref2.config;
|
|
44
51
|
if (!config.patterns.includes('emphasis-elements')) {
|
|
45
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
success: false
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
56
|
var elementName = ast.JSXElement.getName(node);
|
|
48
57
|
if (elementName !== 'em') {
|
|
49
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
success: false
|
|
60
|
+
};
|
|
50
61
|
}
|
|
51
62
|
if (!node.children.length) {
|
|
52
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
success: false
|
|
65
|
+
};
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
// Element has no unallowed props
|
|
56
69
|
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
57
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
success: true,
|
|
72
|
+
autoFixable: false
|
|
73
|
+
};
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
61
77
|
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
62
78
|
if (importDeclaration.length > 1) {
|
|
63
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
autoFixable: false
|
|
82
|
+
};
|
|
64
83
|
}
|
|
65
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
autoFixable: true
|
|
87
|
+
};
|
|
66
88
|
},
|
|
67
89
|
_fix: function _fix(node, _ref3) {
|
|
68
90
|
var context = _ref3.context,
|
|
@@ -21,55 +21,60 @@ export var ParagraphElements = {
|
|
|
21
21
|
config: config
|
|
22
22
|
}),
|
|
23
23
|
success = _ParagraphElements$_c.success,
|
|
24
|
+
autoFixable = _ParagraphElements$_c.autoFixable,
|
|
24
25
|
refs = _ParagraphElements$_c.refs;
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
messageId: 'preferPrimitivesStackedText'
|
|
49
|
-
}, config.enableUnsafeAutofix ? {
|
|
50
|
-
fix: fix
|
|
51
|
-
} : {
|
|
52
|
-
suggest: [{
|
|
53
|
-
desc: "Convert to Text and Stack",
|
|
26
|
+
if (success && autoFixable) {
|
|
27
|
+
if (refs.siblings.length > 1) {
|
|
28
|
+
var _refs$siblings$0$loc, _refs$siblings$loc;
|
|
29
|
+
/**
|
|
30
|
+
* Highlighting from first opening element to last closing element
|
|
31
|
+
* to indicate fix will change all p elements and wrap them in a Stack,
|
|
32
|
+
* falls back to first opening element.
|
|
33
|
+
*/
|
|
34
|
+
var startLoc = (_refs$siblings$0$loc = refs.siblings[0].loc) === null || _refs$siblings$0$loc === void 0 ? void 0 : _refs$siblings$0$loc.start;
|
|
35
|
+
var endLoc = (_refs$siblings$loc = refs.siblings[refs.siblings.length - 1].loc) === null || _refs$siblings$loc === void 0 ? void 0 : _refs$siblings$loc.end;
|
|
36
|
+
var fix = ParagraphElements._fixMultiple(node, {
|
|
37
|
+
context: context,
|
|
38
|
+
config: config,
|
|
39
|
+
refs: refs
|
|
40
|
+
});
|
|
41
|
+
context.report(_objectSpread({
|
|
42
|
+
loc: startLoc && endLoc && {
|
|
43
|
+
start: startLoc,
|
|
44
|
+
end: endLoc
|
|
45
|
+
},
|
|
46
|
+
node: node.openingElement,
|
|
47
|
+
messageId: 'preferPrimitivesStackedText'
|
|
48
|
+
}, config.enableUnsafeAutofix ? {
|
|
54
49
|
fix: fix
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
} : {
|
|
51
|
+
suggest: [{
|
|
52
|
+
desc: "Convert to Text and Stack",
|
|
53
|
+
fix: fix
|
|
54
|
+
}]
|
|
55
|
+
}));
|
|
56
|
+
} else {
|
|
57
|
+
var _fix = ParagraphElements._fixSingle(node, {
|
|
58
|
+
context: context,
|
|
59
|
+
config: config
|
|
60
|
+
});
|
|
61
|
+
context.report(_objectSpread({
|
|
62
|
+
node: node.openingElement,
|
|
63
|
+
messageId: 'preferPrimitivesText'
|
|
64
|
+
}, config.enableUnsafeAutofix ? {
|
|
70
65
|
fix: _fix
|
|
71
|
-
}
|
|
72
|
-
|
|
66
|
+
} : {
|
|
67
|
+
suggest: [{
|
|
68
|
+
desc: "Convert to Text",
|
|
69
|
+
fix: _fix
|
|
70
|
+
}]
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
} else if (success && config.enableUnsafeReport) {
|
|
74
|
+
context.report({
|
|
75
|
+
node: node.openingElement,
|
|
76
|
+
messageId: 'preferPrimitivesText'
|
|
77
|
+
});
|
|
73
78
|
}
|
|
74
79
|
},
|
|
75
80
|
_check: function _check(node, _ref2) {
|
|
@@ -104,7 +109,8 @@ export var ParagraphElements = {
|
|
|
104
109
|
// All siblings have to be paragraph elements with no unallowed props
|
|
105
110
|
if (!isNodeOfType(node.parent, 'JSXElement')) {
|
|
106
111
|
return {
|
|
107
|
-
success:
|
|
112
|
+
success: true,
|
|
113
|
+
autoFixable: false,
|
|
108
114
|
refs: {
|
|
109
115
|
siblings: []
|
|
110
116
|
}
|
|
@@ -116,7 +122,8 @@ export var ParagraphElements = {
|
|
|
116
122
|
// Only report for the first p element by comparing node location
|
|
117
123
|
if (((_siblings$0$range = siblings[0].range) === null || _siblings$0$range === void 0 ? void 0 : _siblings$0$range[0]) !== ((_node$range = node.range) === null || _node$range === void 0 ? void 0 : _node$range[0]) || ((_siblings$0$range2 = siblings[0].range) === null || _siblings$0$range2 === void 0 ? void 0 : _siblings$0$range2[1]) !== ((_node$range2 = node.range) === null || _node$range2 === void 0 ? void 0 : _node$range2[1])) {
|
|
118
124
|
return {
|
|
119
|
-
success:
|
|
125
|
+
success: true,
|
|
126
|
+
autoFixable: false,
|
|
120
127
|
refs: {
|
|
121
128
|
siblings: siblings
|
|
122
129
|
}
|
|
@@ -134,7 +141,8 @@ export var ParagraphElements = {
|
|
|
134
141
|
});
|
|
135
142
|
if (!siblingsMatch) {
|
|
136
143
|
return {
|
|
137
|
-
success:
|
|
144
|
+
success: true,
|
|
145
|
+
autoFixable: false,
|
|
138
146
|
refs: {
|
|
139
147
|
siblings: siblings
|
|
140
148
|
}
|
|
@@ -142,7 +150,8 @@ export var ParagraphElements = {
|
|
|
142
150
|
}
|
|
143
151
|
} else if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
144
152
|
return {
|
|
145
|
-
success:
|
|
153
|
+
success: true,
|
|
154
|
+
autoFixable: false,
|
|
146
155
|
refs: {
|
|
147
156
|
siblings: siblings
|
|
148
157
|
}
|
|
@@ -153,7 +162,8 @@ export var ParagraphElements = {
|
|
|
153
162
|
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
154
163
|
if (importDeclaration.length > 1) {
|
|
155
164
|
return {
|
|
156
|
-
success:
|
|
165
|
+
success: true,
|
|
166
|
+
autoFixable: false,
|
|
157
167
|
refs: {
|
|
158
168
|
siblings: siblings
|
|
159
169
|
}
|
|
@@ -161,6 +171,7 @@ export var ParagraphElements = {
|
|
|
161
171
|
}
|
|
162
172
|
return {
|
|
163
173
|
success: true,
|
|
174
|
+
autoFixable: true,
|
|
164
175
|
refs: {
|
|
165
176
|
siblings: siblings
|
|
166
177
|
}
|
|
@@ -16,58 +16,82 @@ export var SpanElements = {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Check whether all criteria needed to make a transformation are met
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} : {
|
|
35
|
-
suggest: [{
|
|
36
|
-
desc: "Convert to Text",
|
|
19
|
+
var _SpanElements$_check = SpanElements._check(node, {
|
|
20
|
+
context: context,
|
|
21
|
+
config: config
|
|
22
|
+
}),
|
|
23
|
+
success = _SpanElements$_check.success,
|
|
24
|
+
autoFixable = _SpanElements$_check.autoFixable;
|
|
25
|
+
if (success && autoFixable) {
|
|
26
|
+
var fix = SpanElements._fix(node, {
|
|
27
|
+
context: context,
|
|
28
|
+
config: config
|
|
29
|
+
});
|
|
30
|
+
context.report(_objectSpread({
|
|
31
|
+
node: node.openingElement,
|
|
32
|
+
messageId: 'preferPrimitivesText'
|
|
33
|
+
}, config.enableUnsafeAutofix ? {
|
|
37
34
|
fix: fix
|
|
38
|
-
}
|
|
39
|
-
|
|
35
|
+
} : {
|
|
36
|
+
suggest: [{
|
|
37
|
+
desc: "Convert to Text",
|
|
38
|
+
fix: fix
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
} else if (success && config.enableUnsafeReport) {
|
|
42
|
+
context.report({
|
|
43
|
+
node: node.openingElement,
|
|
44
|
+
messageId: 'preferPrimitivesText'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
},
|
|
41
48
|
_check: function _check(node, _ref2) {
|
|
42
49
|
var context = _ref2.context,
|
|
43
50
|
config = _ref2.config;
|
|
44
51
|
if (!config.patterns.includes('span-elements')) {
|
|
45
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
success: false
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
56
|
var elementName = ast.JSXElement.getName(node);
|
|
48
57
|
if (elementName !== 'span') {
|
|
49
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
success: false
|
|
60
|
+
};
|
|
50
61
|
}
|
|
51
62
|
if (!node.children.length) {
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Element has no unallowed props
|
|
56
|
-
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
57
|
-
return false;
|
|
63
|
+
return {
|
|
64
|
+
success: false
|
|
65
|
+
};
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
// Only allow elements with strings as children
|
|
61
69
|
if (!hasTextChildrenOnly(node)) {
|
|
62
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
success: false
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Element has no unallowed props
|
|
76
|
+
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
autoFixable: false
|
|
80
|
+
};
|
|
63
81
|
}
|
|
64
|
-
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
65
82
|
|
|
66
83
|
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
84
|
+
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
67
85
|
if (importDeclaration.length > 1) {
|
|
68
|
-
return
|
|
86
|
+
return {
|
|
87
|
+
success: true,
|
|
88
|
+
autoFixable: false
|
|
89
|
+
};
|
|
69
90
|
}
|
|
70
|
-
return
|
|
91
|
+
return {
|
|
92
|
+
success: true,
|
|
93
|
+
autoFixable: true
|
|
94
|
+
};
|
|
71
95
|
},
|
|
72
96
|
_fix: function _fix(node, _ref3) {
|
|
73
97
|
var context = _ref3.context,
|
|
@@ -16,53 +16,75 @@ export var StrongElements = {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Check whether all criteria needed to make a transformation are met
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} : {
|
|
35
|
-
suggest: [{
|
|
36
|
-
desc: "Convert to Text",
|
|
19
|
+
var _StrongElements$_chec = StrongElements._check(node, {
|
|
20
|
+
context: context,
|
|
21
|
+
config: config
|
|
22
|
+
}),
|
|
23
|
+
success = _StrongElements$_chec.success,
|
|
24
|
+
autoFixable = _StrongElements$_chec.autoFixable;
|
|
25
|
+
if (success && autoFixable) {
|
|
26
|
+
var fix = StrongElements._fix(node, {
|
|
27
|
+
context: context,
|
|
28
|
+
config: config
|
|
29
|
+
});
|
|
30
|
+
context.report(_objectSpread({
|
|
31
|
+
node: node.openingElement,
|
|
32
|
+
messageId: 'preferPrimitivesText'
|
|
33
|
+
}, config.enableUnsafeAutofix ? {
|
|
37
34
|
fix: fix
|
|
38
|
-
}
|
|
39
|
-
|
|
35
|
+
} : {
|
|
36
|
+
suggest: [{
|
|
37
|
+
desc: "Convert to Text",
|
|
38
|
+
fix: fix
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
} else if (success && config.enableUnsafeReport) {
|
|
42
|
+
context.report({
|
|
43
|
+
node: node.openingElement,
|
|
44
|
+
messageId: 'preferPrimitivesText'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
},
|
|
41
48
|
_check: function _check(node, _ref2) {
|
|
42
49
|
var context = _ref2.context,
|
|
43
50
|
config = _ref2.config;
|
|
44
51
|
if (!config.patterns.includes('strong-elements')) {
|
|
45
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
success: false
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
56
|
var elementName = ast.JSXElement.getName(node);
|
|
48
57
|
if (elementName !== 'strong') {
|
|
49
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
success: false
|
|
60
|
+
};
|
|
50
61
|
}
|
|
51
62
|
if (!node.children.length) {
|
|
52
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
success: false
|
|
65
|
+
};
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
// Element has no unallowed props
|
|
56
69
|
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
57
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
success: true,
|
|
72
|
+
autoFixable: false
|
|
73
|
+
};
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
61
77
|
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
62
78
|
if (importDeclaration.length > 1) {
|
|
63
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
autoFixable: false
|
|
82
|
+
};
|
|
64
83
|
}
|
|
65
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
autoFixable: true
|
|
87
|
+
};
|
|
66
88
|
},
|
|
67
89
|
_fix: function _fix(node, _ref3) {
|
|
68
90
|
var context = _ref3.context,
|
|
@@ -14,12 +14,11 @@ export declare const configs: {
|
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
16
16
|
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': string;
|
|
17
|
-
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
18
|
-
'@atlaskit/design-system/no-exported-css': string;
|
|
19
|
-
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
20
17
|
'@atlaskit/design-system/no-html-anchor': string;
|
|
21
18
|
'@atlaskit/design-system/no-html-button': string;
|
|
22
|
-
'@atlaskit/design-system/no-invalid-css-map': string
|
|
19
|
+
'@atlaskit/design-system/no-invalid-css-map': (string | {
|
|
20
|
+
allowedFunctionCalls: string[][];
|
|
21
|
+
})[];
|
|
23
22
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
24
23
|
'@atlaskit/design-system/no-legacy-icons': string;
|
|
25
24
|
'@atlaskit/design-system/no-margin': string;
|
|
@@ -57,12 +56,11 @@ export declare const configs: {
|
|
|
57
56
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
58
57
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
59
58
|
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': string;
|
|
60
|
-
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
61
|
-
'@atlaskit/design-system/no-exported-css': string;
|
|
62
|
-
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
63
59
|
'@atlaskit/design-system/no-html-anchor': string;
|
|
64
60
|
'@atlaskit/design-system/no-html-button': string;
|
|
65
|
-
'@atlaskit/design-system/no-invalid-css-map': string
|
|
61
|
+
'@atlaskit/design-system/no-invalid-css-map': (string | {
|
|
62
|
+
allowedFunctionCalls: string[][];
|
|
63
|
+
})[];
|
|
66
64
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
67
65
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
68
66
|
'@atlaskit/design-system/no-unsafe-style-overrides': 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::b6947ac630ea512fe3f4e3f44abb6783>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -17,12 +17,11 @@ declare const _default: {
|
|
|
17
17
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
18
18
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
19
19
|
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': string;
|
|
20
|
-
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
21
|
-
'@atlaskit/design-system/no-exported-css': string;
|
|
22
|
-
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
23
20
|
'@atlaskit/design-system/no-html-anchor': string;
|
|
24
21
|
'@atlaskit/design-system/no-html-button': string;
|
|
25
|
-
'@atlaskit/design-system/no-invalid-css-map': string
|
|
22
|
+
'@atlaskit/design-system/no-invalid-css-map': (string | {
|
|
23
|
+
allowedFunctionCalls: string[][];
|
|
24
|
+
})[];
|
|
26
25
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
27
26
|
'@atlaskit/design-system/no-legacy-icons': string;
|
|
28
27
|
'@atlaskit/design-system/no-margin': 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::9b6bccf688f4ee18dd0d49dbce48e475>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -14,12 +14,11 @@ declare const _default: {
|
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
16
16
|
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': string;
|
|
17
|
-
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
18
|
-
'@atlaskit/design-system/no-exported-css': string;
|
|
19
|
-
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
20
17
|
'@atlaskit/design-system/no-html-anchor': string;
|
|
21
18
|
'@atlaskit/design-system/no-html-button': string;
|
|
22
|
-
'@atlaskit/design-system/no-invalid-css-map': string
|
|
19
|
+
'@atlaskit/design-system/no-invalid-css-map': (string | {
|
|
20
|
+
allowedFunctionCalls: string[][];
|
|
21
|
+
})[];
|
|
23
22
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
24
23
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
25
24
|
'@atlaskit/design-system/no-unsafe-style-overrides': string;
|
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
import type
|
|
2
|
-
declare const ruleMeta:
|
|
1
|
+
import { type Domains } from './types';
|
|
2
|
+
declare const ruleMeta: {
|
|
3
|
+
readonly name: "ensure-design-token-usage";
|
|
4
|
+
readonly hasSuggestions: true;
|
|
5
|
+
readonly schema: {
|
|
6
|
+
readonly type: "array";
|
|
7
|
+
readonly items: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly applyImport: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
};
|
|
13
|
+
readonly shouldEnforceFallbacks: {
|
|
14
|
+
readonly type: "boolean";
|
|
15
|
+
};
|
|
16
|
+
readonly domains: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly items: {
|
|
19
|
+
readonly enum: Domains;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly exceptions: {
|
|
23
|
+
readonly type: "array";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly type: "problem";
|
|
29
|
+
readonly fixable: "code";
|
|
30
|
+
readonly docs: {
|
|
31
|
+
readonly description: "Enforces usage of design tokens rather than hard-coded values.";
|
|
32
|
+
readonly recommended: true;
|
|
33
|
+
readonly severity: "error";
|
|
34
|
+
};
|
|
35
|
+
readonly messages: {
|
|
36
|
+
readonly noRawRadiusValues: "The use of shape tokens is preferred over the direct application of border properties.\n\n@meta <<{{payload}}>>";
|
|
37
|
+
readonly noRawSpacingValues: "The use of spacing primitives or tokens is preferred over the direct application of spacing properties.\n\n@meta <<{{payload}}>>";
|
|
38
|
+
readonly autofixesPossible: "Automated corrections available for spacing values. Apply autofix to replace values with appropriate tokens";
|
|
39
|
+
readonly noCalcUsage: "The use of space tokens is preferred over using the CSS calc function. If using a value that is not aligned to the spacing scale, consider aligning to the scale and using tokens instead.";
|
|
40
|
+
readonly hardCodedColor: "Colors can be sourced from the global theme using the token function.";
|
|
41
|
+
readonly legacyElevation: "Elevations can be sourced from the global theme using the token function made of both a background and shadow. Use \"card\" for card elevations, and \"overlay\" for anything else that should appear elevated.";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
3
44
|
export default ruleMeta;
|
|
@@ -27,7 +27,19 @@ export declare const isSize: (size: any) => size is "small" | "medium" | "large"
|
|
|
27
27
|
* @param iconPackage The name of the legacy icon package
|
|
28
28
|
* @returns The migration map object for the legacy icon or null if not found
|
|
29
29
|
*/
|
|
30
|
-
export declare const getMigrationMapObject: (iconPackage: string) =>
|
|
30
|
+
export declare const getMigrationMapObject: (iconPackage: string) => {
|
|
31
|
+
newIcon?: {
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
package: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
additionalIcons?: {
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
package: string;
|
|
40
|
+
}[] | undefined;
|
|
41
|
+
sizeGuidance: Record<import("@atlaskit/icon").Size, IconMigrationSizeGuidance>;
|
|
42
|
+
} | null;
|
|
31
43
|
export declare const getUpcomingIcons: (iconPackage: string) => {
|
|
32
44
|
sizeGuidance: Record<Size, IconMigrationSizeGuidance>;
|
|
33
45
|
} | null;
|
|
@@ -2,7 +2,8 @@ type Pattern = 'native-elements';
|
|
|
2
2
|
export interface RuleConfig {
|
|
3
3
|
failSilently: boolean;
|
|
4
4
|
patterns: Pattern[];
|
|
5
|
-
enableUnsafeAutofix:
|
|
5
|
+
enableUnsafeAutofix: boolean;
|
|
6
|
+
enableUnsafeReport: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const getConfig: (overrides: Partial<RuleConfig>) => RuleConfig;
|
|
8
9
|
export {};
|
|
@@ -10,9 +10,13 @@ interface ValidHeadingElement extends JSXElement {
|
|
|
10
10
|
};
|
|
11
11
|
} & JSXOpeningElement;
|
|
12
12
|
}
|
|
13
|
+
type CheckResult = {
|
|
14
|
+
success: boolean;
|
|
15
|
+
autoFixable?: boolean;
|
|
16
|
+
};
|
|
13
17
|
export declare const NativeElements: {
|
|
14
18
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
15
|
-
_check(node: Rule.Node, { config }: MetaData):
|
|
19
|
+
_check(node: Rule.Node, { config }: MetaData): CheckResult;
|
|
16
20
|
_fix(node: ValidHeadingElement, { context }: MetaData): Rule.ReportFixer;
|
|
17
21
|
};
|
|
18
22
|
export {};
|