microsoft / microsoft/TypeScript

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

Open
#30,430 4 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the source.organizeImports code action and the import-sorting behavior shown in the issue, then compare it with the tslint ordering that reports the error. Reproduce the save cycle with the supplied settings and imports; done means organizing imports no longer immediately restores a tslint violation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.