diff --git a/src/scan.ts b/src/scan.ts index 18e8c82..bda169d 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -51,7 +51,8 @@ export async function scanComponents (dirs: ScanDir[], srcDir: string): Promise< componentNameParts.push(prefixParts.shift()!) } - const componentName = pascalCase(componentNameParts) + pascalCase(fileNameParts) + const componentName = pascalCase(componentNameParts).replace(/^\d+/, '') + + pascalCase(fileNameParts).replace(/^\d+/, '') if (resolvedNames.has(componentName)) { // eslint-disable-next-line no-console diff --git a/test/fixture/components/base/Button.vue b/test/fixture/components/0-base/1.Button.vue similarity index 100% rename from test/fixture/components/base/Button.vue rename to test/fixture/components/0-base/1.Button.vue diff --git a/test/fixture/components/base/SecondButton/SecondButton.vue b/test/fixture/components/0-base/SecondButton/SecondButton.vue similarity index 100% rename from test/fixture/components/base/SecondButton/SecondButton.vue rename to test/fixture/components/0-base/SecondButton/SecondButton.vue diff --git a/test/fixture/components/base/SecondButton/index.vue b/test/fixture/components/0-base/SecondButton/index.vue similarity index 100% rename from test/fixture/components/base/SecondButton/index.vue rename to test/fixture/components/0-base/SecondButton/index.vue diff --git a/test/unit/loader.test.ts b/test/unit/loader.test.ts index 39a07da..9b9ead2 100644 --- a/test/unit/loader.test.ts +++ b/test/unit/loader.test.ts @@ -29,7 +29,7 @@ beforeAll(async () => { function expectToContainImports (content: string) { const fixturePath = p => path.resolve('test/fixture', p).replace(/\\/g, '\\\\') expect(content).toContain(`require('${fixturePath('components/Foo.vue')}')`) - expect(content).toContain(`require('${fixturePath('components/base/Button.vue')}')`) + expect(content).toContain(`require('${fixturePath('components/0-base/1.Button.vue')}')`) expect(content).toContain(`require('${fixturePath('components/icons/Home.vue')}')`) }