Skip to content

Commit 66aeb44

Browse files
committed
Avoid triggering the linter with unnecessarily quoted keys
1 parent f0fc140 commit 66aeb44

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/create-vue-lib/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ async function togglePromptIf(condition: boolean, message: string, initial = fal
6060
type Config = {
6161
scopedPackageName: string
6262
unscopedPackageName: string
63+
packageNameAsObjectKey: string
6364
globalVariableName: string
6465
targetDirName: string
6566
targetDirPath: string
@@ -190,6 +191,9 @@ async function init() {
190191

191192
const unscopedPackageName = scopedPackageName.replace(/.*\//, '')
192193

194+
// The earlier check on scopedPackageName makes this slightly easier
195+
const packageNameAsObjectKey = /^[a-zA-Z_$][\w$]*$/.test(scopedPackageName) ? scopedPackageName : `'${scopedPackageName}'`
196+
193197
const targetDirName = await textPrompt('Target directory', unscopedPackageName)
194198

195199
if (targetDirName !== '.' && !isValidDirName(targetDirName)) {
@@ -286,6 +290,7 @@ async function init() {
286290
const config: Config = {
287291
scopedPackageName,
288292
unscopedPackageName,
293+
packageNameAsObjectKey,
289294
globalVariableName,
290295
targetDirName,
291296
targetDirPath,

packages/create-vue-lib/src/template/playground/config/packages/playground/vite.config.mts.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig(({ mode }): UserConfig => ({
3333
]
3434
<%_ } else { _%>
3535
alias: {
36-
'<%- config.scopedPackageName %>': fileURLToPath(new URL('../<%- config.mainPackageDirName %>/src/', import.meta.url))
36+
<%- config.packageNameAsObjectKey %>: fileURLToPath(new URL('../<%- config.mainPackageDirName %>/src/', import.meta.url))
3737
}
3838
<%_ } _%>
3939
},

packages/create-vue-lib/src/template/vitepress/config/packages/docs/.vitepress/config.mts.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default ({ mode }: { mode: string }) => defineConfigWithTheme({
5353
]
5454
<%_ } else { _%>
5555
alias: {
56-
'<%- config.scopedPackageName %>': fileURLToPath(new URL('../../<%- config.mainPackageDirName %>/src/', import.meta.url))
56+
<%- config.packageNameAsObjectKey %>: fileURLToPath(new URL('../../<%- config.mainPackageDirName %>/src/', import.meta.url))
5757
}
5858
<%_ } _%>
5959
},

0 commit comments

Comments
 (0)