All Projects → daidodo → format-imports-vscode

daidodo / format-imports-vscode

Licence: MIT license
Format imports and exports for JavaScript and TypeScript in VS Code.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to format-imports-vscode

craft3-blockonomicon
Manage matrix fields on a per-block basis. Bundle presentation with blocks. Render entire matrices with a single line.
Stars: ✭ 32 (-46.67%)
Mutual labels:  export, import
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (+110%)
Mutual labels:  export, import
Grafana Import Export
shell scripts for importing and exporting Grafana's dashboards and datasources
Stars: ✭ 125 (+108.33%)
Mutual labels:  export, import
Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (-25%)
Mutual labels:  export, import
Dataset Serialize
JSON to DataSet and DataSet to JSON converter for Delphi and Lazarus (FPC)
Stars: ✭ 213 (+255%)
Mutual labels:  export, import
Fbx
📜 Single-file binary FBX importer.
Stars: ✭ 47 (-21.67%)
Mutual labels:  export, import
cassandra-exporter
Simple Tool to Export / Import Cassandra Tables into JSON
Stars: ✭ 44 (-26.67%)
Mutual labels:  export, import
Npoi.mapper
Use this tool to import or export data with Excel file. The tool is a convention based mapper between strong typed object and Excel data via NPOI.
Stars: ✭ 348 (+480%)
Mutual labels:  export, import
Sketchup Stl
A SketchUp Ruby Extension that adds STL (STereoLithography) file format import and export.
Stars: ✭ 214 (+256.67%)
Mutual labels:  export, import
Csvreader
csvreader library / gem - read tabular data in the comma-separated values (csv) format the right way (uses best practices out-of-the-box with zero-configuration)
Stars: ✭ 169 (+181.67%)
Mutual labels:  export, import
Elasticsearch Dump
Import and export tools for elasticsearch
Stars: ✭ 5,977 (+9861.67%)
Mutual labels:  export, import
open2fa
Two-factor authentication app with import/export for iOS and macOS. All codes encrypted with AES 256. FaceID & TouchID support included. Written with love in SwiftUI ❤️
Stars: ✭ 24 (-60%)
Mutual labels:  export, import
Lazy importer
library for importing functions from dlls in a hidden, reverse engineer unfriendly way
Stars: ✭ 544 (+806.67%)
Mutual labels:  export, import
Process Migrator
Process migrator node.js utility for VSTS inherited process
Stars: ✭ 49 (-18.33%)
Mutual labels:  export, import
Simple Excel
Read and write simple Excel and CSV files
Stars: ✭ 502 (+736.67%)
Mutual labels:  export, import
Couchimport
CouchDB import tool to allow data to be bulk inserted
Stars: ✭ 125 (+108.33%)
Mutual labels:  export, import
Node Firestore Import Export
Firestore data import and export
Stars: ✭ 271 (+351.67%)
Mutual labels:  export, import
Csvkeychain
Import/export between Apple Keychain.app and plain CSV file.
Stars: ✭ 281 (+368.33%)
Mutual labels:  export, import
Keycloak Config Cli
Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.
Stars: ✭ 147 (+145%)
Mutual labels:  export, import
Portphp
Data import/export framework for PHP
Stars: ✭ 225 (+275%)
Mutual labels:  export, import

JS/TS Import/Export Sorter

Version Downloads Installs Ratings

Automatically format imports and exports for JavaScript and TypeScript in VSCode.

[7.5.x]

Added

  • Add builtin to GroupRule to support NodeJS builtin module imports.
  • Add nodeProtocol to support adding or removing "node:" to builtin module paths.
  • Support React 18 use client directive.
  • Support TypeScript 4.9 satisfies operator.

Table of contents

Features

How to use

  • Auto format on save when autoFormat is set to onSave (this is the default).

  • Auto format via Code Actions on Save (VSCode 1.44+)

    "editor.codeActionsOnSave": ["source.organizeImports.sortImports"]

    or

    "editor.codeActionsOnSave": {"source.organizeImports.sortImports": true}
  • Press shortcut keys, default to Alt+Shift+S.

  • Use Sort Imports/Exports command in the Command Palette (Ctrl+Shift+P).

    1
  • Right click on editor content and select Sort Imports/Exports.

    image

Configuration

The extension reads configurations from the following sources (in precedence from high to low):

  • ESLint configuration if installed.
  • "importSorter" section in package.json
  • import-sorter.json (File name is configurable)
  • Prettier configuration if installed
  • .editorconfig
  • VS Code "editor" and "files" settings
  • VS Code "tsImportSorter" settings

VSCode Settings

