Skip to content

Commit a615dd1

Browse files
authored
feat: remove numeric prefix from component names (#222)
1 parent 2917fc3 commit a615dd1

File tree

5 files changed

+3
-2
lines changed

5 files changed

+3
-2
lines changed

src/scan.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export async function scanComponents (dirs: ScanDir[], srcDir: string): Promise<
5151
componentNameParts.push(prefixParts.shift()!)
5252
}
5353

54-
const componentName = pascalCase(componentNameParts) + pascalCase(fileNameParts)
54+
const componentName = pascalCase(componentNameParts).replace(/^\d+/, '') +
55+
pascalCase(fileNameParts).replace(/^\d+/, '')
5556

5657
if (resolvedNames.has(componentName)) {
5758
// eslint-disable-next-line no-console

test/unit/loader.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ beforeAll(async () => {
2929
function expectToContainImports (content: string) {
3030
const fixturePath = p => path.resolve('test/fixture', p).replace(/\\/g, '\\\\')
3131
expect(content).toContain(`require('${fixturePath('components/Foo.vue')}')`)
32-
expect(content).toContain(`require('${fixturePath('components/base/Button.vue')}')`)
32+
expect(content).toContain(`require('${fixturePath('components/0-base/1.Button.vue')}')`)
3333
expect(content).toContain(`require('${fixturePath('components/icons/Home.vue')}')`)
3434
}
3535

0 commit comments

Comments
 (0)