VinceAggrippino
VinceAggrippino•9mo ago

Can I disable deno linting for individual files, or a path?

I'm using VSCode and the Deno extension. I want to use the inbuilt functionality of VSCode for type checking client-side JavaScript (in /website/js for this project) and Deno's type checking for other TypeScript files. I like what I'm doing with TypeScript and I'd like a similar experience with regular JS. So I did some reading about JSDoc and type-safe JS, but when I tried to set it up with a tsconfig.json file, it didn't do anything. If I add // @ts-check to the top of the JS files I want to check, I get incorrect error messages from deno-ts. In the screenshot, for example, it doesn't know what document is and it's just fine with identifying the type of the ui variable as String when it should be Element. It recommends adding something like "lib": ["DOM"] to compilerOptions in the config, but I tried that and it's pretty clear that nothing it's not reading tsconfig.json.
Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
Then I disabled the Deno extension and everything works like I've read that it should and the errors, generated by ts, all make sense. With the Deno extension enabled, but no // @ts-check at the top of the file, there are no error messages. So, Deno's not checking it but it's preventing ts from checking it, too.
No description
2 Replies
VinceAggrippino
VinceAggrippino•9mo ago
UPDATE: Never mind. I found the deno.disablePaths setting. I didn't find any documentation for it, though. Deno Configuration I just saw it on my 458th look through VSCode's settings UI 😅
Deno - Visual Studio Marketplace
Extension for Visual Studio Code - A language server client for Deno.
No description
Deno AI Helper
Deno AI Helper•9mo ago
Yes, you can disable Deno linting for individual files or a path. The documentation provides two ways to ignore linting for files: 1. To ignore a whole file, you can place the // deno-lint-ignore-file directive at the top of the file. Here's an example:
// deno-lint-ignore-file

function foo(): any {
// ...
}
// deno-lint-ignore-file

function foo(): any {
// ...
}
2. If you want to ignore certain diagnostics in the whole file, you can use the // deno-lint-ignore-file <codes...> directive. Here's an example:
// deno-lint-ignore-file no-explicit-any no-empty

function foo(): any {
// ...
}
// deno-lint-ignore-file no-explicit-any no-empty

function foo(): any {
// ...
}
For your specific case, you can add the // deno-lint-ignore-file directive at the top of the JavaScript files you want to exclude from Deno's linting. As for the issue with the Deno extension in VSCode, it seems like you're working on a mixed project with both Deno and client-side JavaScript. The Deno extension, when enabled, disables the built-in JavaScript and TypeScript language services of VSCode and uses the Deno language server instead. This might be causing the issue with type checking in your client-side JavaScript files. The documentation suggests a solution for mixed projects. You can partially enable Deno in your workspace. This means you can have some workspace folders enabled for Deno and some not. You can do this by creating a new workspace (or adding a folder to an existing workspace) and in the settings, configure one of the folders to have deno.enable set to true and one set to false. This way, the Deno language server will only apply diagnostics to the enabled folders, while the other folder will use the built-in TypeScript compiler of VSCode to supply diagnostics for TypeScript and JavaScript files. 🦕