@barusu/tool-sort-imports v0.0.47
Usage
Install
yarn global add @barusu/tool-sort-importsUsage
barusu-sort-imports 'src/**/*.ts'
Options
Overview
$ barusu-sort-imports --help
Usage: barusu-sort-imports <cwd> [options]
Options:
Options:
-V, --version output the version number
--log-level <level> specify logger level.
--log-name <name> specify logger name.
--log-mode <'normal' | 'loose'> specify logger name.
--log-flag <option> specify logger option. [[no-]<date|title|colorful|inline>] (default: [])
--log-filepath <filepath> specify logger output path.
--log-encoding <encoding> specify output file encoding.
-c, --config-path <configFilepath> config filepaths (default: [])
--parastic-config-path <parasticConfigFilepath> parastic config filepath
--parastic-config-entry <parasticConfigFilepath> parastic config filepath
-P, --pattern <pattern> glob pattern of source file (default: [])
-e, --encoding <encoding> encoding of source file
--max-column <maxColumn> maximum column width
--indent <indent> indent of source codes
--quote <quote> quotation marker surround the module path
--semicolon whether to add a semicolon at the end of import/export statement
--type-first whether the type import/export statements rank ahead
--blank-line-after-statement blank lines after import/export statement
-h, --help display help for commandDetails
--log-*: see cli-options | @barusu-logger-e, --encoding <encoding>: Specify the encoding of the source files.- Default:
utf-8
- Default:
-p, --pattern <pattern>: Specify the glob pattern of source files, see patterns option | globby.- Default:
[]
- Default:
--max-column <maxColumn>: Specify the maximum column width, if the number of characters in oneimport/exportstatement exceeds this limit, line breaks will be performed.- Default:
1000
- Default:
--indent <indent>: Specify indent of source codes.- Default:
- Default:
--quote <quote>: Specify the quotation marker surround the module path.- Default:
'
- Default:
--semicolon: Specify whether to add a semicolon at the end ofimport/exportstatement.- Default:
false
- Default:
--type-first: Whether should make the typeimport/exportstatements printed first.- Default:
true
- Default:
--blank-line-after-statement: Blank lines afterimport/exportstatement.- Default: 2
Options in /package.json
You can also specify options in the <cwd>/package.json, for example:
{
"@barusu/tool-sort-imports": {
"pattern": [
"src/**/*.{ts,tsx}",
"test/**/*.{ts,tsx}"
],
"moduleRanks": [
{
"regex": "^(react|vue|angular)(?:[\/\\-][\\w\\-.\/]*)?$",
"rank": 1.1
},
{
"regex": "^mocha|chai(?:[\/][\\w\\-.\/]*)?$",
"rank": 1.2
},
{
"regex": "^[a-zA-Z\\d][\\w\\-.]*",
"rank": 1.3
},
{
"regex": "^@[a-zA-Z\\d][\\w\\-.]*\\/[a-zA-Z\\d][\\w\\-.]*",
"rank": 1.4
},
{
"regex": "^@\\/",
"rank": 2.1
},
{
"regex": "^(?:\\/|[a-zA-Z]:)",
"rank": 3.1
},
{
"regex": "^[.]{2}[\\/\\\\][^\\n]*",
"rank": 3.2
},
{
"regex": "^[.][\\/\\\\][^\\n]*",
"rank": 3.3
}
],
"indent": " ",
"quote": "'",
"semicolon": false,
"maxColumn": 100,
"typeFirst": true,
"blankLinesAfterStatement": 1
}
}moduleRanksspecified module rank when sortimport/exportstatements. If a module path matches multiple items, only the first matched item is taken.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago