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

DOM Errors: Document is not defined #590

Open
ebebbington opened this issue Jan 15, 2021 · 4 comments
Open

DOM Errors: Document is not defined #590

ebebbington opened this issue Jan 15, 2021 · 4 comments
Labels
globals Issues related to acquiring symbols available globally

Comments

@ebebbington
Copy link

Possible to use any tsconfig with deno lint, or any other way to bypass these errors?

$ cat my_file.ts

...
const prevBody = document.body.children.length;
...

$ deno lint --unstable my_file.ts

(no-undef) document is not defined
    const prevBody = document.body.children.length;

@ebebbington ebebbington changed the title Document is not defined DOM Errors: Document is not defined Jan 15, 2021
@magurotuna
Copy link
Member

As far as I know, there's no way of configuring what variables are defined globally.
Currently the list of global variables is constant, being managed in this file. This list doesn't contain document, so no-undef error was triggered in your example.

I'm not really sure document should be listed here, but I guess it should.
@bartlomieju what do you think about it?

@ebebbington
Copy link
Author

Thanks for the response :) I was curious if there's a way about it, currently i am just slapping // deno-lint-ignore no-undef on, and if it helps, my use case is I have code that talks to the DOM (not client side code im trying to lint),and this is exposed via the modules API

So linting is a big part of the project, i guess it isn't 'breaking', but it would be really nice to have :) Though saying that, it seems like document is something that shouldn't be a thing thats enabled by default so a. --config flag. could work well maybe?

But the above is just my opinion

@bartlomieju
Copy link
Member

I'm leaning towards accepting more configuration in Rust API for the linter so we can synchronize list of globals based on the lib value in tsconfig.json users are using. I guess we need to use more of the available sets from https://www.npmjs.com/package/globals and add proper API to the Linter; then we can handle that in deno to sniff out what libs user wishes to use.

@kitsonk
Copy link
Contributor

kitsonk commented Jan 16, 2021

We need to find a way to integrate the linter with TypeScript in the long term so that tsc can be queried and get type information. Maintaining lists of global variables is intenrsincly a bad idea, as any number of things can be changed which impact the global variables.

@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
Projects
None yet
Development

No branches or pull requests

4 participants