-
-
Notifications
You must be signed in to change notification settings - Fork 223
Open
Description
Description
TLDR: consider displaying a warning when developers have potentially misspelled filenames (eg: hook.server.js instead of hooks.server.js, page.svelte for +page.svelte)
Proposed solution
This could maybe be displayed as a warning in the 'Problems' panel in VSCode
POC Code:
const SvelteFileNameChecker = vscode.languages.createDiagnosticCollection('svelte file names');
function checkFilename(
file: vscode.Uri,
diagnostic: vscode.DiagnosticCollection
) {
// Somebody smarter than me can probably make some checks ?
diagnostic.set(file, [
new vscode.Diagnostic(
new vscode.Range(0, 0, 0, 0),
'File has wrong name, did you mean xxx',
vscode.DiagnosticSeverity.Warning
),
]);
}
vscode.workspace.onDidCreateFiles((ev) => ev.files.forEach((file) => checkFilename(file, SvelteFileNameChecker )));
vscode.workspace.onDidRenameFiles((ev) => {
ev.files.forEach((file) => {
SvelteFileNameChecker.delete(file.oldUri);
checkFilename(file.newUri, SvelteFileNameChecker );
});
});
vscode.workspace.onDidDeleteFiles((ev) => {
ev.files.forEach((file) => SvelteFileNameChecker.delete(file));
});
context.subscriptions.push(SvelteFileNameChecker);Code misses to only check in the src folder, detecting mistakes, maybe even putting the file in the wrong location (like /routes/hooks.server.js)...
Alternatives
No response
Additional Information, eg. Screenshots

Metadata
Metadata
Assignees
Labels
No labels