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

Quick Fix popup stopped suggesting "Add missing import" for JS #1326

Closed
croraf opened this issue Aug 28, 2021 · 11 comments
Closed

Quick Fix popup stopped suggesting "Add missing import" for JS #1326

croraf opened this issue Aug 28, 2021 · 11 comments
Labels
info-needed Issue requires more information from poster

Comments

@croraf
Copy link

croraf commented Aug 28, 2021

  • VS Code Version: 1.59.1
  • OS Version: Linux x64 5.4.0-45-generic

Version: 1.59.1
Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
Date: 2021-08-19T11:54:37.513Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Linux x64 5.4.0-45-generic

Steps to Reproduce:

  1. Context:
  • have a JS project with package.json with "type": "module" property.
  • Have ESLint extension installed, eslint dependency installed locally with npm install eslint
  • Have the following eslint configuration file .eslintrc.cjs:
module.exports = {
  'env': {
    'node': true,
    'es2021': true,
  },
  'extends': 'eslint:recommended',
  'parserOptions': {
    'ecmaVersion': 12,
    'sourceType': 'module'
  },
  'rules': {
  }
};
  1. have two JS files first.js and second.js
// second.js
const myItem = 5;
export {myItem};
// first.js
const temp = myItem;

During typing of myItem in first.js the editor does suggest me to complete it and import, and on confirm it does complete and import myItem. (this part works even without ESLint extension and library)

But, if it is already completed, it does get underlined as a missing error and you can open a Quickfix popup. But in the Quickfix popup there is no suggestion to "Add the missing import".
Screenshot from 2021-08-28 12-53-06
Screenshot from 2021-08-28 12-55-07

The "Add the missing import" suggestion was present until sometime in the mid 2021. (But perhaps I disabled something in the settings also.)

@croraf
Copy link
Author

croraf commented Aug 28, 2021

This is a copy of this issue opened on the vscode repository: microsoft/vscode#131840

@dbaeumer
Copy link
Member

I am not sure what exactly the issue is. Running eslint in the terminal shows exactly the same errors than the eslint extension does

dirkb:~/Projects/../1326 $ ./node_modules/.bin/eslint first.js

/home/dirkb/Projects/playgrounds/1326/first.js
  2:7   error  'temp' is assigned a value but never used  no-unused-vars
  2:14  error  'myItem' is not defined                    no-undef

✖ 2 problems (2 errors, 0 warnings)

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Aug 30, 2021
@croraf
Copy link
Author

croraf commented Aug 30, 2021

Yes.

But the problem is in the Quick Fix feature. When error popup shows up, in its bottom right corner you have a Quick Fix link which opens another popup with suggested fixes. (As shown in the images)

The Quick Fix popup should suggest to add the missing import but it does not since 2 months ago (but perhaps is a problem in my settings.

The "Fix this semi problem" for example is shown correctly as before:
Screenshot from 2021-08-31 02-21-24

@croraf croraf changed the title Quickfix popup stopped suggesting imports for JS Quickfix popup stopped suggesting "Add missing import" for JS Aug 31, 2021
@croraf croraf changed the title Quickfix popup stopped suggesting "Add missing import" for JS Quick Fix popup stopped suggesting "Add missing import" for JS Aug 31, 2021
@dbaeumer
Copy link
Member

When you run eslint in the terminal with the --fix option doe the problem get fixed. If not it is not fixable in the extension either. This can be a configuration problem or something ESLint itself doesn't support anymore.

@croraf
Copy link
Author

croraf commented Aug 31, 2021

I actually tried that later yesterday, and it does not get fixed. This is what suggested me that it has nothing to do with vscode-eslint extension, because the extension just forwards the autofixable things to the vscode, right?

If this is the case then perhaps eslint removed the support for this, or vscode provided the autoimport fix through "typescript language features" or I have some configuration issue.

I mean vscode-eslint hasn't released a new production version since 2020, right? And the issue started to appear mid 2021.

@dbaeumer
Copy link
Member

dbaeumer commented Sep 1, 2021

The latest update on vscode-eslint is from 6/15/2021. Since eslint on the terminal doesn't fix the issue either there is little I can do to fix this. If you ask me the fix came from TypeScript and not from ESLint itself since ESLint is usually single file and wouldn't know from where to import the symbol from.

@dbaeumer
Copy link
Member

dbaeumer commented Sep 1, 2021

I will close the issue.

@dbaeumer dbaeumer closed this as completed Sep 1, 2021
@croraf
Copy link
Author

croraf commented Sep 1, 2021

The latest update on vscode-eslint is from 6/15/2021.

Oh, I see now in the marketplace docs. But here on the github, in code tab it says:
Screenshot from 2021-09-01 11-48-28

Since eslint on the terminal doesn't fix the issue either there is little I can do to fix this. If you ask me the fix came from TypeScript and not from ESLint itself since ESLint is usually single file and wouldn't know from where to import the symbol from.

Makes sense for now.

@kbridge
Copy link

kbridge commented Dec 31, 2022

It's almost 2023 and this problem still seems not fixed yet.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 9, 2023

As said this need to be fixed in TS/JS and not in ESLint.

@Pefington
Copy link

Pefington commented Mar 16, 2023

This works for me: add // @ts-check at the beginning of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants