@blueprintjs/eslint-plugin
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -5,9 +5,9 @@ declare const _default: { | ||
"icon-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"literal" | "component", ["literal" | "component"], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-core-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-datetime-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-select-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-table-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-timezone-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-core-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-datetime-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-select-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-table-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-timezone-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
}; | ||
export default _default; |
import { TSESLint } from "@typescript-eslint/utils"; | ||
declare type MessageIds = "migration"; | ||
declare type MessageIds = "migration" | "migrationWithPropUsage"; | ||
/** | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components | ||
* in JSX syntax. | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components in JSX syntax. | ||
* | ||
* Only components imported from `packagesToCheck` will be flagged. The lint violation will include | ||
* a recommendation to migrate to the newer, non-deprecated component (this must be specified for each | ||
* component via the second argument `deprecatedToNewComponentMapping`). | ||
* @param packagesToCheck Only components imported from these packages will be flagged. | ||
* | ||
* @param deprecatedComponentConfig Configuration of the deprecated components to lint for. Note that this configuration | ||
* is not exposed to lint rule users, it just lives inside our rule implementations. Lint violations will include a | ||
* recommendation to migrate to the newer, non-deprecated component specified in this mapping. Keys-value pairs may use | ||
* one of two syntaxes: | ||
* - "ComponentV1": "ComponentV2" - Usage of <ComponentV1> will be flagged with a recommendation | ||
* to migrate to <ComponentV2> | ||
* - "ComponentV1.propName": "ComponentV2" - Usage of <ComponentV1 propName={...}> will be flagged with a | ||
* recommendation to migrate to <ComponentV2> | ||
*/ | ||
export declare function createNoDeprecatedComponentsRule(ruleName: string, packagesToCheck: string[], deprecatedToNewComponentMapping: { | ||
[deprecated: string]: string; | ||
}): TSESLint.RuleModule<MessageIds, unknown[]>; | ||
export declare function createNoDeprecatedComponentsRule(ruleName: string, packagesToCheck: string[], deprecatedComponentConfig: Record<string, string>): TSESLint.RuleModule<MessageIds, unknown[]>; | ||
export {}; |
@@ -11,10 +11,16 @@ "use strict"; | ||
/** | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components | ||
* in JSX syntax. | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components in JSX syntax. | ||
* | ||
* Only components imported from `packagesToCheck` will be flagged. The lint violation will include | ||
* a recommendation to migrate to the newer, non-deprecated component (this must be specified for each | ||
* component via the second argument `deprecatedToNewComponentMapping`). | ||
* @param packagesToCheck Only components imported from these packages will be flagged. | ||
* | ||
* @param deprecatedComponentConfig Configuration of the deprecated components to lint for. Note that this configuration | ||
* is not exposed to lint rule users, it just lives inside our rule implementations. Lint violations will include a | ||
* recommendation to migrate to the newer, non-deprecated component specified in this mapping. Keys-value pairs may use | ||
* one of two syntaxes: | ||
* - "ComponentV1": "ComponentV2" - Usage of <ComponentV1> will be flagged with a recommendation | ||
* to migrate to <ComponentV2> | ||
* - "ComponentV1.propName": "ComponentV2" - Usage of <ComponentV1 propName={...}> will be flagged with a | ||
* recommendation to migrate to <ComponentV2> | ||
*/ | ||
function createNoDeprecatedComponentsRule(ruleName, packagesToCheck, deprecatedToNewComponentMapping) { | ||
function createNoDeprecatedComponentsRule(ruleName, packagesToCheck, deprecatedComponentConfig) { | ||
const descriptionFromClause = packagesToCheck.length === 1 ? ` from ${packagesToCheck[0]}` : ""; | ||
@@ -31,7 +37,8 @@ return (0, createRule_1.createRule)({ | ||
messages: { | ||
migration: "{{ deprecatedComponentName }} is deprecated, migrate to {{ newComponentName }} instead", | ||
migration: "Usage of {{ deprecatedComponentName }} is deprecated, migrate to {{ newComponentName }} instead", | ||
migrationWithPropUsage: "Usage of {{ deprecatedComponentName }} with prop '{{ deprecatedPropName }}' is deprecated, migrate to {{ newComponentName }} instead", | ||
}, | ||
schema: [ | ||
{ | ||
enum: ["migration"], | ||
enum: ["migration", "migrationWithPropUsage"], | ||
}, | ||
@@ -43,12 +50,38 @@ ], | ||
const deprecatedImports = []; | ||
// parses out additional deprecated components from entries like { "MenuItem.popoverProps": "MenuItem2" } | ||
const additionalDeprecatedComponents = Object.keys(deprecatedComponentConfig).reduce((components, key) => { | ||
const [componentName, propName] = key.split("."); | ||
if (propName !== undefined) { | ||
components.push(componentName); | ||
} | ||
return components; | ||
}, []); | ||
function isDeprecatedComponent(name) { | ||
if (deprecatedImports.length === 0) { | ||
return false; | ||
} | ||
return deprecatedImports.some(deprecatedImport => (deprecatedImport.type === "function" && deprecatedImport.localFunctionName === name) || | ||
deprecatedToNewComponentMapping[name] != null); | ||
return (deprecatedComponentConfig[name] != null && | ||
deprecatedImports.some(deprecatedImport => deprecatedImport.type === "function" && deprecatedImport.localFunctionName === name)); | ||
} | ||
function isDeprecatedNamespacedComponent(name, property) { | ||
return (deprecatedImports.some(deprecatedImport => deprecatedImport.type === "namespace" && deprecatedImport.namespace === name) && deprecatedToNewComponentMapping[property] != null); | ||
return (deprecatedComponentConfig[property] != null && | ||
deprecatedImports.some(deprecatedImport => deprecatedImport.type === "namespace" && deprecatedImport.namespace === name)); | ||
} | ||
function checkDeprecatedComponentAndProp(jsxOpeningElementChildNode, elementName, openingElementNode) { | ||
const deprecatedProp = openingElementNode.attributes.find(attribute => attribute.type === utils_1.TSESTree.AST_NODE_TYPES.JSXAttribute && | ||
attribute.name.type === utils_1.TSESTree.AST_NODE_TYPES.JSXIdentifier && | ||
deprecatedComponentConfig[`${elementName}.${attribute.name.name}`] != null); | ||
if (deprecatedProp === undefined) { | ||
return; | ||
} | ||
const deprecatedComponentKey = Object.keys(deprecatedComponentConfig).find(key => key.includes(".") && key.split(".")[0] === elementName); | ||
const deprecatedPropName = deprecatedProp.name | ||
.name; | ||
context.report({ | ||
data: { | ||
deprecatedComponentName: elementName, | ||
deprecatedPropName, | ||
newComponentName: deprecatedComponentConfig[deprecatedComponentKey], | ||
}, | ||
messageId: "migrationWithPropUsage", | ||
node: jsxOpeningElementChildNode, | ||
}); | ||
} | ||
// Get the list of all deprecated imports from packages included in the provided list | ||
@@ -70,3 +103,4 @@ return { | ||
case utils_1.TSESTree.AST_NODE_TYPES.ImportSpecifier: | ||
if (deprecatedToNewComponentMapping[importClause.imported.name] != null) { | ||
if (deprecatedComponentConfig[importClause.imported.name] != null || | ||
additionalDeprecatedComponents.includes(importClause.imported.name)) { | ||
deprecatedImports.push({ | ||
@@ -82,3 +116,3 @@ functionName: importClause.imported.name, | ||
}, | ||
// check <DeprecatedComponent /> syntax | ||
// check <DeprecatedComponent> syntax (includes self-closing tags) | ||
"JSXElement > JSXOpeningElement > JSXIdentifier": (node) => { | ||
@@ -89,3 +123,3 @@ if (isDeprecatedComponent(node.name)) { | ||
deprecatedComponentName: node.name, | ||
newComponentName: deprecatedToNewComponentMapping[node.name], | ||
newComponentName: deprecatedComponentConfig[node.name], | ||
}, | ||
@@ -96,4 +130,8 @@ messageId: "migration", | ||
} | ||
else if (isOpeningElement(node.parent)) { | ||
// check <DeprecatedComponent withDeprecatedProp={...}> syntax | ||
checkDeprecatedComponentAndProp(node, node.name, node.parent); | ||
} | ||
}, | ||
// check <Blueprint.DeprecatedComponent /> syntax | ||
// check <Blueprint.DeprecatedComponent> syntax (includes self-closing tags) | ||
"JSXElement > JSXOpeningElement > JSXMemberExpression[property.type='JSXIdentifier']": (node) => { | ||
@@ -110,3 +148,3 @@ if (node.object.type !== utils_1.TSESTree.AST_NODE_TYPES.JSXIdentifier || | ||
deprecatedComponentName: node.property.name, | ||
newComponentName: deprecatedToNewComponentMapping[node.property.name], | ||
newComponentName: deprecatedComponentConfig[node.property.name], | ||
}, | ||
@@ -117,2 +155,6 @@ messageId: "migration", | ||
} | ||
else if (isOpeningElement(node.parent)) { | ||
// check <Blueprint.DeprecatedComponent withDeprecatedProp={...}> syntax | ||
checkDeprecatedComponentAndProp(node, node.property.name, node.parent); | ||
} | ||
}, | ||
@@ -126,3 +168,3 @@ // check `class Foo extends DeprecatedComponent` syntax | ||
deprecatedComponentName: superClass.name, | ||
newComponentName: deprecatedToNewComponentMapping[superClass.name], | ||
newComponentName: deprecatedComponentConfig[superClass.name], | ||
}, | ||
@@ -147,3 +189,3 @@ messageId: "migration", | ||
deprecatedComponentName: superClass.property.name, | ||
newComponentName: deprecatedToNewComponentMapping[superClass.property.name], | ||
newComponentName: deprecatedComponentConfig[superClass.property.name], | ||
}, | ||
@@ -160,2 +202,5 @@ messageId: "migration", | ||
exports.createNoDeprecatedComponentsRule = createNoDeprecatedComponentsRule; | ||
function isOpeningElement(parent) { | ||
return (parent === null || parent === void 0 ? void 0 : parent.type) === utils_1.TSESTree.AST_NODE_TYPES.JSXOpeningElement; | ||
} | ||
//# sourceMappingURL=createNoDeprecatedComponentsRule.js.map |
@@ -7,2 +7,2 @@ /** | ||
*/ | ||
export declare const noDeprecatedComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
@@ -6,4 +6,3 @@ export declare const coreComponentsMigrationMapping: { | ||
CollapsibleList: string; | ||
MenuItem: string; | ||
PanelStack: string; | ||
"MenuItem.popoverProps": string; | ||
Popover: string; | ||
@@ -17,2 +16,2 @@ Tooltip: string; | ||
*/ | ||
export declare const noDeprecatedCoreComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedCoreComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
@@ -13,4 +13,5 @@ "use strict"; | ||
CollapsibleList: "OverflowList", | ||
MenuItem: "MenuItem2", | ||
PanelStack: "PanelStack2", | ||
"MenuItem.popoverProps": "MenuItem2", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// PanelStack: "PanelStack2", | ||
Popover: "Popover2", | ||
@@ -17,0 +18,0 @@ Tooltip: "Tooltip2", |
export declare const datetimeComponentsMigrationMapping: { | ||
DateInput: string; | ||
DateRangeInput: string; | ||
DateTimePicker: string; | ||
}; | ||
@@ -11,2 +10,2 @@ /** | ||
*/ | ||
export declare const noDeprecatedDatetimeComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedDatetimeComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
@@ -11,3 +11,4 @@ "use strict"; | ||
DateRangeInput: "DateRangeInput2", | ||
DateTimePicker: "DatePicker", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// DateTimePicker: "DatePicker", | ||
}; | ||
@@ -14,0 +15,0 @@ /** |
@@ -11,2 +11,2 @@ export declare const selectComponentsMigrationMapping: { | ||
*/ | ||
export declare const noDeprecatedSelectComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedSelectComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
export declare const tableComponentsMigrationMapping: { | ||
ColumnHeaderCell: string; | ||
EditableCell: string; | ||
JSONFormat: string; | ||
RowHeaderCell: string; | ||
Table: string; | ||
TruncatedFormat: string; | ||
@@ -14,2 +10,2 @@ }; | ||
*/ | ||
export declare const noDeprecatedTableComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedTableComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
@@ -9,8 +9,9 @@ "use strict"; | ||
exports.tableComponentsMigrationMapping = { | ||
ColumnHeaderCell: "ColumnHeaderCell2", | ||
EditableCell: "EditableCell2", | ||
JSONFormat: "JSONFormat2", | ||
RowHeaderCell: "RowHeaderCell2", | ||
Table: "Table2", | ||
TruncatedFormat: "TruncatedFormat2", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// ColumnHeaderCell: "ColumnHeaderCell2", | ||
// EditableCell: "EditableCell2", | ||
// RowHeaderCell: "RowHeaderCell2", | ||
// Table: "Table2", | ||
}; | ||
@@ -17,0 +18,0 @@ /** |
@@ -9,2 +9,2 @@ export declare const timezoneComponentsMigrationMapping: { | ||
*/ | ||
export declare const noDeprecatedTimezoneComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
export declare const noDeprecatedTimezoneComponentsRule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration" | "migrationWithPropUsage", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; |
{ | ||
"name": "@blueprintjs/eslint-plugin", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "ESLint rules for use with @blueprintjs packages", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,11 +11,17 @@ /* | ||
type MessageIds = "migration"; | ||
type MessageIds = "migration" | "migrationWithPropUsage"; | ||
/** | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components | ||
* in JSX syntax. | ||
* Higher-order function to create an ESLint rule which checks for usage of deprecated React components in JSX syntax. | ||
* | ||
* Only components imported from `packagesToCheck` will be flagged. The lint violation will include | ||
* a recommendation to migrate to the newer, non-deprecated component (this must be specified for each | ||
* component via the second argument `deprecatedToNewComponentMapping`). | ||
* @param packagesToCheck Only components imported from these packages will be flagged. | ||
* | ||
* @param deprecatedComponentConfig Configuration of the deprecated components to lint for. Note that this configuration | ||
* is not exposed to lint rule users, it just lives inside our rule implementations. Lint violations will include a | ||
* recommendation to migrate to the newer, non-deprecated component specified in this mapping. Keys-value pairs may use | ||
* one of two syntaxes: | ||
* - "ComponentV1": "ComponentV2" - Usage of <ComponentV1> will be flagged with a recommendation | ||
* to migrate to <ComponentV2> | ||
* - "ComponentV1.propName": "ComponentV2" - Usage of <ComponentV1 propName={...}> will be flagged with a | ||
* recommendation to migrate to <ComponentV2> | ||
*/ | ||
@@ -25,5 +31,3 @@ export function createNoDeprecatedComponentsRule( | ||
packagesToCheck: string[], | ||
deprecatedToNewComponentMapping: { | ||
[deprecated: string]: string; | ||
}, | ||
deprecatedComponentConfig: Record<string, string>, | ||
): TSESLint.RuleModule<MessageIds, unknown[]> { | ||
@@ -42,7 +46,10 @@ const descriptionFromClause = packagesToCheck.length === 1 ? ` from ${packagesToCheck[0]}` : ""; | ||
messages: { | ||
migration: "{{ deprecatedComponentName }} is deprecated, migrate to {{ newComponentName }} instead", | ||
migration: | ||
"Usage of {{ deprecatedComponentName }} is deprecated, migrate to {{ newComponentName }} instead", | ||
migrationWithPropUsage: | ||
"Usage of {{ deprecatedComponentName }} with prop '{{ deprecatedPropName }}' is deprecated, migrate to {{ newComponentName }} instead", | ||
}, | ||
schema: [ | ||
{ | ||
enum: ["migration"], | ||
enum: ["migration", "migrationWithPropUsage"], | ||
}, | ||
@@ -58,11 +65,21 @@ ], | ||
// parses out additional deprecated components from entries like { "MenuItem.popoverProps": "MenuItem2" } | ||
const additionalDeprecatedComponents = Object.keys(deprecatedComponentConfig).reduce<string[]>( | ||
(components, key) => { | ||
const [componentName, propName] = key.split("."); | ||
if (propName !== undefined) { | ||
components.push(componentName); | ||
} | ||
return components; | ||
}, | ||
[], | ||
); | ||
function isDeprecatedComponent(name: string) { | ||
if (deprecatedImports.length === 0) { | ||
return false; | ||
} | ||
return deprecatedImports.some( | ||
deprecatedImport => | ||
(deprecatedImport.type === "function" && deprecatedImport.localFunctionName === name) || | ||
deprecatedToNewComponentMapping[name] != null, | ||
return ( | ||
deprecatedComponentConfig[name] != null && | ||
deprecatedImports.some( | ||
deprecatedImport => | ||
deprecatedImport.type === "function" && deprecatedImport.localFunctionName === name, | ||
) | ||
); | ||
@@ -73,9 +90,42 @@ } | ||
return ( | ||
deprecatedComponentConfig[property] != null && | ||
deprecatedImports.some( | ||
deprecatedImport => | ||
deprecatedImport.type === "namespace" && deprecatedImport.namespace === name, | ||
) && deprecatedToNewComponentMapping[property] != null | ||
) | ||
); | ||
} | ||
function checkDeprecatedComponentAndProp( | ||
jsxOpeningElementChildNode: TSESTree.Node, | ||
elementName: string, | ||
openingElementNode: TSESTree.JSXOpeningElement, | ||
) { | ||
const deprecatedProp = openingElementNode.attributes.find( | ||
attribute => | ||
attribute.type === TSESTree.AST_NODE_TYPES.JSXAttribute && | ||
attribute.name.type === TSESTree.AST_NODE_TYPES.JSXIdentifier && | ||
deprecatedComponentConfig[`${elementName}.${attribute.name.name}`] != null, | ||
); | ||
if (deprecatedProp === undefined) { | ||
return; | ||
} | ||
const deprecatedComponentKey = Object.keys(deprecatedComponentConfig).find( | ||
key => key.includes(".") && key.split(".")[0] === elementName, | ||
); | ||
const deprecatedPropName = ((deprecatedProp as TSESTree.JSXAttribute).name as TSESTree.JSXIdentifier) | ||
.name; | ||
context.report({ | ||
data: { | ||
deprecatedComponentName: elementName, | ||
deprecatedPropName, | ||
newComponentName: deprecatedComponentConfig[deprecatedComponentKey!], | ||
}, | ||
messageId: "migrationWithPropUsage", | ||
node: jsxOpeningElementChildNode, | ||
}); | ||
} | ||
// Get the list of all deprecated imports from packages included in the provided list | ||
@@ -97,3 +147,6 @@ return { | ||
case TSESTree.AST_NODE_TYPES.ImportSpecifier: | ||
if (deprecatedToNewComponentMapping[importClause.imported.name] != null) { | ||
if ( | ||
deprecatedComponentConfig[importClause.imported.name] != null || | ||
additionalDeprecatedComponents.includes(importClause.imported.name) | ||
) { | ||
deprecatedImports.push({ | ||
@@ -110,3 +163,3 @@ functionName: importClause.imported.name, | ||
// check <DeprecatedComponent /> syntax | ||
// check <DeprecatedComponent> syntax (includes self-closing tags) | ||
"JSXElement > JSXOpeningElement > JSXIdentifier": (node: TSESTree.JSXIdentifier) => { | ||
@@ -117,3 +170,3 @@ if (isDeprecatedComponent(node.name)) { | ||
deprecatedComponentName: node.name, | ||
newComponentName: deprecatedToNewComponentMapping[node.name], | ||
newComponentName: deprecatedComponentConfig[node.name], | ||
}, | ||
@@ -123,6 +176,9 @@ messageId: "migration", | ||
}); | ||
} else if (isOpeningElement(node.parent)) { | ||
// check <DeprecatedComponent withDeprecatedProp={...}> syntax | ||
checkDeprecatedComponentAndProp(node, node.name, node.parent); | ||
} | ||
}, | ||
// check <Blueprint.DeprecatedComponent /> syntax | ||
// check <Blueprint.DeprecatedComponent> syntax (includes self-closing tags) | ||
"JSXElement > JSXOpeningElement > JSXMemberExpression[property.type='JSXIdentifier']": ( | ||
@@ -144,3 +200,3 @@ node: TSESTree.JSXMemberExpression, | ||
deprecatedComponentName: node.property.name, | ||
newComponentName: deprecatedToNewComponentMapping[node.property.name], | ||
newComponentName: deprecatedComponentConfig[node.property.name], | ||
}, | ||
@@ -150,2 +206,5 @@ messageId: "migration", | ||
}); | ||
} else if (isOpeningElement(node.parent)) { | ||
// check <Blueprint.DeprecatedComponent withDeprecatedProp={...}> syntax | ||
checkDeprecatedComponentAndProp(node, node.property.name, node.parent); | ||
} | ||
@@ -161,3 +220,3 @@ }, | ||
deprecatedComponentName: superClass.name, | ||
newComponentName: deprecatedToNewComponentMapping[superClass.name], | ||
newComponentName: deprecatedComponentConfig[superClass.name], | ||
}, | ||
@@ -186,3 +245,3 @@ messageId: "migration", | ||
deprecatedComponentName: superClass.property.name, | ||
newComponentName: deprecatedToNewComponentMapping[superClass.property.name], | ||
newComponentName: deprecatedComponentConfig[superClass.property.name], | ||
}, | ||
@@ -198,1 +257,5 @@ messageId: "migration", | ||
} | ||
function isOpeningElement(parent: TSESTree.Node | undefined): parent is TSESTree.JSXOpeningElement { | ||
return parent?.type === TSESTree.AST_NODE_TYPES.JSXOpeningElement; | ||
} |
@@ -12,4 +12,5 @@ /* | ||
CollapsibleList: "OverflowList", | ||
MenuItem: "MenuItem2", | ||
PanelStack: "PanelStack2", | ||
"MenuItem.popoverProps": "MenuItem2", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// PanelStack: "PanelStack2", | ||
Popover: "Popover2", | ||
@@ -16,0 +17,0 @@ Tooltip: "Tooltip2", |
@@ -10,3 +10,4 @@ /* | ||
DateRangeInput: "DateRangeInput2", | ||
DateTimePicker: "DatePicker", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// DateTimePicker: "DatePicker", | ||
}; | ||
@@ -13,0 +14,0 @@ |
@@ -8,8 +8,9 @@ /* | ||
export const tableComponentsMigrationMapping = { | ||
ColumnHeaderCell: "ColumnHeaderCell2", | ||
EditableCell: "EditableCell2", | ||
JSONFormat: "JSONFormat2", | ||
RowHeaderCell: "RowHeaderCell2", | ||
Table: "Table2", | ||
TruncatedFormat: "TruncatedFormat2", | ||
// TODO(@adidahiya): Blueprint v6 | ||
// ColumnHeaderCell: "ColumnHeaderCell2", | ||
// EditableCell: "EditableCell2", | ||
// RowHeaderCell: "RowHeaderCell2", | ||
// Table: "Table2", | ||
}; | ||
@@ -16,0 +17,0 @@ |
@@ -21,1 +21,2 @@ /* ! | ||
import "./no-deprecated-components.test"; | ||
import "./no-deprecated-core-components.test"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146197
79
2570