Skip to content

Commit 0898f85

Browse files
committed
Refactor getNamespaceIdentifier to use lastPart instead of packageName
1 parent 306e467 commit 0898f85

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

rules/import-style.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,8 @@ const getNamespaceIdentifier = moduleName => {
156156
// Trim trailing slashes and get the last part of the path and remove extension
157157
const lastPart = moduleName.replace(/\/+$/, '').split('/').pop().split('.')[0];
158158

159-
// For scoped packages, we want the package name, not the scope
160-
// @scope/package -> package
161-
// @scope/foo.bar -> foo
162-
const packageName = lastPart.startsWith('@') ? moduleName.split('/').pop().split('.')[0] : lastPart;
163-
164159
// Replace invalid identifier characters and convert to camelCase
165-
let identifier = packageName
160+
let identifier = lastPart
166161
.replaceAll(/[^\dA-Za-z-]/g, '-') // Replace invalid chars with hyphen
167162
.replaceAll(/-./g, x => x[1].toUpperCase()); // Convert to camelCase
168163

0 commit comments

Comments
 (0)