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

source.organizeImports organizes imports to a sort order that tslint complains about #30430

Open
StephenWeatherford opened this issue Mar 12, 2019 · 4 comments
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@StephenWeatherford
Copy link

Issue Type: Bug

settings:
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
tslint.json:
{
"extends": "tslint-microsoft-contrib",
...

Code:

import * as cp from 'child_process';
import * as fse from 'fs-extra';
import { IActionContext, parseError } from 'vscode-azureextensionui';
import { ImageNode } from '../explorer/models/imageNode';
import { ext } from '../extensionVariables';
import { docker, DockerEngineType } from './utils/docker-endpoint';
import { ImageItem, quickPickImage } from './utils/quick-pick-image';
import os = require('os');
import vscode = require('vscode');

That gives this error:
image

Auto-fixing the lint issue reorders to this code:

import * as cp from 'child_process';
import * as fse from 'fs-extra';
import os = require('os');
import vscode = require('vscode');
import { IActionContext, parseError } from 'vscode-azureextensionui';
import { ImageNode } from '../explorer/models/imageNode';
import { ext } from '../extensionVariables';
import { docker, DockerEngineType } from './utils/docker-endpoint';
import { ImageItem, quickPickImage } from './utils/quick-pick-image';

Then pressing CTRL+S to save puts it back to the first form, which causes the lint error again.

VS Code version: Code - Insiders 1.33.0-insider (d77d8d561143cc021a82664efc056755c075d070, 2019-03-11T08:47:23.627Z)
OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz (12 x 3600)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 31.73GB (16.54GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (13)
Extension Author (truncated) Version
vscode-antlr4 mik 2.1.1
vscode-cosmosdb ms- 0.10.0
extension-manifest-editor ms- 0.1.5
azure-account ms- 0.8.0
csharp ms- 1.17.1
vscode-typescript-tslint-plugin ms- 1.0.0
azurerm-vscode-tools msa 0.5.0
vscode-docker Pet 0.5.2
vscode-sort-json ric 1.13.0
scope-info sie 0.2.0
tmcolor sle 0.0.1
sort-lines Tyr 1.8.0
win-ca uko 2.4.0
@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 15, 2019
@mjbvz mjbvz removed their assignment Mar 15, 2019
@microsoft microsoft deleted a comment from vscodebot bot Mar 15, 2019
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Experience Enhancement Noncontroversial enhancements labels Mar 25, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 25, 2019
@RyanCavanaugh
Copy link
Member

I don't know what we're going to do when tslint and eslint disagree about import order, but someone can send a PR to tweak this order for now I guess

@felixfbecker
Copy link
Contributor

ESLint is even worse, because it requires import * from imports to come before all cherry-picking imports

@chapmanjacobd
Copy link

chapmanjacobd commented Oct 2, 2020

also one issue is that

import './file'
import { normal } from 'stuff'
import './z-file-which-should-load-first'

will lead to incorrect sort order....

@jasonwilliams
Copy link

It would be really nice to be able to switch the ordering off, not everyone wants that but we do want to remove unused imports, i raised it here: #43141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants