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

console and Promise reported as not defined #918

Closed
mvolkmann opened this issue Mar 27, 2021 · 2 comments · Fixed by sveltejs/kit#722
Closed

console and Promise reported as not defined #918

mvolkmann opened this issue Mar 27, 2021 · 2 comments · Fixed by sveltejs/kit#722
Labels
bug Something isn't working

Comments

@mvolkmann
Copy link

Describe the bug
When editing a .js file in src/lib, if I use console.log or Promise.all they work, but VS Code reports console and Promise as not defined.

To Reproduce
Steps to reproduce the behavior:

Create the file src/lib/demo.js containing the following:

console.log('demo');
const promises = [];
const p = Promise.all(promises);

Notice that console and Promise have squiggly red lines below them.

Expected behavior
VS Code should recognize these names as being defined.

Screenshots
Screen Shot 2021-03-27 at 10 11 23 AM

System (please complete the following information):

  • OS: macOS
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode
@mvolkmann mvolkmann added the bug Something isn't working label Mar 27, 2021
@dummdidumm
Copy link
Member

The Svelte for VS Code extension does not provide any form of diagnostics to JS/TS files. What are the error messages / codes exactly? What is the project type where you are getting this error (SvelteKit, ESLint yes/no, etc)?

@mvolkmann
Copy link
Author

Ah, sorry. The error is from ESLint. An example message is "'console' is not defined. eslint(no-undef)".
This is a SvelteKit project. Maybe I need to modify the .eslintrc.cjs file it provides.
Ah ha! The errors go away if I add this:

  env: {
    es6: true, // for Promise
    node: true // for console
  },

Perhaps these settings should be in .eslintrc.cjs by default for SvelteKit projects.

dummdidumm pushed a commit to sveltejs/kit that referenced this issue Mar 27, 2021
Else it will complain about uses of console.log etc. Added node/browser/es2017 for the 90% use case. Fixes sveltejs/language-tools#918
dummdidumm added a commit to sveltejs/kit that referenced this issue Mar 27, 2021
Else it will complain about uses of console.log etc. Added node/browser/es2017 for the 90% use case. Fixes sveltejs/language-tools#918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants