Skip to content

Commit

Permalink
fix: update isValidComponentName logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Apr 15, 2024
1 parent a0113d2 commit c13578a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/core/src/helpers/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,22 @@ export function inferFileType(filename: string): FileType {
/**
* 判断组件名是否合法
* @example Button -> valid
* @example div -> valid
* @example undefined | null -> invalid
* @example isStrict ? div -> invalid : div -> valid
* @param name
* @param isStrict 是否严格模式(严格模式不匹配原生标签)
* @returns
*/
export function isValidComponentName(name: string) {
export function isValidComponentName(name: string, isStrict = false) {
if (!name) {
return false;
}
return true;

if (!isStrict) {
return true;
}

const firstChar = name.charAt(0);
return firstChar === firstChar.toUpperCase();
}

/**
Expand Down

0 comments on commit c13578a

Please sign in to comment.