@atlaskit/eslint-plugin-design-system 10.12.4 → 10.13.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 +24 -0
- package/dist/cjs/rules/no-legacy-icons/checks.js +90 -44
- package/dist/cjs/rules/no-legacy-icons/helpers.js +44 -12
- package/dist/cjs/rules/no-legacy-icons/index.js +5 -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/rules/no-legacy-icons/checks.js +75 -33
- package/dist/es2019/rules/no-legacy-icons/helpers.js +43 -11
- package/dist/es2019/rules/no-legacy-icons/index.js +5 -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/rules/no-legacy-icons/checks.js +91 -45
- package/dist/esm/rules/no-legacy-icons/helpers.js +43 -11
- package/dist/esm/rules/no-legacy-icons/index.js +5 -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/rules/no-legacy-icons/checks.d.ts +4 -1
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +21 -14
- 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/rules/no-legacy-icons/checks.d.ts +4 -1
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +21 -14
- 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,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type CallExpression, type ExportDefaultDeclaration, type ExportNamedDeclaration, type Identifier, type ImportDeclaration, type VariableDeclaration } from 'eslint-codemod-utils';
|
|
3
|
-
|
|
3
|
+
type ReturnObject = {
|
|
4
4
|
checkImportDeclarations: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
|
|
5
5
|
checkVariableDeclarations: (node: VariableDeclaration & Rule.NodeParentExtension) => void;
|
|
6
6
|
checkExportDefaultDeclaration: (node: ExportDefaultDeclaration & Rule.NodeParentExtension) => void;
|
|
7
7
|
checkExportNamedVariables: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
|
|
8
8
|
checkArrayOrMap: (node: Identifier) => void;
|
|
9
9
|
checkIconAsProp: (node: Identifier) => void;
|
|
10
|
+
checkIconReference: (node: Identifier & Rule.NodeParentExtension) => void;
|
|
10
11
|
checkJSXElement: (node: Rule.Node) => void;
|
|
11
12
|
checkCallExpression: (node: CallExpression & Rule.NodeParentExtension) => void;
|
|
12
13
|
throwErrors: () => void;
|
|
13
14
|
};
|
|
15
|
+
export declare const createChecks: (context: Rule.RuleContext) => ReturnObject;
|
|
16
|
+
export {};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXAttribute, type Node } from 'eslint-codemod-utils';
|
|
3
3
|
import { type IconMigrationSizeGuidance } from '@atlaskit/icon/UNSAFE_migration-map';
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
4
|
+
export type IconMigrationError = Rule.ReportDescriptor;
|
|
5
|
+
export type RangeList = {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
}[];
|
|
9
|
+
export type ErrorListManual = {
|
|
6
10
|
[loc: string]: {
|
|
7
|
-
errors:
|
|
11
|
+
errors: IconMigrationError[];
|
|
8
12
|
iconName: string;
|
|
9
13
|
importSource: string;
|
|
10
14
|
};
|
|
11
15
|
};
|
|
12
|
-
export type
|
|
13
|
-
[loc: string]:
|
|
16
|
+
export type ErrorListAuto = {
|
|
17
|
+
[loc: string]: IconMigrationError;
|
|
14
18
|
};
|
|
15
|
-
export type
|
|
19
|
+
export type GuidanceList = {
|
|
16
20
|
[loc: string]: string;
|
|
17
21
|
};
|
|
18
22
|
declare const sizes: readonly ["small", "medium", "large", "xlarge"];
|
|
@@ -42,14 +46,15 @@ export declare const createGuidance: (iconPackage: string, insideNewButton?: boo
|
|
|
42
46
|
*/
|
|
43
47
|
export declare const canMigrateColor: (color: string) => boolean;
|
|
44
48
|
export declare const locToString: (node: Node) => string;
|
|
45
|
-
export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors:
|
|
46
|
-
export declare const
|
|
47
|
-
export declare const
|
|
48
|
-
export declare const
|
|
49
|
-
export declare const
|
|
50
|
-
export declare const
|
|
51
|
-
export declare const
|
|
52
|
-
export declare const
|
|
49
|
+
export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
|
|
50
|
+
export declare const createCantMigrateIdentifierMapOrArrayError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
|
|
51
|
+
export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
|
|
52
|
+
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: ErrorListManual, sizeIssue?: boolean) => void;
|
|
53
|
+
export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: ErrorListManual) => void;
|
|
54
|
+
export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: ErrorListManual, importSource: string, iconName: string) => void;
|
|
55
|
+
export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: ErrorListManual, importSource: string, iconName: string) => void;
|
|
56
|
+
export declare const createCantMigrateSizeUnknown: (node: Node, errors: ErrorListManual, importSource: string, iconName: string) => void;
|
|
57
|
+
export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, errors: ErrorListAuto) => void;
|
|
53
58
|
export declare const getLiteralStringValue: (value: any) => string | undefined;
|
|
54
59
|
export declare const createHelpers: (context: Rule.RuleContext) => {
|
|
55
60
|
/**
|
|
@@ -59,4 +64,6 @@ export declare const createHelpers: (context: Rule.RuleContext) => {
|
|
|
59
64
|
getTokenCallValue: (value: any) => string | undefined;
|
|
60
65
|
getConfigFlag: (key: string, defaultValue: boolean) => boolean;
|
|
61
66
|
};
|
|
67
|
+
export declare const addToListOfRanges: (node: Node, sortedListOfRangesForErrors: RangeList) => void;
|
|
68
|
+
export declare const isInRangeList: (node: Node, sortedListOfRangesForErrors: RangeList) => boolean;
|
|
62
69
|
export {};
|
|
@@ -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 {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXElement } from 'eslint-codemod-utils';
|
|
3
3
|
import { type MetaData } from './common';
|
|
4
|
+
type CheckResult = {
|
|
5
|
+
success: boolean;
|
|
6
|
+
autoFixable?: boolean;
|
|
7
|
+
};
|
|
4
8
|
export declare const EmphasisElements: {
|
|
5
9
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
6
|
-
_check(node: JSXElement, { context, config }: MetaData):
|
|
10
|
+
_check(node: JSXElement, { context, config }: MetaData): CheckResult;
|
|
7
11
|
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
8
12
|
};
|
|
13
|
+
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXElement } from 'eslint-codemod-utils';
|
|
3
3
|
import { type MetaData } from './common';
|
|
4
|
+
type CheckResult = {
|
|
5
|
+
success: boolean;
|
|
6
|
+
autoFixable?: boolean;
|
|
7
|
+
};
|
|
4
8
|
export declare const SpanElements: {
|
|
5
9
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
6
|
-
_check(node: JSXElement, { context, config }: MetaData):
|
|
10
|
+
_check(node: JSXElement, { context, config }: MetaData): CheckResult;
|
|
7
11
|
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
8
12
|
};
|
|
13
|
+
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXElement } from 'eslint-codemod-utils';
|
|
3
3
|
import { type MetaData } from './common';
|
|
4
|
+
type CheckResult = {
|
|
5
|
+
success: boolean;
|
|
6
|
+
autoFixable?: boolean;
|
|
7
|
+
};
|
|
4
8
|
export declare const StrongElements: {
|
|
5
9
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
6
|
-
_check(node: JSXElement, { context, config }: MetaData):
|
|
10
|
+
_check(node: JSXElement, { context, config }: MetaData): CheckResult;
|
|
7
11
|
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
8
12
|
};
|
|
13
|
+
export {};
|