-
Notifications
You must be signed in to change notification settings - Fork 159
Open
Description
Describe the bug
When saving a file and denoland.vscode-deno is used as a default formatter, I get incorrect formatted files. The documentation states that the extension uses the deno.json config file for formatting. The problem with that is, that it does not respect custom linter plugins and thus formats the files incorrectly. It looks like the extension does a deno fmt instead of a deno lint --fix.
To Reproduce
- Use this custom plugin (or any other plugin):
export default {
name: 'colon-spacing',
rules: {
'after-function': {
create(context): Deno.lint.LintVisitor {
return {
TSTypeAnnotation(node): void {
if (node.parent.type === 'FunctionDeclaration') {
const functionStart = node.parent.range[0];
const sectionEnd = node.range[0];
const index =
context.sourceCode.getText(node.parent).substring(0, sectionEnd - functionStart).search(/\) *$/) + 1;
const sectionStart = functionStart + index;
if (index !== -1 && sectionEnd - sectionStart !== 1) {
context.report({
message: `Wrong colon spacing.`,
range: [sectionStart - 1, sectionEnd + 1],
fix(fixer) {
return fixer.replaceTextRange([sectionStart, sectionEnd], ' ');
}
});
}
}
}
};
}
}
}
} satisfies Deno.lint.Plugin;- Use the example code:
export function Foo(prop1: string, prop2: number) : string {
return 'Hello World!';
}- Saving the file, using
denoland.vscode-denoas formatter will result in the following:
- export function Foo(prop1: string, prop2: number) : string {
+ export function Foo(prop1: string, prop2: number): string {
return 'Hello World!';
}- But formatting, using
deno lint --fixresults in:
- export function Foo(prop1: string, prop2: number) : string {
+ export function Foo(prop1: string, prop2: number) : string {
return 'Hello World!';
}Expected behavior
The VS-Code extension should respect the custom linter plugins, provided in the deno.json config.
Versions
- vscode:
1.105.1 - deno:
2.5.6 - extension:
v3.46.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels