Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-import-sort

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-import-sort

A jS Codemode to sort/organise imports

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47
increased by1466.67%
Maintainers
1
Weekly downloads
 
Created
Source

JS-Import-Sort

Travis-CI npm version Greenkeeper badge


A JS codemod to sort imports

Intro

Built on top of facebook/jscodeshift

This will transform a JS file, sorting and organising its imports (ES2015/ES6).

Example:

    import Main from 'aaaa';
    import {ZMain}  from 'aaaa';


    import First from 'zzz';
    import {Third} from 'zzz';


    import {Second} from 'zzz';


    import * as someDefault from 'bbb';


    import {a as b} from 'packageModule';


    import SomeClass from './MyModule';
    import AnotherClass from '../../Module1';


    import * as util from 'util';

Becomes:

   import * as util from 'util';

   import Main, {ZMain} from 'aaaa';
   import * as someDefault from 'bbb';
   import First, {Second, Third} from 'zzz';

   import {a as b} from 'packageModule';

   import AnotherClass from '../../Module1';
   import SomeClass from './MyModule';

Imports are separated by node, dependencies and devDependencies in package.json, other, and relative imports.

Running

To run, just run:

js-import-sort --path ./*

Options

You can remove the the blank lines between imports by passing --no-blank-lines to the command.

Debugging

js-import-sort supports 3 of the debugging tools from jscodesift, dry, print and verbose which can be used in any combination

use --dry and --print to view the results of the changes before they are applied

FAQs

Package last updated on 02 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc