microsoft / microsoft/TypeScript

Respect trailing comma style when organizing imports

Open
#53,660 3 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

I use eslint with a typescript react project, and the comma-dangle rule is in direct conflict with the VS Code built in organize imports feature. Currently the organize imports feature supports multiple import variables on their own line, but will remove the trailing comma, causing the eslint rule to complain. Even if I manually fix it, the organize import feature will just remove it again.

PLEASE add the option to ALLOW trailing commas.

import {
    foo,
    bar,
    bloop,
} from "some-package";

That is perfectly valid Typescript and should be configurable.

Example of the setting in question:

"settings": {
	"editor.formatOnSave": true,
	"[typescript]": {
		"editor.codeActionsOnSave": {
			"source.organizeImports": true
		}
	}
}

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

No source file or test is named. Start by locating the TypeScript organize imports entry point and reviewing how its formatting options are configured, then compare the behavior with ESLint's comma-dangle rule. Done means trailing commas can be enabled for multiline imports without breaking existing organize-imports behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.