Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>ES6 Import FormatterNew to Visual Studio Code? Get it now.

ES6 Import Formatter

Henry Li

|
26,761 installs
| (1) | Free
Sort the leading imports/requires for ES6.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Import Formatter

Version Installs Ratings

A VSCode plugin which automatically sort the leading import and require statements.

Animation

Installation

VSCode Marketplace

Features

Sort ES6 import statements

Before

import styles from '../index.less';
import { b as bb } from '../../b';
import c from '../../c';
import a from 'a';
import React from 'react';

After

// ESLint proof
// Built-ins and modules from third parties
import a from 'a';
import React from 'react';

// Modules from the current project.
import { b as bb } from '../../b';
import c from '../../c';

// Stylesheets or other assets
import styles from '../index.less';

The require() function from CommonJS is also supported.

Before

var c = require('../../c');
var a = require('a');
var { b: bb } = require('../../b');
var React = require('react');

After

var a = require('a');
var React = require('react');

var { b: bb } = require('../../b');
var c = require('../../c');

Both var and const are supported in CommonJS mode.

Sort Order

Currently the plugin only supports 'default' order which exactly fits my own coding style.

Don't like the default sorting order?

Please leave your requirements in Q&A, and I'll make customized settings for you.

Command

Type Sort imports/requires in VSCode Command Palette.

Context Menu

Click Sort imports/requires in the context menu in JavaScript editor.

Default Keybindings

  • Windows: Ctrl + Alt + S
  • Mac OS X: ⌘ + ⌥ + S

Known Issues

The comments between import/require statements will be removed.

Release Notes

0.1.0

Initial release.

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft