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

Organize Imports adding semicolons despite semi:false #49223

Closed
ShMcK opened this issue May 4, 2018 · 5 comments
Closed

Organize Imports adding semicolons despite semi:false #49223

ShMcK opened this issue May 4, 2018 · 5 comments
Assignees
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@ShMcK
Copy link

ShMcK commented May 4, 2018

  • VSCode Version: 1.23.0
  • OS Version: Mac 10.13

"organize imports" automatically adds semi colons to your import statements, even when eslint & prettier set semicolons to false.

 "editor.codeActionsOnSave": {
    "source.organizeImports": true
  },
  "prettier.semi": false,

Steps to Reproduce:

  1. Set prettier & eslint semi colons to false
  2. Run save on a list of unordered imports
  3. See that additional semi colons are added at the end
@vscodebot vscodebot bot added the new release label May 4, 2018
@ShMcK ShMcK changed the title " Organize Imports adding semicolons despite semi:false May 4, 2018
@rebornix
Copy link
Member

rebornix commented May 4, 2018

AFAIK, the organize imports are provided by TypeScript extension, which doesn't read options from other extensions.

@mzygmunt
Copy link

mzygmunt commented May 4, 2018

I think it would be good if we could turn off the semicolons in organizImports configuration.

@mjbvz
Copy link
Contributor

mjbvz commented May 4, 2018

Yes, we don't use settings from other extensions.

Enabling/disabling semicolons in generated imports is tracked by microsoft/TypeScript#19882

@mjbvz mjbvz closed this as completed May 4, 2018
@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label May 4, 2018
@jleclanche
Copy link

For the record, adding "editor.formatOnSave": true to the config sort of solves that issue. The problem is that the typescript import sorting will not follow prettier rules if you're using prettier, so something like this (from prettier):

import {
    a,
    b,
    c,
    d,
    e,
    f,
    g,
} from "./interfaces";

may get turned into something like this (by typescript):

import { a, b, c, d, e, f, g, ... } from "./interfaces";

And then back into the original. With zero meaningful AST changes, and causing a flash of text on save. Super annoying :(

@jongear
Copy link

jongear commented May 7, 2018

I can confirm this also happens in javascript files utilizing babel. Adding "editor.formatOnSave": true forces prettier to run and force cleanup the semicolons after organizing

"editor.codeActionsOnSave": {
  "source.organizeImports": true
},
"editor.formatOnSave": true,

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

6 participants