Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customise globals support #630

Open
carlosala opened this issue Mar 4, 2021 · 13 comments
Open

Customise globals support #630

carlosala opened this issue Mar 4, 2021 · 13 comments
Labels
globals Issues related to acquiring symbols available globally request Feature request

Comments

@carlosala
Copy link

Is your feature request related to a problem? Please describe.

Hi! The Deno linter is absolutely amazing, the best that we have in JS/TS development. But if you try to use it in a Node project, tipical functions as require(), module.exports or process.env are not recognized. Even though, it's possible to use the LSP to every project with the "deno.lint": false, but we just have the classic tsserver.

Describe the solution you'd like

Would be great to recognize Node functions or just avoid them and don't show that horrible warnings.

Thanks!

@kitsonk
Copy link
Contributor

kitsonk commented Mar 4, 2021

The intended use of the extension is for Deno projects. Why would you want to use the extension with Node.js projects?

@carlosala
Copy link
Author

Just because the Deno Linter is the best one.

@kitsonk kitsonk transferred this issue from denoland/vscode_deno Mar 4, 2021
@kitsonk kitsonk changed the title Node Functions Support Customise globals support Mar 4, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Mar 4, 2021

This really is a request to allow customisation of globals support for deno_lint

@kitsonk kitsonk added the request Feature request label Mar 4, 2021
@ebebbington
Copy link

Granted, I feel like Deno could replace ESLint and Prettier for Node projects

I mean, if Deno did allow the customisation, i'd straight up make the move to use Deno over prettier and eslint

@David-Else
Copy link

I am using the LSP/linter for browser code, and adding /// <reference lib="dom" /> at the top of modules that require it. I can use the .ts extension for local imports and esbuild understands and bundles :)

Unfortunately for API's that Deno does not include I get not defined:

HTMLCanvasElement is not define
document is not defined
requestAnimationFrame is not defined

What is the recommended way to overcome this problem? Do I need to wait for the ability to Customise globals support before what I am doing is really a viable workflow?

@bartlomieju
Copy link
Member

We've discussed this issue with @lucacasonato several times and we're leaning towards disabling no-undef altogether. Adding additional globals requires some kind of configuration and since topic of configuration is rather controversial and we can't seem to find a consensus I think it'd be better to skip this rule.

@David-Else
Copy link

@bartlomieju Can I turn off no-undef per module like eslint's /* eslint-disable <rule> */?

@bartlomieju
Copy link
Member

@David-Else sure: // deno-lint-ignore-file no-undef

@David-Else
Copy link

@bartlomieju Would be great to get that added to the docs. I did search for the information before but found nothing.

@bartlomieju
Copy link
Member

bartlomieju commented Mar 5, 2021

@David-Else this info is available at https://lint.deno.land/ignoring-rules

EDIT: Also available in https://deno.land/manual@v1.8.0/tools/linter

@carlosala
Copy link
Author

@David-Else sure: // deno-lint-ignore-file no-undef

That is what I want. Is it possible to globalise this config?

@bartlomieju
Copy link
Member

@David-Else sure: // deno-lint-ignore-file no-undef

That is what I want. Is it possible to globalise this config?

No, currently there's no way as deno_lint has no config besides those ignore directives

@bartlomieju
Copy link
Member

We've discussed this issue with @lucacasonato several times and we're leaning towards disabling no-undef altogether. Adding additional globals requires some kind of configuration and since topic of configuration is rather controversial and we can't seem to find a consensus I think it'd be better to skip this rule.

So no-undef rule has been removed from "recommended" rule set in #649

@bartlomieju bartlomieju added the globals Issues related to acquiring symbols available globally label Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
globals Issues related to acquiring symbols available globally request Feature request
Projects
None yet
Development

No branches or pull requests

5 participants