The following settings (and default values) are available in VSCode User Settings for this extension:

// Configuration file name.
// Not available in 'import-sorter.json' or 'package.json'.
"tsImportSorter.configuration.configurationFileName": "import-sorter.json",

// When to auto format imports/exports. Valid values are 'off' or 'onSave'.
"tsImportSorter.configuration.autoFormat": "onSave",

// Whether to format exports as well.
"tsImportSorter.configuration.formatExports": true,

// Disable formatting for files matching regular expressions.
"tsImportSorter.configuration.exclude": ["node_modules"],

// Disable formatting for files matching glob patterns.
"tsImportSorter.configuration.excludeGlob": [],

// Sort import declarations by paths or first names. Valid values are 'paths' or 'names'.
"tsImportSorter.sortImportsBy": "paths",

// Grouping rules for path patterns for imports. {} is the fall-back group.
// Wiki: https://github.com/daidodo/format-imports/wiki/Grouping-Rules
"tsImportSorter.configuration.groupRules": [
  "^react(-dom)?$",
  "^@angular/",
  "^vue$",
  "^node:",
  {},
  "^[@]",
  "^[.]"
],

// Global Sorting rules. Valid values are 'none' or an object.
// Wiki: https://github.com/daidodo/format-imports/wiki/Sorting-Rules
"tsImportSorter.configuration.sortRules": {

  // Sorting rule for import paths. Valid values are 'none' or an array.
  "paths": ["_", "aA"],

  // Sorting rule for imported/exported names. Valid values are 'none' or an array.
  "names": ["_", "aA"]
}

// By default all unused imports are removed. Keep some or all them around with this
// setting via a list of regular expressions if you need.
// e.g. In order to keep all unused imports, use [".*"]
"tsImportSorter.configuration.keepUnused": [],

// Line wrapping style. Valid values are 'prettier' or an object.
// Wiki: https://github.com/daidodo/format-imports/wiki/Line-Wrapping-Style
"tsImportSorter.configuration.wrappingStyle": {

  // Max binding names per line before wrapping for imports. 0 for no limit.
  "maxBindingNamesPerLine": 1,

  // Max default and binding names per line before wrapping for imports. 0 for no limit.
  "maxDefaultAndBindingNamesPerLine": 2,

  // Max binding names per line before wrapping for exports. 0 for no limit.
  "maxExportNamesPerLine": 0,

  // Max names on wrapped lines. 0 for no limit.
  "maxNamesPerWrappedLine": 1,

  // Whether to ignore trailing comments when counting line length.
  "ignoreComments": false
}

// Number of empty lines between groups (NOT sub-groups).
"tsImportSorter.configuration.emptyLinesBetweenGroups": 1,

// Number of empty lines after the last import declaration.
"tsImportSorter.configuration.emptyLinesAfterAllImports": 1,

// Whether to remove the last slash when normalizing paths.
"tsImportSorter.configuration.removeLastSlashInPath": false,

// Whether to remove the last 'index' when normalizing paths.
"tsImportSorter.configuration.removeLastIndexInPath": false,

// Whether to enable debug mode and write detailed logs to VSCode output channel.
// Not available in 'import-sorter.json' or 'package.json'.
"tsImportSorter.configuration.development.enableDebug": false,

Config Files

Most of the above settings, plus more in Configuration are also available in import-sorter.json or package.json under "importSorter section.

For examples:

import-sorter.json:

{
  "autoFormat": "onSave",
  "quoteMark": "single",
  "wrappingStyle": {
    "maxBindingNamesPerLine": 2
  }
}

Or

package.json:

{
  "importSorter": {
    "autoFormat": "onSave",
    "quoteMark": "single",
    "wrappingStyle": {
      "maxBindingNamesPerLine": 2
    }
  }
}

ESLint Compatibility

If installed, ESLint and plugins rules will be detected and consulted, so that the result code will comply to the lint rules.

For how it works, please check the ESLint Compatibility wiki.

Monorepo Support

When reading config from import-sorter.json or package.json, Format-Imports will automatically look for them in the directory of the file to be formatted, and in successive parent directories all the way up to the root directory of the filesystem (unless "root": true is specified).

Multiple import-sorter.json or package.json files can be useful when you want different configurations for different sub projects of your monorepo, while common settings are kept in the root import-sorter.json or package.json. When there is a conflict, the sub project (more localized) config will take precedence.

Contribution

This is an open source project so your contribution will be well appreciated.

Please refer to CONTRIBUTING.md for more information.

Thanks

The inspiration came from import-sorter.

License

MIT © Zhao DAI [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].