diff --git a/.changeset/young-pants-warn.md b/.changeset/young-pants-warn.md new file mode 100644 index 000000000..4895c6ce9 --- /dev/null +++ b/.changeset/young-pants-warn.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-import-x": patch +--- + +fix false positive for no-rename-default diff --git a/src/rules/no-rename-default.ts b/src/rules/no-rename-default.ts index e52ef03db..f8e9eec5c 100644 --- a/src/rules/no-rename-default.ts +++ b/src/rules/no-rename-default.ts @@ -142,6 +142,17 @@ export = createRule<[Options?], MessageId>({ return } + // Some packages have a default export that is meant to be renamed. For example, + // "typescript-eslint" has a default export of "_default" and "eslint-plugin-jsdoc" has a + // default export of "index". + const defaultExportNameTrimmed = defaultExportName.replace(/^_+/, '') // Trim leading underscores. + if ( + defaultExportNameTrimmed === 'default' || + defaultExportNameTrimmed == 'index' + ) { + return + } + const importTarget = node.parent.source?.value const importBasename = path.basename(exportMap.path)