A VSCode plugin which automatically sort the leading import and require statements.
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.
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.