@atlaskit/eslint-plugin-design-system 10.10.2 → 10.11.1
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 +18 -0
- package/dist/cjs/rules/no-legacy-icons/checks.js +2 -23
- package/dist/cjs/rules/no-legacy-icons/helpers.js +1 -31
- package/dist/cjs/rules/use-heading/config/index.js +2 -4
- package/dist/cjs/rules/use-heading/transformers/native-elements.js +15 -10
- package/dist/cjs/rules/use-primitives/config/index.js +0 -3
- package/dist/cjs/rules/use-primitives-text/config/index.js +2 -4
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +14 -9
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +28 -19
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +14 -9
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +14 -9
- package/dist/cjs/rules/use-tokens-typography/config/index.js +2 -4
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +12 -6
- package/dist/es2019/rules/no-legacy-icons/checks.js +3 -24
- package/dist/es2019/rules/no-legacy-icons/helpers.js +0 -28
- package/dist/es2019/rules/use-heading/config/index.js +2 -4
- package/dist/es2019/rules/use-heading/transformers/native-elements.js +12 -7
- package/dist/es2019/rules/use-primitives/config/index.js +0 -3
- package/dist/es2019/rules/use-primitives-text/config/index.js +2 -4
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +12 -7
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +25 -15
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +12 -7
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +12 -7
- package/dist/es2019/rules/use-tokens-typography/config/index.js +2 -4
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +9 -4
- package/dist/esm/rules/no-legacy-icons/checks.js +3 -24
- package/dist/esm/rules/no-legacy-icons/helpers.js +0 -30
- package/dist/esm/rules/use-heading/config/index.js +2 -4
- package/dist/esm/rules/use-heading/transformers/native-elements.js +15 -8
- package/dist/esm/rules/use-primitives/config/index.js +0 -3
- package/dist/esm/rules/use-primitives-text/config/index.js +2 -4
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +14 -7
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +28 -17
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +14 -7
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +14 -7
- package/dist/esm/rules/use-tokens-typography/config/index.js +2 -4
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +11 -4
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +1 -6
- package/dist/types/rules/use-heading/config/index.d.ts +2 -1
- package/dist/types/rules/use-primitives/config/index.d.ts +1 -1
- package/dist/types/rules/use-primitives-text/config/index.d.ts +2 -1
- package/dist/types/rules/use-tokens-typography/config/index.d.ts +4 -3
- package/dist/types/rules/use-tokens-typography/utils.d.ts +0 -39
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +1 -6
- package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-tokens-typography/config/index.d.ts +4 -3
- package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +0 -39
- package/package.json +1 -1
|
@@ -23,16 +23,21 @@ export const NativeElements = {
|
|
|
23
23
|
})) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
+
const fix = NativeElements._fix(node, {
|
|
27
|
+
context,
|
|
28
|
+
config
|
|
29
|
+
});
|
|
26
30
|
context.report({
|
|
27
31
|
node,
|
|
28
32
|
messageId: 'preferHeading',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
...(config.enableUnsafeAutofix ? {
|
|
34
|
+
fix
|
|
35
|
+
} : {
|
|
36
|
+
suggest: [{
|
|
37
|
+
desc: `Convert to Heading`,
|
|
38
|
+
fix
|
|
39
|
+
}]
|
|
40
|
+
})
|
|
36
41
|
});
|
|
37
42
|
},
|
|
38
43
|
_check(node, {
|
|
@@ -2,8 +2,5 @@ const defaults = {
|
|
|
2
2
|
patterns: ['compiled-css-function']
|
|
3
3
|
};
|
|
4
4
|
export const getConfig = overrides => {
|
|
5
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
7
|
-
// The empty object is returned, as well as modified in place
|
|
8
5
|
return Object.assign({}, defaults, overrides);
|
|
9
6
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const defaults = {
|
|
2
2
|
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
|
|
3
|
-
inheritColor: false
|
|
3
|
+
inheritColor: false,
|
|
4
|
+
enableUnsafeAutofix: false
|
|
4
5
|
};
|
|
5
6
|
export const getConfig = overrides => {
|
|
6
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
7
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
8
|
-
// The empty object is returned, as well as modified in place
|
|
9
7
|
return Object.assign({}, defaults, overrides);
|
|
10
8
|
};
|
|
@@ -19,16 +19,21 @@ export const EmphasisElements = {
|
|
|
19
19
|
})) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
const fix = EmphasisElements._fix(node, {
|
|
23
|
+
context,
|
|
24
|
+
config
|
|
25
|
+
});
|
|
22
26
|
context.report({
|
|
23
27
|
node: node.openingElement,
|
|
24
28
|
messageId: 'preferPrimitivesText',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
...(config.enableUnsafeAutofix ? {
|
|
30
|
+
fix
|
|
31
|
+
} : {
|
|
32
|
+
suggest: [{
|
|
33
|
+
desc: `Convert to Text`,
|
|
34
|
+
fix
|
|
35
|
+
}]
|
|
36
|
+
})
|
|
32
37
|
});
|
|
33
38
|
},
|
|
34
39
|
_check(node, {
|
|
@@ -32,6 +32,11 @@ export const ParagraphElements = {
|
|
|
32
32
|
*/
|
|
33
33
|
const startLoc = (_refs$siblings$0$loc = refs.siblings[0].loc) === null || _refs$siblings$0$loc === void 0 ? void 0 : _refs$siblings$0$loc.start;
|
|
34
34
|
const endLoc = (_refs$siblings$loc = refs.siblings[refs.siblings.length - 1].loc) === null || _refs$siblings$loc === void 0 ? void 0 : _refs$siblings$loc.end;
|
|
35
|
+
const fix = ParagraphElements._fixMultiple(node, {
|
|
36
|
+
context,
|
|
37
|
+
config,
|
|
38
|
+
refs
|
|
39
|
+
});
|
|
35
40
|
context.report({
|
|
36
41
|
loc: startLoc && endLoc && {
|
|
37
42
|
start: startLoc,
|
|
@@ -39,26 +44,31 @@ export const ParagraphElements = {
|
|
|
39
44
|
},
|
|
40
45
|
node: node.openingElement,
|
|
41
46
|
messageId: 'preferPrimitivesStackedText',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
47
|
+
...(config.enableUnsafeAutofix ? {
|
|
48
|
+
fix
|
|
49
|
+
} : {
|
|
50
|
+
suggest: [{
|
|
51
|
+
desc: `Convert to Text and Stack`,
|
|
52
|
+
fix
|
|
53
|
+
}]
|
|
54
|
+
})
|
|
50
55
|
});
|
|
51
56
|
} else {
|
|
57
|
+
const fix = ParagraphElements._fixSingle(node, {
|
|
58
|
+
context,
|
|
59
|
+
config
|
|
60
|
+
});
|
|
52
61
|
context.report({
|
|
53
62
|
node,
|
|
54
63
|
messageId: 'preferPrimitivesText',
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
...(config.enableUnsafeAutofix ? {
|
|
65
|
+
fix
|
|
66
|
+
} : {
|
|
67
|
+
suggest: [{
|
|
68
|
+
desc: `Convert to Text`,
|
|
69
|
+
fix
|
|
70
|
+
}]
|
|
71
|
+
})
|
|
62
72
|
});
|
|
63
73
|
}
|
|
64
74
|
},
|
|
@@ -19,16 +19,21 @@ export const SpanElements = {
|
|
|
19
19
|
})) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
const fix = SpanElements._fix(node, {
|
|
23
|
+
context,
|
|
24
|
+
config
|
|
25
|
+
});
|
|
22
26
|
context.report({
|
|
23
27
|
node: node.openingElement,
|
|
24
28
|
messageId: 'preferPrimitivesText',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
...(config.enableUnsafeAutofix ? {
|
|
30
|
+
fix
|
|
31
|
+
} : {
|
|
32
|
+
suggest: [{
|
|
33
|
+
desc: `Convert to Text`,
|
|
34
|
+
fix
|
|
35
|
+
}]
|
|
36
|
+
})
|
|
32
37
|
});
|
|
33
38
|
},
|
|
34
39
|
_check(node, {
|
|
@@ -19,16 +19,21 @@ export const StrongElements = {
|
|
|
19
19
|
})) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
const fix = StrongElements._fix(node, {
|
|
23
|
+
context,
|
|
24
|
+
config
|
|
25
|
+
});
|
|
22
26
|
context.report({
|
|
23
27
|
node: node.openingElement,
|
|
24
28
|
messageId: 'preferPrimitivesText',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
...(config.enableUnsafeAutofix ? {
|
|
30
|
+
fix
|
|
31
|
+
} : {
|
|
32
|
+
suggest: [{
|
|
33
|
+
desc: `Convert to Text`,
|
|
34
|
+
fix
|
|
35
|
+
}]
|
|
36
|
+
})
|
|
32
37
|
});
|
|
33
38
|
},
|
|
34
39
|
_check(node, {
|
|
@@ -14,11 +14,9 @@ export const ruleSchema = {
|
|
|
14
14
|
};
|
|
15
15
|
const defaultConfig = {
|
|
16
16
|
failSilently: false,
|
|
17
|
-
shouldEnforceFallbacks: true
|
|
17
|
+
shouldEnforceFallbacks: true,
|
|
18
|
+
enableUnsafeAutofix: false
|
|
18
19
|
};
|
|
19
20
|
export const getConfig = overrides => {
|
|
20
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
21
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
22
|
-
// The empty object is returned, as well as modified in place
|
|
23
21
|
return Object.assign({}, defaultConfig, overrides);
|
|
24
22
|
};
|
|
@@ -146,16 +146,21 @@ export const StyleObject = {
|
|
|
146
146
|
fontFamilyReplacement,
|
|
147
147
|
fontStyleReplacement
|
|
148
148
|
};
|
|
149
|
+
const fix = StyleObject._fix(fixerRefs, context);
|
|
149
150
|
context.report({
|
|
150
151
|
node: fontSizeNode,
|
|
151
152
|
messageId: 'noRawTypographyValues',
|
|
152
153
|
data: {
|
|
153
154
|
payload: `fontSize:${fontSizeRaw}`
|
|
154
155
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
...(config.enableUnsafeAutofix ? {
|
|
157
|
+
fix
|
|
158
|
+
} : {
|
|
159
|
+
suggest: [{
|
|
160
|
+
desc: `Convert to font token`,
|
|
161
|
+
fix
|
|
162
|
+
}]
|
|
163
|
+
})
|
|
159
164
|
});
|
|
160
165
|
} else if (!matchingTokens.length) {
|
|
161
166
|
context.report({
|
|
@@ -3,7 +3,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
3
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
6
|
-
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError,
|
|
6
|
+
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, locToString } from './helpers';
|
|
7
7
|
import { isSize } from './migration-map-temp';
|
|
8
8
|
export var createChecks = function createChecks(context) {
|
|
9
9
|
//create global variables to be shared by the checks
|
|
@@ -229,22 +229,12 @@ export var createChecks = function createChecks(context) {
|
|
|
229
229
|
var newIcon = migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.newIcon;
|
|
230
230
|
var isNewIconMigratable = canAutoMigrateNewIconBasedOnSize(migrationMapObject === null || migrationMapObject === void 0 || (_migrationMapObject$s = migrationMapObject.sizeGuidance) === null || _migrationMapObject$s === void 0 ? void 0 : _migrationMapObject$s.medium);
|
|
231
231
|
var isInNewButton = isNodeOfType(node.parent.parent.parent.name, 'JSXIdentifier') && newButtonImports.has(node.parent.parent.parent.name.name);
|
|
232
|
-
|
|
233
|
-
var UNSAFE_propName = null;
|
|
234
|
-
if (isInNewButton) {
|
|
235
|
-
var result = findUNSAFEProp(node.parent.parent, node.parent.parent.parent);
|
|
236
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
237
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
238
|
-
}
|
|
239
|
-
if (newIcon && isInNewButton && isNewIconMigratable && UNSAFE_size !== 'large' && UNSAFE_size !== 'xlarge') {
|
|
232
|
+
if (newIcon && isInNewButton && isNewIconMigratable) {
|
|
240
233
|
createAutoMigrationError(node, legacyIconImports[node.name].packageName, node.name, errorsAuto);
|
|
241
234
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton, 'medium');
|
|
242
|
-
} else if (
|
|
235
|
+
} else if (!newIcon || !isNewIconMigratable) {
|
|
243
236
|
createCantFindSuitableReplacementError(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
244
237
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton);
|
|
245
|
-
} else if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && UNSAFE_propName) {
|
|
246
|
-
createCantMigrateUnsafeProp(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
247
|
-
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton, UNSAFE_size);
|
|
248
238
|
} else if (!isInNewButton) {
|
|
249
239
|
createCantMigrateFunctionUnknownError(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
250
240
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton);
|
|
@@ -272,15 +262,9 @@ export var createChecks = function createChecks(context) {
|
|
|
272
262
|
var _node$parent2, _node$parent3, _size;
|
|
273
263
|
// Determine if inside a new button - if so:
|
|
274
264
|
// - Assume spread props are safe - still error if props explicitly set to unmigratable values
|
|
275
|
-
// - eventually: look for UNSAFE_iconBefore_size props on the parent button - if it's large/xlarge, fail
|
|
276
265
|
var insideNewButton = false;
|
|
277
|
-
var UNSAFE_propName = null;
|
|
278
|
-
var UNSAFE_size = null;
|
|
279
266
|
if (node.parent && isNodeOfType(node.parent, 'ArrowFunctionExpression') && (_node$parent2 = node.parent) !== null && _node$parent2 !== void 0 && (_node$parent2 = _node$parent2.parent) !== null && _node$parent2 !== void 0 && _node$parent2.parent && isNodeOfType(node.parent.parent.parent, 'JSXAttribute') && isNodeOfType(node.parent.parent.parent.name, 'JSXIdentifier') && (_node$parent3 = node.parent) !== null && _node$parent3 !== void 0 && (_node$parent3 = _node$parent3.parent) !== null && _node$parent3 !== void 0 && (_node$parent3 = _node$parent3.parent) !== null && _node$parent3 !== void 0 && _node$parent3.parent && isNodeOfType(node.parent.parent.parent.parent, 'JSXOpeningElement') && isNodeOfType(node.parent.parent.parent.parent.name, 'JSXIdentifier') && newButtonImports.has(node.parent.parent.parent.parent.name.name)) {
|
|
280
267
|
insideNewButton = true;
|
|
281
|
-
var result = findUNSAFEProp(node.parent.parent.parent, node.parent.parent.parent.parent);
|
|
282
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
283
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
284
268
|
}
|
|
285
269
|
|
|
286
270
|
// Find size prop on node
|
|
@@ -343,11 +327,6 @@ export var createChecks = function createChecks(context) {
|
|
|
343
327
|
createCantMigrateSizeUnknown(node, errorsManual, legacyIconImports[name].packageName, name);
|
|
344
328
|
hasManualMigration = true;
|
|
345
329
|
}
|
|
346
|
-
// Check for unsafe size
|
|
347
|
-
if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && (UNSAFE_propName === 'UNSAFE_iconAfter_size' || UNSAFE_propName === 'UNSAFE_iconBefore_size' || UNSAFE_propName === 'UNSAFE_size')) {
|
|
348
|
-
createCantMigrateUnsafeProp(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[name].packageName, name, errorsManual);
|
|
349
|
-
hasManualMigration = true;
|
|
350
|
-
}
|
|
351
330
|
// Do a set comparison - is requiredAttributesAfterSpread a subset of afterSpreadSet?
|
|
352
331
|
if (hasSpread === true && !Array.from(requiredAttributesAfterSpread).every(function (val) {
|
|
353
332
|
return afterSpreadSet.has(val);
|
|
@@ -124,36 +124,6 @@ export var createCantMigrateIdentifierError = function createCantMigrateIdentifi
|
|
|
124
124
|
};
|
|
125
125
|
pushManualError(locToString(node), errors, myError, packageName, exportName);
|
|
126
126
|
};
|
|
127
|
-
export var findUNSAFEProp = function findUNSAFEProp(iconAttr, button) {
|
|
128
|
-
var UNSAFE_size = null;
|
|
129
|
-
var propName = iconAttr.name.name === 'iconAfter' || iconAttr.name.name === 'iconBefore' || iconAttr.name.name === 'icon' ? iconAttr.name.name : null;
|
|
130
|
-
var buttonAttributes = button.attributes;
|
|
131
|
-
var UNSAFE_propName = propName === 'icon' ? "UNSAFE_size" : propName ? "UNSAFE_".concat(propName, "_size") : null;
|
|
132
|
-
var UNSAFE_size_index = buttonAttributes.findIndex(function (x) {
|
|
133
|
-
return UNSAFE_propName && 'name' in x && x.name && x.name.name === UNSAFE_propName;
|
|
134
|
-
});
|
|
135
|
-
var unsafeAttribute = UNSAFE_size_index !== -1 ? buttonAttributes[UNSAFE_size_index] : null;
|
|
136
|
-
if (unsafeAttribute && isNodeOfType(unsafeAttribute, 'JSXAttribute') && unsafeAttribute.value && isNodeOfType(unsafeAttribute.value, 'Literal') && unsafeAttribute.value.value && ['small', 'large', 'xlarge'].includes(unsafeAttribute.value.value)) {
|
|
137
|
-
UNSAFE_size = unsafeAttribute.value.value;
|
|
138
|
-
} else if (unsafeAttribute && isNodeOfType(unsafeAttribute, 'JSXAttribute') && unsafeAttribute.value && isNodeOfType(unsafeAttribute.value, 'JSXExpressionContainer') && isNodeOfType(unsafeAttribute.value.expression, 'Literal') && ['small', 'large', 'xlarge'].includes(unsafeAttribute.value.expression.value)) {
|
|
139
|
-
UNSAFE_size = unsafeAttribute.value.expression.value;
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
UNSAFE_size: UNSAFE_size,
|
|
143
|
-
UNSAFE_propName: UNSAFE_propName
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
export var createCantMigrateUnsafeProp = function createCantMigrateUnsafeProp(node, propName, value, packageName, iconName, errors) {
|
|
147
|
-
var myError = {
|
|
148
|
-
node: node,
|
|
149
|
-
messageId: 'cantMigrateUnsafeProp',
|
|
150
|
-
data: {
|
|
151
|
-
propName: propName,
|
|
152
|
-
value: value
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
pushManualError(locToString(node), errors, myError, packageName, iconName);
|
|
156
|
-
};
|
|
157
127
|
export var createCantFindSuitableReplacementError = function createCantFindSuitableReplacementError(node, importSource, iconName, errors, sizeIssue) {
|
|
158
128
|
var myError = {
|
|
159
129
|
node: node,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
var defaults = {
|
|
2
|
-
patterns: ['native-elements']
|
|
2
|
+
patterns: ['native-elements'],
|
|
3
|
+
enableUnsafeAutofix: false
|
|
3
4
|
};
|
|
4
5
|
export var getConfig = function getConfig(overrides) {
|
|
5
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
7
|
-
// The empty object is returned, as well as modified in place
|
|
8
6
|
return Object.assign({}, defaults, overrides);
|
|
9
7
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
6
|
|
|
4
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -23,17 +26,21 @@ export var NativeElements = {
|
|
|
23
26
|
})) {
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
|
-
|
|
29
|
+
var fix = NativeElements._fix(node, {
|
|
30
|
+
context: context,
|
|
31
|
+
config: config
|
|
32
|
+
});
|
|
33
|
+
context.report(_objectSpread({
|
|
27
34
|
node: node,
|
|
28
|
-
messageId: 'preferHeading'
|
|
35
|
+
messageId: 'preferHeading'
|
|
36
|
+
}, config.enableUnsafeAutofix ? {
|
|
37
|
+
fix: fix
|
|
38
|
+
} : {
|
|
29
39
|
suggest: [{
|
|
30
|
-
desc:
|
|
31
|
-
fix:
|
|
32
|
-
context: context,
|
|
33
|
-
config: config
|
|
34
|
-
})
|
|
40
|
+
desc: "Convert to Heading",
|
|
41
|
+
fix: fix
|
|
35
42
|
}]
|
|
36
|
-
});
|
|
43
|
+
}));
|
|
37
44
|
},
|
|
38
45
|
_check: function _check(node, _ref2) {
|
|
39
46
|
var config = _ref2.config;
|
|
@@ -2,8 +2,5 @@ var defaults = {
|
|
|
2
2
|
patterns: ['compiled-css-function']
|
|
3
3
|
};
|
|
4
4
|
export var getConfig = function getConfig(overrides) {
|
|
5
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
7
|
-
// The empty object is returned, as well as modified in place
|
|
8
5
|
return Object.assign({}, defaults, overrides);
|
|
9
6
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
var defaults = {
|
|
2
2
|
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
|
|
3
|
-
inheritColor: false
|
|
3
|
+
inheritColor: false,
|
|
4
|
+
enableUnsafeAutofix: false
|
|
4
5
|
};
|
|
5
6
|
export var getConfig = function getConfig(overrides) {
|
|
6
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
7
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
8
|
-
// The empty object is returned, as well as modified in place
|
|
9
7
|
return Object.assign({}, defaults, overrides);
|
|
10
8
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
6
|
|
|
4
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -19,17 +22,21 @@ export var EmphasisElements = {
|
|
|
19
22
|
})) {
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
var fix = EmphasisElements._fix(node, {
|
|
26
|
+
context: context,
|
|
27
|
+
config: config
|
|
28
|
+
});
|
|
29
|
+
context.report(_objectSpread({
|
|
23
30
|
node: node.openingElement,
|
|
24
|
-
messageId: 'preferPrimitivesText'
|
|
31
|
+
messageId: 'preferPrimitivesText'
|
|
32
|
+
}, config.enableUnsafeAutofix ? {
|
|
33
|
+
fix: fix
|
|
34
|
+
} : {
|
|
25
35
|
suggest: [{
|
|
26
36
|
desc: "Convert to Text",
|
|
27
|
-
fix:
|
|
28
|
-
context: context,
|
|
29
|
-
config: config
|
|
30
|
-
})
|
|
37
|
+
fix: fix
|
|
31
38
|
}]
|
|
32
|
-
});
|
|
39
|
+
}));
|
|
33
40
|
},
|
|
34
41
|
_check: function _check(node, _ref2) {
|
|
35
42
|
var context = _ref2.context,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
6
|
|
|
4
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -31,34 +34,42 @@ export var ParagraphElements = {
|
|
|
31
34
|
*/
|
|
32
35
|
var startLoc = (_refs$siblings$0$loc = refs.siblings[0].loc) === null || _refs$siblings$0$loc === void 0 ? void 0 : _refs$siblings$0$loc.start;
|
|
33
36
|
var endLoc = (_refs$siblings$loc = refs.siblings[refs.siblings.length - 1].loc) === null || _refs$siblings$loc === void 0 ? void 0 : _refs$siblings$loc.end;
|
|
34
|
-
|
|
37
|
+
var fix = ParagraphElements._fixMultiple(node, {
|
|
38
|
+
context: context,
|
|
39
|
+
config: config,
|
|
40
|
+
refs: refs
|
|
41
|
+
});
|
|
42
|
+
context.report(_objectSpread({
|
|
35
43
|
loc: startLoc && endLoc && {
|
|
36
44
|
start: startLoc,
|
|
37
45
|
end: endLoc
|
|
38
46
|
},
|
|
39
47
|
node: node.openingElement,
|
|
40
|
-
messageId: 'preferPrimitivesStackedText'
|
|
48
|
+
messageId: 'preferPrimitivesStackedText'
|
|
49
|
+
}, config.enableUnsafeAutofix ? {
|
|
50
|
+
fix: fix
|
|
51
|
+
} : {
|
|
41
52
|
suggest: [{
|
|
42
|
-
desc:
|
|
43
|
-
fix:
|
|
44
|
-
context: context,
|
|
45
|
-
config: config,
|
|
46
|
-
refs: refs
|
|
47
|
-
})
|
|
53
|
+
desc: "Convert to Text and Stack",
|
|
54
|
+
fix: fix
|
|
48
55
|
}]
|
|
49
|
-
});
|
|
56
|
+
}));
|
|
50
57
|
} else {
|
|
51
|
-
|
|
58
|
+
var _fix = ParagraphElements._fixSingle(node, {
|
|
59
|
+
context: context,
|
|
60
|
+
config: config
|
|
61
|
+
});
|
|
62
|
+
context.report(_objectSpread({
|
|
52
63
|
node: node,
|
|
53
|
-
messageId: 'preferPrimitivesText'
|
|
64
|
+
messageId: 'preferPrimitivesText'
|
|
65
|
+
}, config.enableUnsafeAutofix ? {
|
|
66
|
+
fix: _fix
|
|
67
|
+
} : {
|
|
54
68
|
suggest: [{
|
|
55
|
-
desc:
|
|
56
|
-
fix:
|
|
57
|
-
context: context,
|
|
58
|
-
config: config
|
|
59
|
-
})
|
|
69
|
+
desc: "Convert to Text",
|
|
70
|
+
fix: _fix
|
|
60
71
|
}]
|
|
61
|
-
});
|
|
72
|
+
}));
|
|
62
73
|
}
|
|
63
74
|
},
|
|
64
75
|
_check: function _check(node, _ref2) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
6
|
|
|
4
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -19,17 +22,21 @@ export var SpanElements = {
|
|
|
19
22
|
})) {
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
var fix = SpanElements._fix(node, {
|
|
26
|
+
context: context,
|
|
27
|
+
config: config
|
|
28
|
+
});
|
|
29
|
+
context.report(_objectSpread({
|
|
23
30
|
node: node.openingElement,
|
|
24
|
-
messageId: 'preferPrimitivesText'
|
|
31
|
+
messageId: 'preferPrimitivesText'
|
|
32
|
+
}, config.enableUnsafeAutofix ? {
|
|
33
|
+
fix: fix
|
|
34
|
+
} : {
|
|
25
35
|
suggest: [{
|
|
26
36
|
desc: "Convert to Text",
|
|
27
|
-
fix:
|
|
28
|
-
context: context,
|
|
29
|
-
config: config
|
|
30
|
-
})
|
|
37
|
+
fix: fix
|
|
31
38
|
}]
|
|
32
|
-
});
|
|
39
|
+
}));
|
|
33
40
|
},
|
|
34
41
|
_check: function _check(node, _ref2) {
|
|
35
42
|
var context = _ref2.context,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
6
|
|
|
4
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -19,17 +22,21 @@ export var StrongElements = {
|
|
|
19
22
|
})) {
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
var fix = StrongElements._fix(node, {
|
|
26
|
+
context: context,
|
|
27
|
+
config: config
|
|
28
|
+
});
|
|
29
|
+
context.report(_objectSpread({
|
|
23
30
|
node: node.openingElement,
|
|
24
|
-
messageId: 'preferPrimitivesText'
|
|
31
|
+
messageId: 'preferPrimitivesText'
|
|
32
|
+
}, config.enableUnsafeAutofix ? {
|
|
33
|
+
fix: fix
|
|
34
|
+
} : {
|
|
25
35
|
suggest: [{
|
|
26
36
|
desc: "Convert to Text",
|
|
27
|
-
fix:
|
|
28
|
-
context: context,
|
|
29
|
-
config: config
|
|
30
|
-
})
|
|
37
|
+
fix: fix
|
|
31
38
|
}]
|
|
32
|
-
});
|
|
39
|
+
}));
|
|
33
40
|
},
|
|
34
41
|
_check: function _check(node, _ref2) {
|
|
35
42
|
var context = _ref2.context,
|
|
@@ -14,11 +14,9 @@ export var ruleSchema = {
|
|
|
14
14
|
};
|
|
15
15
|
var defaultConfig = {
|
|
16
16
|
failSilently: false,
|
|
17
|
-
shouldEnforceFallbacks: true
|
|
17
|
+
shouldEnforceFallbacks: true,
|
|
18
|
+
enableUnsafeAutofix: false
|
|
18
19
|
};
|
|
19
20
|
export var getConfig = function getConfig(overrides) {
|
|
20
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
21
|
-
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
22
|
-
// The empty object is returned, as well as modified in place
|
|
23
21
|
return Object.assign({}, defaultConfig, overrides);
|
|
24
22
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
5
|
|
|
3
6
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
@@ -146,17 +149,21 @@ export var StyleObject = {
|
|
|
146
149
|
fontFamilyReplacement: fontFamilyReplacement,
|
|
147
150
|
fontStyleReplacement: fontStyleReplacement
|
|
148
151
|
};
|
|
149
|
-
|
|
152
|
+
var fix = StyleObject._fix(fixerRefs, context);
|
|
153
|
+
context.report(_objectSpread({
|
|
150
154
|
node: fontSizeNode,
|
|
151
155
|
messageId: 'noRawTypographyValues',
|
|
152
156
|
data: {
|
|
153
157
|
payload: "fontSize:".concat(fontSizeRaw)
|
|
154
|
-
}
|
|
158
|
+
}
|
|
159
|
+
}, config.enableUnsafeAutofix ? {
|
|
160
|
+
fix: fix
|
|
161
|
+
} : {
|
|
155
162
|
suggest: [{
|
|
156
163
|
desc: "Convert to font token",
|
|
157
|
-
fix:
|
|
164
|
+
fix: fix
|
|
158
165
|
}]
|
|
159
|
-
});
|
|
166
|
+
}));
|
|
160
167
|
} else if (!matchingTokens.length) {
|
|
161
168
|
context.report({
|
|
162
169
|
node: fontSizeNode,
|