@atlaskit/eslint-plugin-design-system 10.11.0 → 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 +9 -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/es2019/rules/no-legacy-icons/checks.js +3 -24
- package/dist/es2019/rules/no-legacy-icons/helpers.js +0 -28
- package/dist/esm/rules/no-legacy-icons/checks.js +3 -24
- package/dist/esm/rules/no-legacy-icons/helpers.js +0 -30
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +1 -6
- 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-tokens-typography/utils.d.ts +0 -39
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 10.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#120669](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120669)
|
|
8
|
+
[`9e1c531090ea4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9e1c531090ea4) -
|
|
9
|
+
Dropped support for `UNSAFE` icon props in new buttons, which have now been removed.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 10.11.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -236,22 +236,12 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
236
236
|
var newIcon = migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.newIcon;
|
|
237
237
|
var isNewIconMigratable = (0, _helpers.canAutoMigrateNewIconBasedOnSize)(migrationMapObject === null || migrationMapObject === void 0 || (_migrationMapObject$s = migrationMapObject.sizeGuidance) === null || _migrationMapObject$s === void 0 ? void 0 : _migrationMapObject$s.medium);
|
|
238
238
|
var isInNewButton = (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent.parent.name, 'JSXIdentifier') && newButtonImports.has(node.parent.parent.parent.name.name);
|
|
239
|
-
|
|
240
|
-
var UNSAFE_propName = null;
|
|
241
|
-
if (isInNewButton) {
|
|
242
|
-
var result = (0, _helpers.findUNSAFEProp)(node.parent.parent, node.parent.parent.parent);
|
|
243
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
244
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
245
|
-
}
|
|
246
|
-
if (newIcon && isInNewButton && isNewIconMigratable && UNSAFE_size !== 'large' && UNSAFE_size !== 'xlarge') {
|
|
239
|
+
if (newIcon && isInNewButton && isNewIconMigratable) {
|
|
247
240
|
(0, _helpers.createAutoMigrationError)(node, legacyIconImports[node.name].packageName, node.name, errorsAuto);
|
|
248
241
|
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[node.name].packageName, isInNewButton, 'medium');
|
|
249
|
-
} else if (
|
|
242
|
+
} else if (!newIcon || !isNewIconMigratable) {
|
|
250
243
|
(0, _helpers.createCantFindSuitableReplacementError)(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
251
244
|
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[node.name].packageName, isInNewButton);
|
|
252
|
-
} else if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && UNSAFE_propName) {
|
|
253
|
-
(0, _helpers.createCantMigrateUnsafeProp)(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
254
|
-
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[node.name].packageName, isInNewButton, UNSAFE_size);
|
|
255
245
|
} else if (!isInNewButton) {
|
|
256
246
|
(0, _helpers.createCantMigrateFunctionUnknownError)(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
257
247
|
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[node.name].packageName, isInNewButton);
|
|
@@ -279,15 +269,9 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
279
269
|
var _node$parent2, _node$parent3, _size;
|
|
280
270
|
// Determine if inside a new button - if so:
|
|
281
271
|
// - Assume spread props are safe - still error if props explicitly set to unmigratable values
|
|
282
|
-
// - eventually: look for UNSAFE_iconBefore_size props on the parent button - if it's large/xlarge, fail
|
|
283
272
|
var insideNewButton = false;
|
|
284
|
-
var UNSAFE_propName = null;
|
|
285
|
-
var UNSAFE_size = null;
|
|
286
273
|
if (node.parent && (0, _eslintCodemodUtils.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 && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent.parent, 'JSXAttribute') && (0, _eslintCodemodUtils.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 && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent.parent.parent, 'JSXOpeningElement') && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent.parent.parent.name, 'JSXIdentifier') && newButtonImports.has(node.parent.parent.parent.parent.name.name)) {
|
|
287
274
|
insideNewButton = true;
|
|
288
|
-
var result = (0, _helpers.findUNSAFEProp)(node.parent.parent.parent, node.parent.parent.parent.parent);
|
|
289
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
290
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
291
275
|
}
|
|
292
276
|
|
|
293
277
|
// Find size prop on node
|
|
@@ -350,11 +334,6 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
350
334
|
(0, _helpers.createCantMigrateSizeUnknown)(node, errorsManual, legacyIconImports[name].packageName, name);
|
|
351
335
|
hasManualMigration = true;
|
|
352
336
|
}
|
|
353
|
-
// Check for unsafe size
|
|
354
|
-
if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && (UNSAFE_propName === 'UNSAFE_iconAfter_size' || UNSAFE_propName === 'UNSAFE_iconBefore_size' || UNSAFE_propName === 'UNSAFE_size')) {
|
|
355
|
-
(0, _helpers.createCantMigrateUnsafeProp)(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[name].packageName, name, errorsManual);
|
|
356
|
-
hasManualMigration = true;
|
|
357
|
-
}
|
|
358
337
|
// Do a set comparison - is requiredAttributesAfterSpread a subset of afterSpreadSet?
|
|
359
338
|
if (hasSpread === true && !Array.from(requiredAttributesAfterSpread).every(function (val) {
|
|
360
339
|
return afterSpreadSet.has(val);
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.locToString = exports.getMigrationMapObject = exports.getLiteralStringValue = exports.
|
|
8
|
+
exports.locToString = exports.getMigrationMapObject = exports.getLiteralStringValue = exports.createHelpers = exports.createGuidance = exports.createCantMigrateSpreadPropsError = exports.createCantMigrateSizeUnknown = exports.createCantMigrateReExportError = exports.createCantMigrateIdentifierError = exports.createCantMigrateFunctionUnknownError = exports.createCantMigrateColorError = exports.createCantFindSuitableReplacementError = exports.createAutoMigrationError = exports.canMigrateColor = exports.canAutoMigrateNewIconBasedOnSize = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
11
11
|
var _getImportName = require("../utils/get-import-name");
|
|
@@ -134,36 +134,6 @@ var createCantMigrateIdentifierError = exports.createCantMigrateIdentifierError
|
|
|
134
134
|
};
|
|
135
135
|
pushManualError(locToString(node), errors, myError, packageName, exportName);
|
|
136
136
|
};
|
|
137
|
-
var findUNSAFEProp = exports.findUNSAFEProp = function findUNSAFEProp(iconAttr, button) {
|
|
138
|
-
var UNSAFE_size = null;
|
|
139
|
-
var propName = iconAttr.name.name === 'iconAfter' || iconAttr.name.name === 'iconBefore' || iconAttr.name.name === 'icon' ? iconAttr.name.name : null;
|
|
140
|
-
var buttonAttributes = button.attributes;
|
|
141
|
-
var UNSAFE_propName = propName === 'icon' ? "UNSAFE_size" : propName ? "UNSAFE_".concat(propName, "_size") : null;
|
|
142
|
-
var UNSAFE_size_index = buttonAttributes.findIndex(function (x) {
|
|
143
|
-
return UNSAFE_propName && 'name' in x && x.name && x.name.name === UNSAFE_propName;
|
|
144
|
-
});
|
|
145
|
-
var unsafeAttribute = UNSAFE_size_index !== -1 ? buttonAttributes[UNSAFE_size_index] : null;
|
|
146
|
-
if (unsafeAttribute && (0, _eslintCodemodUtils.isNodeOfType)(unsafeAttribute, 'JSXAttribute') && unsafeAttribute.value && (0, _eslintCodemodUtils.isNodeOfType)(unsafeAttribute.value, 'Literal') && unsafeAttribute.value.value && ['small', 'large', 'xlarge'].includes(unsafeAttribute.value.value)) {
|
|
147
|
-
UNSAFE_size = unsafeAttribute.value.value;
|
|
148
|
-
} else if (unsafeAttribute && (0, _eslintCodemodUtils.isNodeOfType)(unsafeAttribute, 'JSXAttribute') && unsafeAttribute.value && (0, _eslintCodemodUtils.isNodeOfType)(unsafeAttribute.value, 'JSXExpressionContainer') && (0, _eslintCodemodUtils.isNodeOfType)(unsafeAttribute.value.expression, 'Literal') && ['small', 'large', 'xlarge'].includes(unsafeAttribute.value.expression.value)) {
|
|
149
|
-
UNSAFE_size = unsafeAttribute.value.expression.value;
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
UNSAFE_size: UNSAFE_size,
|
|
153
|
-
UNSAFE_propName: UNSAFE_propName
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
var createCantMigrateUnsafeProp = exports.createCantMigrateUnsafeProp = function createCantMigrateUnsafeProp(node, propName, value, packageName, iconName, errors) {
|
|
157
|
-
var myError = {
|
|
158
|
-
node: node,
|
|
159
|
-
messageId: 'cantMigrateUnsafeProp',
|
|
160
|
-
data: {
|
|
161
|
-
propName: propName,
|
|
162
|
-
value: value
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
pushManualError(locToString(node), errors, myError, packageName, iconName);
|
|
166
|
-
};
|
|
167
137
|
var createCantFindSuitableReplacementError = exports.createCantFindSuitableReplacementError = function createCantFindSuitableReplacementError(node, importSource, iconName, errors, sizeIssue) {
|
|
168
138
|
var myError = {
|
|
169
139
|
node: node,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError,
|
|
2
|
+
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, locToString } from './helpers';
|
|
3
3
|
import { isSize } from './migration-map-temp';
|
|
4
4
|
export const createChecks = context => {
|
|
5
5
|
//create global variables to be shared by the checks
|
|
@@ -168,22 +168,12 @@ export const createChecks = context => {
|
|
|
168
168
|
const newIcon = migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.newIcon;
|
|
169
169
|
const isNewIconMigratable = canAutoMigrateNewIconBasedOnSize(migrationMapObject === null || migrationMapObject === void 0 ? void 0 : (_migrationMapObject$s = migrationMapObject.sizeGuidance) === null || _migrationMapObject$s === void 0 ? void 0 : _migrationMapObject$s.medium);
|
|
170
170
|
const isInNewButton = isNodeOfType(node.parent.parent.parent.name, 'JSXIdentifier') && newButtonImports.has(node.parent.parent.parent.name.name);
|
|
171
|
-
|
|
172
|
-
let UNSAFE_propName = null;
|
|
173
|
-
if (isInNewButton) {
|
|
174
|
-
const result = findUNSAFEProp(node.parent.parent, node.parent.parent.parent);
|
|
175
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
176
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
177
|
-
}
|
|
178
|
-
if (newIcon && isInNewButton && isNewIconMigratable && UNSAFE_size !== 'large' && UNSAFE_size !== 'xlarge') {
|
|
171
|
+
if (newIcon && isInNewButton && isNewIconMigratable) {
|
|
179
172
|
createAutoMigrationError(node, legacyIconImports[node.name].packageName, node.name, errorsAuto);
|
|
180
173
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton, 'medium');
|
|
181
|
-
} else if (
|
|
174
|
+
} else if (!newIcon || !isNewIconMigratable) {
|
|
182
175
|
createCantFindSuitableReplacementError(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
183
176
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton);
|
|
184
|
-
} else if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && UNSAFE_propName) {
|
|
185
|
-
createCantMigrateUnsafeProp(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
186
|
-
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton, UNSAFE_size);
|
|
187
177
|
} else if (!isInNewButton) {
|
|
188
178
|
createCantMigrateFunctionUnknownError(node, legacyIconImports[node.name].packageName, node.name, errorsManual);
|
|
189
179
|
guidance[locToString(node)] = createGuidance(legacyIconImports[node.name].packageName, isInNewButton);
|
|
@@ -211,15 +201,9 @@ export const createChecks = context => {
|
|
|
211
201
|
var _node$parent2, _node$parent2$parent, _node$parent3, _node$parent3$parent, _node$parent3$parent$, _size;
|
|
212
202
|
// Determine if inside a new button - if so:
|
|
213
203
|
// - Assume spread props are safe - still error if props explicitly set to unmigratable values
|
|
214
|
-
// - eventually: look for UNSAFE_iconBefore_size props on the parent button - if it's large/xlarge, fail
|
|
215
204
|
let insideNewButton = false;
|
|
216
|
-
let UNSAFE_propName = null;
|
|
217
|
-
let UNSAFE_size = null;
|
|
218
205
|
if (node.parent && isNodeOfType(node.parent, 'ArrowFunctionExpression') && (_node$parent2 = node.parent) !== null && _node$parent2 !== void 0 && (_node$parent2$parent = _node$parent2.parent) !== null && _node$parent2$parent !== void 0 && _node$parent2$parent.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$parent = _node$parent3.parent) !== null && _node$parent3$parent !== void 0 && (_node$parent3$parent$ = _node$parent3$parent.parent) !== null && _node$parent3$parent$ !== void 0 && _node$parent3$parent$.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)) {
|
|
219
206
|
insideNewButton = true;
|
|
220
|
-
const result = findUNSAFEProp(node.parent.parent.parent, node.parent.parent.parent.parent);
|
|
221
|
-
UNSAFE_size = result.UNSAFE_size;
|
|
222
|
-
UNSAFE_propName = result.UNSAFE_propName;
|
|
223
207
|
}
|
|
224
208
|
|
|
225
209
|
// Find size prop on node
|
|
@@ -273,11 +257,6 @@ export const createChecks = context => {
|
|
|
273
257
|
createCantMigrateSizeUnknown(node, errorsManual, legacyIconImports[name].packageName, name);
|
|
274
258
|
hasManualMigration = true;
|
|
275
259
|
}
|
|
276
|
-
// Check for unsafe size
|
|
277
|
-
if ((UNSAFE_size === 'large' || UNSAFE_size === 'xlarge') && (UNSAFE_propName === 'UNSAFE_iconAfter_size' || UNSAFE_propName === 'UNSAFE_iconBefore_size' || UNSAFE_propName === 'UNSAFE_size')) {
|
|
278
|
-
createCantMigrateUnsafeProp(node, UNSAFE_propName, UNSAFE_size, legacyIconImports[name].packageName, name, errorsManual);
|
|
279
|
-
hasManualMigration = true;
|
|
280
|
-
}
|
|
281
260
|
// Do a set comparison - is requiredAttributesAfterSpread a subset of afterSpreadSet?
|
|
282
261
|
if (hasSpread === true && !Array.from(requiredAttributesAfterSpread).every(val => afterSpreadSet.has(val)) && !insideNewButton) {
|
|
283
262
|
const missingProps = Array.from(requiredAttributesAfterSpread).filter(val => !afterSpreadSet.has(val));
|
|
@@ -118,34 +118,6 @@ export const createCantMigrateIdentifierError = (node, packageName, exportName,
|
|
|
118
118
|
};
|
|
119
119
|
pushManualError(locToString(node), errors, myError, packageName, exportName);
|
|
120
120
|
};
|
|
121
|
-
export const findUNSAFEProp = (iconAttr, button) => {
|
|
122
|
-
let UNSAFE_size = null;
|
|
123
|
-
const propName = iconAttr.name.name === 'iconAfter' || iconAttr.name.name === 'iconBefore' || iconAttr.name.name === 'icon' ? iconAttr.name.name : null;
|
|
124
|
-
const buttonAttributes = button.attributes;
|
|
125
|
-
const UNSAFE_propName = propName === 'icon' ? `UNSAFE_size` : propName ? `UNSAFE_${propName}_size` : null;
|
|
126
|
-
const UNSAFE_size_index = buttonAttributes.findIndex(x => UNSAFE_propName && 'name' in x && x.name && x.name.name === UNSAFE_propName);
|
|
127
|
-
let unsafeAttribute = UNSAFE_size_index !== -1 ? buttonAttributes[UNSAFE_size_index] : null;
|
|
128
|
-
if (unsafeAttribute && isNodeOfType(unsafeAttribute, 'JSXAttribute') && unsafeAttribute.value && isNodeOfType(unsafeAttribute.value, 'Literal') && unsafeAttribute.value.value && ['small', 'large', 'xlarge'].includes(unsafeAttribute.value.value)) {
|
|
129
|
-
UNSAFE_size = unsafeAttribute.value.value;
|
|
130
|
-
} 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)) {
|
|
131
|
-
UNSAFE_size = unsafeAttribute.value.expression.value;
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
UNSAFE_size,
|
|
135
|
-
UNSAFE_propName
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
export const createCantMigrateUnsafeProp = (node, propName, value, packageName, iconName, errors) => {
|
|
139
|
-
const myError = {
|
|
140
|
-
node,
|
|
141
|
-
messageId: 'cantMigrateUnsafeProp',
|
|
142
|
-
data: {
|
|
143
|
-
propName,
|
|
144
|
-
value
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
pushManualError(locToString(node), errors, myError, packageName, iconName);
|
|
148
|
-
};
|
|
149
121
|
export const createCantFindSuitableReplacementError = (node, importSource, iconName, errors, sizeIssue) => {
|
|
150
122
|
const myError = {
|
|
151
123
|
node,
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
import { type JSXAttribute, type
|
|
2
|
+
import { type JSXAttribute, type Node } from 'eslint-codemod-utils';
|
|
3
3
|
import { type Size } from './migration-map-temp';
|
|
4
4
|
export type iconMigrationError = Rule.ReportDescriptor;
|
|
5
5
|
export type errorsListManual = {
|
|
@@ -50,11 +50,6 @@ export declare const canMigrateColor: (color: string) => boolean;
|
|
|
50
50
|
export declare const locToString: (node: Node) => string;
|
|
51
51
|
export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
|
|
52
52
|
export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
|
|
53
|
-
export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpeningElement) => {
|
|
54
|
-
UNSAFE_size: "small" | "large" | "xlarge" | null;
|
|
55
|
-
UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
|
|
56
|
-
};
|
|
57
|
-
export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
|
|
58
53
|
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual, sizeIssue?: boolean) => void;
|
|
59
54
|
export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
60
55
|
export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
@@ -42,7 +42,6 @@ export declare const fontFamilyTokens: ({
|
|
|
42
42
|
introduced: string;
|
|
43
43
|
description: string;
|
|
44
44
|
deprecated?: undefined;
|
|
45
|
-
responsiveSmallerVariant?: undefined;
|
|
46
45
|
};
|
|
47
46
|
value: string;
|
|
48
47
|
filePath: string;
|
|
@@ -54,7 +53,6 @@ export declare const fontFamilyTokens: ({
|
|
|
54
53
|
introduced: string;
|
|
55
54
|
description: string;
|
|
56
55
|
deprecated?: undefined;
|
|
57
|
-
responsiveSmallerVariant?: undefined;
|
|
58
56
|
};
|
|
59
57
|
value: string;
|
|
60
58
|
};
|
|
@@ -68,7 +66,6 @@ export declare const fontFamilyTokens: ({
|
|
|
68
66
|
introduced: string;
|
|
69
67
|
description: string;
|
|
70
68
|
deprecated: string;
|
|
71
|
-
responsiveSmallerVariant?: undefined;
|
|
72
69
|
};
|
|
73
70
|
value: string;
|
|
74
71
|
filePath: string;
|
|
@@ -80,7 +77,6 @@ export declare const fontFamilyTokens: ({
|
|
|
80
77
|
introduced: string;
|
|
81
78
|
description: string;
|
|
82
79
|
deprecated: string;
|
|
83
|
-
responsiveSmallerVariant?: undefined;
|
|
84
80
|
};
|
|
85
81
|
value: string;
|
|
86
82
|
};
|
|
@@ -93,7 +89,6 @@ export declare const fontFamilyTokens: ({
|
|
|
93
89
|
state: string;
|
|
94
90
|
introduced: string;
|
|
95
91
|
description: string;
|
|
96
|
-
responsiveSmallerVariant: string;
|
|
97
92
|
deprecated?: undefined;
|
|
98
93
|
};
|
|
99
94
|
value: string;
|
|
@@ -105,7 +100,6 @@ export declare const fontFamilyTokens: ({
|
|
|
105
100
|
state: string;
|
|
106
101
|
introduced: string;
|
|
107
102
|
description: string;
|
|
108
|
-
responsiveSmallerVariant: string;
|
|
109
103
|
deprecated?: undefined;
|
|
110
104
|
};
|
|
111
105
|
value: {
|
|
@@ -120,39 +114,6 @@ export declare const fontFamilyTokens: ({
|
|
|
120
114
|
name: string;
|
|
121
115
|
path: string[];
|
|
122
116
|
cleanName: string;
|
|
123
|
-
} | {
|
|
124
|
-
attributes: {
|
|
125
|
-
group: string;
|
|
126
|
-
state: string;
|
|
127
|
-
introduced: string;
|
|
128
|
-
description: string;
|
|
129
|
-
deprecated?: undefined;
|
|
130
|
-
responsiveSmallerVariant?: undefined;
|
|
131
|
-
};
|
|
132
|
-
value: string;
|
|
133
|
-
filePath: string;
|
|
134
|
-
isSource: boolean;
|
|
135
|
-
original: {
|
|
136
|
-
attributes: {
|
|
137
|
-
group: string;
|
|
138
|
-
state: string;
|
|
139
|
-
introduced: string;
|
|
140
|
-
description: string;
|
|
141
|
-
deprecated?: undefined;
|
|
142
|
-
responsiveSmallerVariant?: undefined;
|
|
143
|
-
};
|
|
144
|
-
value: {
|
|
145
|
-
fontWeight: string;
|
|
146
|
-
fontSize: string;
|
|
147
|
-
lineHeight: string;
|
|
148
|
-
fontFamily: string;
|
|
149
|
-
fontStyle: string;
|
|
150
|
-
letterSpacing: string;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
name: string;
|
|
154
|
-
path: string[];
|
|
155
|
-
cleanName: string;
|
|
156
117
|
})[];
|
|
157
118
|
export declare function findFontFamilyValueForToken(tokenName: string): string;
|
|
158
119
|
export declare function notUndefined<V>(value: V | undefined): value is V;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
import { type JSXAttribute, type
|
|
2
|
+
import { type JSXAttribute, type Node } from 'eslint-codemod-utils';
|
|
3
3
|
import { type Size } from './migration-map-temp';
|
|
4
4
|
export type iconMigrationError = Rule.ReportDescriptor;
|
|
5
5
|
export type errorsListManual = {
|
|
@@ -50,11 +50,6 @@ export declare const canMigrateColor: (color: string) => boolean;
|
|
|
50
50
|
export declare const locToString: (node: Node) => string;
|
|
51
51
|
export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
|
|
52
52
|
export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
|
|
53
|
-
export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpeningElement) => {
|
|
54
|
-
UNSAFE_size: "small" | "large" | "xlarge" | null;
|
|
55
|
-
UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
|
|
56
|
-
};
|
|
57
|
-
export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
|
|
58
53
|
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual, sizeIssue?: boolean) => void;
|
|
59
54
|
export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
60
55
|
export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
@@ -42,7 +42,6 @@ export declare const fontFamilyTokens: ({
|
|
|
42
42
|
introduced: string;
|
|
43
43
|
description: string;
|
|
44
44
|
deprecated?: undefined;
|
|
45
|
-
responsiveSmallerVariant?: undefined;
|
|
46
45
|
};
|
|
47
46
|
value: string;
|
|
48
47
|
filePath: string;
|
|
@@ -54,7 +53,6 @@ export declare const fontFamilyTokens: ({
|
|
|
54
53
|
introduced: string;
|
|
55
54
|
description: string;
|
|
56
55
|
deprecated?: undefined;
|
|
57
|
-
responsiveSmallerVariant?: undefined;
|
|
58
56
|
};
|
|
59
57
|
value: string;
|
|
60
58
|
};
|
|
@@ -68,7 +66,6 @@ export declare const fontFamilyTokens: ({
|
|
|
68
66
|
introduced: string;
|
|
69
67
|
description: string;
|
|
70
68
|
deprecated: string;
|
|
71
|
-
responsiveSmallerVariant?: undefined;
|
|
72
69
|
};
|
|
73
70
|
value: string;
|
|
74
71
|
filePath: string;
|
|
@@ -80,7 +77,6 @@ export declare const fontFamilyTokens: ({
|
|
|
80
77
|
introduced: string;
|
|
81
78
|
description: string;
|
|
82
79
|
deprecated: string;
|
|
83
|
-
responsiveSmallerVariant?: undefined;
|
|
84
80
|
};
|
|
85
81
|
value: string;
|
|
86
82
|
};
|
|
@@ -93,7 +89,6 @@ export declare const fontFamilyTokens: ({
|
|
|
93
89
|
state: string;
|
|
94
90
|
introduced: string;
|
|
95
91
|
description: string;
|
|
96
|
-
responsiveSmallerVariant: string;
|
|
97
92
|
deprecated?: undefined;
|
|
98
93
|
};
|
|
99
94
|
value: string;
|
|
@@ -105,7 +100,6 @@ export declare const fontFamilyTokens: ({
|
|
|
105
100
|
state: string;
|
|
106
101
|
introduced: string;
|
|
107
102
|
description: string;
|
|
108
|
-
responsiveSmallerVariant: string;
|
|
109
103
|
deprecated?: undefined;
|
|
110
104
|
};
|
|
111
105
|
value: {
|
|
@@ -120,39 +114,6 @@ export declare const fontFamilyTokens: ({
|
|
|
120
114
|
name: string;
|
|
121
115
|
path: string[];
|
|
122
116
|
cleanName: string;
|
|
123
|
-
} | {
|
|
124
|
-
attributes: {
|
|
125
|
-
group: string;
|
|
126
|
-
state: string;
|
|
127
|
-
introduced: string;
|
|
128
|
-
description: string;
|
|
129
|
-
deprecated?: undefined;
|
|
130
|
-
responsiveSmallerVariant?: undefined;
|
|
131
|
-
};
|
|
132
|
-
value: string;
|
|
133
|
-
filePath: string;
|
|
134
|
-
isSource: boolean;
|
|
135
|
-
original: {
|
|
136
|
-
attributes: {
|
|
137
|
-
group: string;
|
|
138
|
-
state: string;
|
|
139
|
-
introduced: string;
|
|
140
|
-
description: string;
|
|
141
|
-
deprecated?: undefined;
|
|
142
|
-
responsiveSmallerVariant?: undefined;
|
|
143
|
-
};
|
|
144
|
-
value: {
|
|
145
|
-
fontWeight: string;
|
|
146
|
-
fontSize: string;
|
|
147
|
-
lineHeight: string;
|
|
148
|
-
fontFamily: string;
|
|
149
|
-
fontStyle: string;
|
|
150
|
-
letterSpacing: string;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
name: string;
|
|
154
|
-
path: string[];
|
|
155
|
-
cleanName: string;
|
|
156
117
|
})[];
|
|
157
118
|
export declare function findFontFamilyValueForToken(tokenName: string): string;
|
|
158
119
|
export declare function notUndefined<V>(value: V | undefined): value is V;
|
package/package.json
CHANGED