Installations
npm install import-sort-parser-babylon-7
Developer Guide
Typescript
No
Module System
CommonJS
Score
64.8
Supply Chain
59.9
Quality
74.9
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (97.56%)
JavaScript (1.9%)
HCL (0.54%)
Developer
renke
Download Statistics
Total Downloads
4,427
Last Day
5
Last Week
15
Last Month
36
Last Year
191
GitHub Statistics
465 Stars
143 Commits
69 Forks
5 Watching
25 Branches
8 Contributors
Bundle Size
805.64 kB
Minified
191.48 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.2.3
Package Id
import-sort-parser-babylon-7@4.2.3
Unpacked Size
7.59 kB
Size
2.36 kB
File Count
5
Total Downloads
Cumulative downloads
Total Downloads
4,427
Last day
25%
5
Compared to previous day
Last week
25%
15
Compared to previous week
Last month
227.3%
36
Compared to previous month
Last year
-72.4%
191
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
import-sort
import-sort
is a set of packages that allow you to sort your ES2015 (aka ES6)
imports. Both JavaScript and TypeScript files are supported.
Sorting imports
There are multiple ways to actually sort your imports. Just pick the one that suits you most.
- Visual Studio Code
- Atom
- Vim
- JetBrains IDEs (IntelliJ IDEA, WebStorm etc.)
- Command Line
Visual Studio Code (vsc-sort-imports)
Sort your imports directy from within Visual Studio Code.
See sort-imports in the Visual Studio Marketplace for more details.
This extension was originally developed by Peter Juras and is currently maintained by A. MatÃas Quezada. Thank you very much!
Atom (atom-import-sort)
Sort your imports directly from within Atom. Go to
package or install it directly with
apm install atom-import-sort
. The plugin can sort imports in both JavaScript
and TypeScript.
After you installed the package you can sort your imports using the
Ctrl + Alt + o key binding or trigger it
manually from the command palette with the Import Sort: Sort
command.
The package also offers a "sort on save" option to automatically sort your imports whenever you save a JavaScript or TypeScript file. It's disabled by default.
Vim (vim-sort-imports)
Sort your imports directy from within Vim. See vim-sort-imports for more details about the configuration.
JetBrains IDEs
To use import-sort in any of the JetBrains IDEs follow the instructions regarding File Watcher in the
prettier documentation and replace prettier
with import-sort
.
Alternatively, just install the File Watcher plugin and try to import the following File Watcher configuration.
Command Line (import-sort-cli)
Sort your imports from the command line. Useful to sort all your files in bulk
or from a script in your package.json
.
Install it with npm install --save-dev import-sort-cli
or use it directly with
npx import-sort-cli
.
ATTENTION: Since version 4 --write
modifies file in-place. The old
--overwrite
flag was removed. The CLI now behaves closer to
prettier's CLI. Also, the exit code is
now 0 even when unsorted were sorted (unless --list-different
is used.)
Usage: import-sort [OPTION]... [FILE/GLOB]...
Options:
--list-different, -l Print the names of files that are not sorted. [boolean]
--write Edit files in-place. [boolean]
--with-node-modules Process files inside 'node_modules' directory..[boolean]
--version, -v Show version number [boolean]
--help, -h Show help [boolean]
Node.js (import-sort)
Sort your imports via Node.js. For more information take
a look at the code of the import-sort-cli
package.
To use it you probably want to install import-sort
, import-sort-config
, a
parser (say import-sort-parser-babylon
) and a style (say
import-sort-style-eslint
).
The import-sort
library is basically the heart that powers import-sort-cli
and atom-import-sort
and should be used if you want to integrate it with other
environments.
Ignoring files
Sometimes the imports in a certain file should not be sorted. To prevent
import-sort
from sorting a particular file, just add // import-sort-ignore
or /* import-sort-ignore */
to your file. Anwhere in the file is fine.
Dealing with comments
Prior versions of import-sort
had problems with comments that were attached to
imports. This is now mostly fixed and situations like the following should no
longer cause problems.
1import foo from "bar"; // This will move with the import
1// This will also move with the import 2import foo from "bar";
1// This won't move with the import 2 3// This will move with the import 4import foo from "bar"; 5// This won't move with the import
In general, every comment that is directly above the import (no blank line between them) or is on the same line is considered part of it.
That means that things like // eslint-disable line
and // eslint-disable-next-line
are finally supported.
For copyright headers and compiler pragmas (like @flow
) a blank line should be
added after the comment.
1// @flow 2 3import foo from "bar";
Using a different style or parser
Styles (and parsers) can be configured on a per-project basis including support for different types of files (currently JavaScript and TypeScript).
Just add the following to your package.json
and adapt it to your liking:
1"importSort": { 2 ".js, .jsx, .es6, .es, .mjs, .ts, .tsx": { 3 "parser": "babylon", 4 "style": "eslint" 5 } 6}
The keys are a list of file extensions that map to the parser and style that should be used for files that have any of the listed file extensions.
Instead of putting your configuration into your package.json
you can also use
a .importsortrc
file written in JSON. For more details see
cosmiconfig which is used
internally by import-sort
.
By default, import-sort
comes with these styles:
-
import-sort-style-eslint
(default): A style that that is compatible with ESLint's sort-imports rule. -
import-sort-style-module
: A style that groups and sorts by module. -
import-sort-style-renke
: Renke's personal style.
Writing you own custom style
Since styles can now be configured using your package.json
it's way easier to
write and use your own style.
A style is module that should be called import-sort-style-$name
where $name
is the name of the style.
An API is provided to specify how the imports are sorted (see style API for more details).
The best way to write your own style is to look at existing styles like
import-sort-style-renke
and
adapt it to your liking.
Feedback
I appreciate any kind of feedback. Just create an issue or drop me a mail. Thanks!
License
See LICENSE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: ISC License: LICENSE:0
Reason
Found 3/28 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Reason
72 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-2mj8-pj3j-h362
- Warn: Project is vulnerable to: GHSA-gqf6-75v8-vr26
- Warn: Project is vulnerable to: GHSA-v45m-2wcp-gg98
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-3gx7-xhv7-5mx3
- Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9
- Warn: Project is vulnerable to: GHSA-jmqm-f2gx-4fjv
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-6fw4-hr69-g3rv
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-3f95-r44v-8mrg
- Warn: Project is vulnerable to: GHSA-28xr-mwxg-3qc8
- Warn: Project is vulnerable to: GHSA-9p95-fxvg-qgq2
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.9
/10
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More