classNameFromFilename() — astro Function Reference
Architecture documentation for the classNameFromFilename() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 9bb1c1ce_4618_e68d_330b_fc8221783511["classNameFromFilename()"] 6db4d7db_edbb_c18d_7ff5_decb13f1c284["utils.ts"] 9bb1c1ce_4618_e68d_330b_fc8221783511 -->|defined in| 6db4d7db_edbb_c18d_7ff5_decb13f1c284 15e8cb4e_2c8b_a58f_7a91_50841c8f74d1["framework2tsx()"] 15e8cb4e_2c8b_a58f_7a91_50841c8f74d1 -->|calls| 9bb1c1ce_4618_e68d_330b_fc8221783511 0e78e617_6e9f_a2f4_2b15_e4151d28132b["toPascalCase()"] 9bb1c1ce_4618_e68d_330b_fc8221783511 -->|calls| 0e78e617_6e9f_a2f4_2b15_e4151d28132b style 9bb1c1ce_4618_e68d_330b_fc8221783511 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/core/utils.ts lines 52–72
export function classNameFromFilename(filename: string): string {
const url = URI.parse(filename);
const withoutExtensions = Utils.basename(url).slice(0, -Utils.extname(url).length);
const withoutInvalidCharacters = withoutExtensions
.split('')
// Although "-" is invalid, we leave it in, pascal-case-handling will throw it out later
.filter((char) => /[\w$-]/.test(char))
.join('');
const firstValidCharIdx = withoutInvalidCharacters
.split('')
// Although _ and $ are valid first characters for classes, they are invalid first characters
// for tag names. For a better import autocompletion experience, we therefore throw them out.
.findIndex((char) => /[A-Za-z]/.test(char));
const withoutLeadingInvalidCharacters = withoutInvalidCharacters.substring(firstValidCharIdx);
const inPascalCase = toPascalCase(withoutLeadingInvalidCharacters);
const finalName = firstValidCharIdx === -1 ? `A${inPascalCase}` : inPascalCase;
return finalName;
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does classNameFromFilename() do?
classNameFromFilename() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/utils.ts.
Where is classNameFromFilename() defined?
classNameFromFilename() is defined in packages/language-tools/language-server/src/core/utils.ts at line 52.
What does classNameFromFilename() call?
classNameFromFilename() calls 1 function(s): toPascalCase.
What calls classNameFromFilename()?
classNameFromFilename() is called by 1 function(s): framework2tsx.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free