Code Monkey home page Code Monkey logo

format-imports-vscode's People

Contributors

daidodo avatar danielkcz avatar dependabot[bot] avatar dfoverdx avatar karlhorky avatar zddai avatar zefling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

format-imports-vscode's Issues

when exports are reformatted, newline at end-of-file is removed

Describe the bug
Supposing you have an export at the end of a file with a newline after it, when formatExports is turned on, the newline is removed. This conflicts with the eslint rule eol-last

To Reproduce
Steps to reproduce the behavior:

  1. have an export at the end of a file export { Foo }; followed by a newline
  2. format imports

Expected behavior
Newline following export should be preserved

Actual behavior
Newline is removed, causing eol-last linting error

OS (please complete the following information):

  • OS: Windows / WSL2
  • Version: 20H2

VS Code (please complete the following information):

  • Version: 1.52.1

import-sorter.json

{
    "keepUnused":[".*"],
    "wrappingStyle": {
        "maxBindingNamesPerLine": 5,
        "maxDefaultAndBindingNamesPerLine": 5,
        "maxExportNamesPerLine": 5,
        "maxNamesPerWrappedLine": 1,
        "ignoreComments": false
    }
}

import '.' is changed to import './'

First, thank you for taking over this extension and improving it. I was sorry to see TypeScript Import Sorter become unmaintained. I'm glad to have an up-to-date alternative because it saves my team a lot of hassle and code conflicts with ordering of imports.

Describe the bug
When I need to import the default module in a folder from another module in the same folder, I typically do it with:

import foo from '.'

This extension automatically replaces that import with:

import foo from './'

Importing from './' (and even './index') triggers linting errors due to it being redundant ('.' is sufficient):

  ✖  2:22  Useless path segments for "./", should be "."                   import/no-useless-path-segments

Note: This happens with both JavaScript and TypeScript.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file in src named index.js. In index.js, put this code:
const foo = 'bar'
export default foo
  1. Create another file in src named cli.js. In cli.js, put this code:
import foo from '.'
console.log(foo)
  1. Save foo.js or otherwise trigger the import sorting extension.
  2. See the import path change.

Expected behavior
I expect the import path to be the shortest/simplest path necessary to successfully import the module. In this case, it should stay as '.'.

Actual behavior
The import path is always changed to './', which triggers linting errors for redundancy in the path.

Screenshots
If applicable, add screenshots to help explain your problem.

OS (please complete the following information):

  • OS: Windows
  • Version: 10

VS Code (please complete the following information):

  • Version: 1.51.1 (latest stable as of 11/15/2020)

repo with reproduction of issue
https://github.com/neodon/tsimportsorter-issue

Installed VS Code extensions
I disabled all extensions except JS/TS Import/Export Sorter v3.0.4

I appreciate any discussion, and if there is agreement that this is a bug, I would be interested in submitting a pull request. Thank you.

Edit: After looking at the tests for path normalization and giving it some more thought, I think the fix for this bug would be limited to paths like ., .., ../.., etc and not something like ./foo/. The reason is that you might have both foo.js and foo/index.js, so the trailing slash in those cases is needed to differentiate.

Ignore specified characters when sorting

Is your feature request related to a problem? Please describe.
Hi, I found another case in my workspace that is a violation of what I wanted from #4.

import { ActivityGroup, ACTIVITY_CHART_TOTAL_DAYS, RootDashboardPageProvider } from "./";

It's supposed to look like this:

import { ACTIVITY_CHART_TOTAL_DAYS, ActivityGroup, RootDashboardPageProvider } from "./";

I'm guessing that it's the underscore that's causing the problem here because my sortRules is:

"sortRules": {
    "names": ["Aa"]
}

Describe the solution you'd like
It's probably worth it to allow the user to specify what characters, strings or regular expressions should be ignored when determining how to sort imports.

Describe alternatives you've considered
Are there any alternatives? If so, I'd like to know what they are.

Additional context

Save is slow

Describe the bug
Save is much slower when the extension is enabled

To Reproduce
Just use save

Expected behavior
A save that is done without too much slowing down.

Actual behavior
The save is slow, in some cases it is necessary to do 2 saves.

OS (please complete the following information):

  • OS: Windows
  • Version: 3.0.4

VS Code (please complete the following information):

  • Version: 1.51.1

tsconfig.json (if any)

{
    "extends": "tslint:recommended",
    "linterOptions": {
      "exclude": [
        "**/*.notslint.ts"
      ]
    },
    "rules": {
      "array-type": false,
      "arrow-parens": false,
      "deprecation": false,
      "component-class-suffix": true,
      "contextual-lifecycle": true,
      "directive-class-suffix": false,
      "directive-selector": [
        true,
        "camelCase"
      ],
      "component-selector": [
        true,
        "element",
        "kebab-case"
      ],
      "import-blacklist": [
        true,
        "rxjs/Rx"
      ],
      "interface-name": false,
      "max-classes-per-file": false,
      "max-line-length": [
        true,
        120
      ],
      "member-access": false,
      "member-ordering": [
        true,
        {
          "order": [
            "static-field",
            "instance-field",
            "static-method",
            "instance-method"
          ]
        }
      ],
      "no-consecutive-blank-lines": false,
      "no-console": [
        true,
        "debug",
        "info",
        "time",
        "timeEnd",
        "trace"
      ],
      "no-empty": false,
      "no-inferrable-types": false,
      "no-non-null-assertion": true,
      "no-redundant-jsdoc": false,
      "no-switch-case-fall-through": true,
      "no-use-before-declare": true,
      "no-var-requires": false,
      "object-literal-key-quotes": false,
      "object-literal-sort-keys": false,
      "ordered-imports": false,
      "quotemark": [
        true,
        "single",
        "avoid-escape"
      ],
      "trailing-comma": false,
      "no-conflicting-lifecycle": false,
      "no-host-metadata-property": true,
      "no-input-rename": false,
      "no-inputs-metadata-property": true,
      "no-output-native": false,
      "no-output-on-prefix": false,
      "no-output-rename": false,
      "no-outputs-metadata-property": true,
      "template-banana-in-box": true,
      "template-no-negated-async": true,
      "use-lifecycle-interface": false,
      "use-pipe-transform-interface": true,
      "no-angle-bracket-type-assertion": false,
      "arrow-return-shorthand": false,
      "no-namespace": false,
      "interface-over-type-literal": false,
      "adjacent-overload-signatures": false,
      "one-variable-per-declaration": false,
      "ban": false,
      "ban-types": false,
      "no-string-literal": false,
      "prefer-for-of": false,
      "object-literal-shorthand": false,
      "space-before-function-paren": false,
      "only-arrow-functions": false,
      "semicolon": [
        true,
        "always"
      ],
      "whitespace": [
        true,
        "check-branch",
        "check-decl",
        "check-operator",
        "check-separator",
        "check-type"
      ],
      "import-destructuring-spacing": true,
      "framework-underscore-private": [
        true,
        "check-property",
        "check-constructor",
        "check-method"
      ],
      "framework-call-subject-next": true,
      "variable-name": [
        true,
        "check-format",
        "allow-leading-underscore",
        "ban-keywords"
      ]
    },
    "rulesDirectory": [
      "codelyzer",
      "@tools/tslint-rules"
    ]
  }

.editorconfig (if any)

    "tsImportSorter.configuration.maxBindingNamesPerLine": 0,
    "tsImportSorter.configuration.maxDefaultAndBindingNamesPerLine": 0,
    "tsImportSorter.configuration.maxNamesPerWrappedLine": 0,
    "tsImportSorter.configuration.configurationFileName": "C:\\Users\\XXXX\\AppData\\Roaming\\Code\\User\\import-sorter.json",
    "tsImportSorter.configuration.exclude": [
        "node_modules",
        "polyfills.ts",
        "polyfills.browser.ts"
    ]
{
  "maxLineLength": 120,
  "quoteMark": "simple",
  "tabSize": 4,
  "insertFinalNewline": false,
  "groupRules": [ 
	  {
		"regex": "^@angular/",
		"level": 10
	  },  
	  {
		"regex": "rxjs",
		"level": 11
	  },
	  {
		"regex": "^(?!(src|projects|lib)/)[a-z]",
		"level": 13
	  },
	  {
		"regex": "^@framework/",
		"level": 14
	  },
	  {
		"regex": "^[@]",
		"level": 15
	  },
	  {
		"regex": "^(src|lib|projects)/",
		"level": 20
	  },
	  {
		"regex": "^[.][.]",
		"level": 30
	  },
	  {
		"regex": "^(?!.*routing)[.]/",
		"level": 40
	  },
	  {
		"regex": "^[.]/",
		"level": 50
	  }
   ]
}

Installed VS Code extensions

cssho.vscode-svgviewer
deerawan.vscode-hasher
dozerg.tsimportsorter 
eamodio.gitlens
EditorConfig.EditorConfig
file-icons.file-icons
herrmannplatz.npm-dependency-links
jamesmaj.easy-icons
johnstoncode.svn-scm
LaurentTreguier.vscode-simple-icons
michelemelluso.gitignore
mike-co.import-sorter
ms-azuretools.vscode-docker
MS-CEINTL.vscode-language-pack-fr
ms-vscode-remote.remote-wsl
ms-vscode.vscode-typescript-tslint-plugin
msjsdiag.debugger-for-chrome
nepaul.editorconfiggenerator
obrejla.netbeans-light-theme
redhat.java
sasa.vscode-sass-format
Telerik.nativescript
traBpUkciP.vscode-npm-scripts
Tyriar.terminal-tabs
VisualStudioExptTeam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
xyz.local-history

Newline at end of file gets removed

Hi, I've got a file that has a bunch of exports at the end, followed by a blank line. Having a blank line at the end of a file is good practice and is something that the linter at my work requires. However, when I save the file, the blank line at the end disappears. It doesn't happen to most files, but it happens to this one because of the exports at the end.

There might already be a way to fix this on my end, but I don't know what it is.

".." path converted to "../"

Describe the bug
Import like this:
import BlurredBackground from '..';
Get transformed to this:
import BlurredBackground from '../';

But we are using eslint with import/no-useless-path-segments (https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-useless-path-segments.md) so every time I have a similar import and format them I have to manually remove the extra / to please eslint.

Maybe this could be an additional setting?

To Reproduce
Steps to reproduce the behavior:

  1. Add an import like import BlurredBackground from '..';
  2. Run the "Sort Imports/Export" command

Expected behavior
Import remains unchanged
import BlurredBackground from '..';

Actual behavior
Import path is updated with a trailing /
import BlurredBackground from '../';

OS (please complete the following information):

  • OS: Ubuntu
  • Version: 20.04

VS Code (please complete the following information):

  • Version: 1.46.1

Installed VS Code extensions

alexkrechik.cucumberautocomplete
CoenraadS.bracket-pair-colorizer
dbaeumer.vscode-eslint
dozerg.tsimportsorter
eamodio.gitlens
EditorConfig.EditorConfig
esbenp.prettier-vscode
jpoissonnier.vscode-styled-components
karunamurti.haml
mikestead.dotenv
Orta.vscode-jest
rebornix.ruby
skyran.js-jsx-snippets
vscode-icons-team.vscode-icons
wingrunr21.vscode-ruby

Type-only imports are converted to regular ones on sort

Describe the bug
TS 3.8 introduced the new feature of Type-Only imports which is really for optimizing.

Unfortunately, the extension is not able to preserve it and the keyword is removed during the sort.

To Reproduce

import type { Client } from 'urql'

Expected behavior
Import should keep type keyword.

Actual behavior

import { Client } from 'urql'

OS (please complete the following information):

  • OS: Windows
  • Version: 10

VS Code (please complete the following information):

  • Version: 1.45.0

I believe the fix should be fairly trivial and I am able to work on the PR.

Does not work .vue files

Describe the bug
I can't seem to use this on .vue files

To Reproduce

  1. Create a .vue single file component
  2. include a script block like <script lang="ts">
  3. Try to sort the imports by save or manual action

Expected behavior
It should sort imports in .vue files containing script blocks

Actual behavior
It does nothing

OS (please complete the following information):

  • OS: Windows
  • Version: 10

Option for case considerations when sorting imports

It is possible for bindings to have names with the same spelling apart from their cases. By default, the import sorter puts the lowercase one first:

import { a, A, b, B } from "/some/code/path";

I want an option to make uppercase imports come first:

import { A, a, B, b } from "/some/code/path";

Configure to only sort & remove unused (no other formatting)

Is your feature request related to a problem? Please describe.
Sort of, yes. I'm using Prettier and don't have custom Prettier config - using it out of the box. I have format-on-save turned on, and tsImportSorter is line breaking imports causing Prettier to complain about the line breaks.

Describe the solution you'd like
I'm using this extension for the sorting and removing of unused imports. If I could configure it to do just those two things and not format anything else, that would be perfect. I can't tell based on existing available settings if that's possible.

Support case like `import './style.css'`

Configuation:

    "tsImportSorter.configuration.groupRules": [
        "react",
        ".css$",
    ]

Source file:

import React from 'react';
import './index.css';

Expected:

import React from 'react';

import './index.css';

Actually:

import './index.css';

import React from 'react';

It's seems that the groupRules doesn't support the unnamed imports.

5.0.3 unable to load .eslintrc.js file

Describe the bug
First, thanks for your work on this project.

Version 5.0.2 is able to load the projects .eslintrc.js file just fine and applies the import sort order as expected. Starting with 5.0.3 the log files say they are unable to load the same file (though the location is accurate, and the file can be opened by clicking the path the logs say it is unable to open).

Specific error: [2020-12-28T18:14:39.380] [WARN] config.loadESLintConfig - Failed loading ESLint config: Cannot read config file: /Users/myuser/code/my-project/.eslintrc.js

Here is the log output from opening VSCode to saving a file:

[2020-12-28T18:14:16.552] [INFO] default - os: {
  arch: 'x64',
  platform: 'darwin',
  type: 'Darwin',
  release: '19.6.0',
  totalmem: 17179869184,
  freemem: 1896468480,
  EOL: '\n'
}
[2020-12-28T18:14:16.553] [INFO] default - vscode: { version: '1.52.1' }
[2020-12-28T18:14:16.554] [INFO] default - extensions: {
  builtIn: [
    'Windows Bat Language Basics ([email protected])',
    'Clojure Language Basics ([email protected])',
    'CoffeeScript Language Basics ([email protected])',
    'Configuration Editing ([email protected])',
    'C/C++ Language Basics ([email protected])',
    'C# Language Basics ([email protected])',
    'CSS Language Basics ([email protected])',
    'CSS Language Features ([email protected])',
    'Node Debug Auto-attach ([email protected])',
    'Server Ready Action ([email protected])',
    'Docker Language Basics ([email protected])',
    'Emmet ([email protected])',
    'Extension Authoring ([email protected])',
    'F# Language Basics ([email protected])',
    'Git ([email protected])',
    'Git UI ([email protected])',
    'GitHub ([email protected])',
    'GitHub Authentication ([email protected])',
    'Go Language Basics ([email protected])',
    'Groovy Language Basics ([email protected])',
    'Grunt support for VS Code ([email protected])',
    'Gulp support for VSCode ([email protected])',
    'Handlebars Language Basics ([email protected])',
    'HLSL Language Basics ([email protected])',
    'HTML Language Basics ([email protected])',
    'HTML Language Features ([email protected])',
    'Image Preview ([email protected])',
    'Ini Language Basics ([email protected])',
    'Jake support for VS Code ([email protected])',
    'Java Language Basics ([email protected])',
    'JavaScript Language Basics ([email protected])',
    'JSON Language Basics ([email protected])',
    'JSON Language Features ([email protected])',
    'Less Language Basics ([email protected])',
    'Log ([email protected])',
    'Lua Language Basics ([email protected])',
    'Make Language Basics ([email protected])',
    'Markdown Language Basics ([email protected])',
    'Markdown Language Features ([email protected])',
    'Merge Conflict ([email protected])',
    'Microsoft Account ([email protected])',
    'JavaScript Debugger Companion Extension ([email protected])',
    'Node Debug (legacy) ([email protected])',
    'Node Debug ([email protected])',
    'Reference Search View ([email protected])',
    '[email protected]',
    'NPM support for VS Code ([email protected])',
    'Objective-C Language Basics ([email protected])',
    'Perl Language Basics ([email protected])',
    'PHP Language Basics ([email protected])',
    'PHP Language Features ([email protected])',
    'Powershell Language Basics ([email protected])',
    'Pug Language Basics ([email protected])',
    'Python Language Basics ([email protected])',
    'R Language Basics ([email protected])',
    'Razor Language Basics ([email protected])',
    'Ruby Language Basics ([email protected])',
    'Rust Language Basics ([email protected])',
    'SCSS Language Basics ([email protected])',
    'Search Result ([email protected])',
    'Shaderlab Language Basics ([email protected])',
    'Shell Script Language Basics ([email protected])',
    'SQL Language Basics ([email protected])',
    'Swift Language Basics ([email protected])',
    'Abyss Theme ([email protected])',
    'Default Themes ([email protected])',
    'Kimbie Dark Theme ([email protected])',
    'Monokai Theme ([email protected])',
    'Monokai Dimmed Theme ([email protected])',
    'Quiet Light Theme ([email protected])',
    'Red Theme ([email protected])',
    'Seti File Icon Theme ([email protected])',
    'Solarized Dark Theme ([email protected])',
    'Solarized Light Theme ([email protected])',
    'Tomorrow Night Blue Theme ([email protected])',
    'TypeScript Language Basics ([email protected])',
    'TypeScript and JavaScript Language Features ([email protected])',
    'Visual Basic Language Basics ([email protected])',
    'XML Language Basics ([email protected])',
    'YAML Language Basics ([email protected])'
  ],
  installed: [
    'ESLint ([email protected])',
    'JS/TS Import/Export Sorter ([email protected])',
    'HTML CSS Support ([email protected])',
    'Prettier - Code formatter ([email protected])',
    'Prettify JSON ([email protected])',
    'MDX ([email protected])',
    'stylelint ([email protected])',
    'Sort JS object keys ([email protected])'
  ]
}
[2020-12-28T18:14:39.350] [INFO] vscode.resolveConfig - Start resolving configs for fileName: /Users/myuser/code/my-project/src/app-dashboard/components/header/dashboard-header.tsx, languageId: typescriptreact
[2020-12-28T18:14:39.352] [DEBUG] config.loadVscConfig - Finish loading VSC config
[2020-12-28T18:14:39.352] [DEBUG] config.loadImportSorterConfig - Load Prettier/EditorConfig config.
[2020-12-28T18:14:39.352] [INFO] config.loadPretConfig - Prettier API version:  2.2.1
[2020-12-28T18:14:39.363] [DEBUG] config.loadImportSorterConfig - Load import-sorter config from import-sorter.json
[2020-12-28T18:14:39.364] [DEBUG] config.loadImportSorterConfig - Load package.json config.
[2020-12-28T18:14:39.364] [DEBUG] config.loadESLintConfig - Start loading ESLint config for filePath: /Users/myuser/code/my-project/src/app-dashboard/components/header/dashboard-header.tsx
[2020-12-28T18:14:39.364] [INFO] config.loadESLintConfig - ESLint API version: 7.16.0
[2020-12-28T18:14:39.380] [WARN] config.loadESLintConfig - Failed loading ESLint config: Cannot read config file: /Users/myuser/code/my-project/.eslintrc.js
Error: Cannot find module '/Users/myuser/code/my-project/.eslintrc.js'
[2020-12-28T18:14:39.381] [DEBUG] config.loadTsConfig - Find TS config for fileName: /Users/myuser/code/my-project/src/app-dashboard/components/header/dashboard-header.tsx
[2020-12-28T18:14:39.381] [DEBUG] config.loadTsConfig - Load TS config for fileName: /Users/myuser/code/my-project/src/app-dashboard/components/header/dashboard-header.tsx
[2020-12-28T18:14:39.388] [DEBUG] config.loadTsConfig - Parse TS config for path: /Users/myuser/code/my-project
[2020-12-28T18:14:39.407] [DEBUG] vscode.resolveConfig - Finish resolving configs.
[2020-12-28T18:14:39.407] [DEBUG] formatDocument - Start formatting fileName: /Users/myuser/code/my-project/src/app-dashboard/components/header/dashboard-header.tsx
[2020-12-28T18:14:39.408] [INFO] parser.formatSource - config: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'onSave',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  sortImportsBy: 'paths',
  groupRules: [ '^react(-dom)?$', '^@angular/', '^vue$', {}, '^[@]', '^[.]' ],
  sortRules: { paths: [ '_', 'aA' ], names: [ '_', 'aA' ] },
  keepUnused: [],
  emptyLinesBetweenGroups: 1,
  emptyLinesAfterAllImports: 1,
  removeLastSlashInPath: false,
  removeLastIndexInPath: false,
  maxBindingNamesPerLine: 1,
  maxDefaultAndBindingNamesPerLine: 2,
  maxExportNamesPerLine: 0,
  maxNamesPerWrappedLine: 1,
  development: { enableDebug: true },
  insertFinalNewline: true,
  maxLineLength: 100,
  tabType: 'space',
  tabSize: 2,
  hasSemicolon: true,
  quoteMark: 'single',
  trailingComma: 'multiLine',
  bracketSpacing: true,
  eol: 'LF'
}
[2020-12-28T18:14:39.408] [INFO] parser.formatSource - eslintConfig: undefined
[2020-12-28T18:14:39.408] [INFO] parser.formatSource - tsCompilerOptions: {
  allowJs: false,
  allowSyntheticDefaultImports: true,
  allowUnreachableCode: false,
  baseUrl: '/Users/myuser/code/my-project/src',
  experimentalDecorators: true,
  jsx: 1,
  lib: [ 'lib.es2020.d.ts', 'lib.dom.d.ts' ],
  module: 6,
  moduleResolution: 2,
  noImplicitAny: false,
  noUnusedLocals: true,
  noUnusedParameters: true,
  paths: { '@root/*': [ '../*' ], '@src/*': [ './*' ] },
  resolveJsonModule: true,
  skipLibCheck: true,
  sourceMap: true,
  strictBindCallApply: true,
  strictNullChecks: false,
  target: 7,
  pathsBasePath: '/Users/myuser/code/my-project',
  configFilePath: undefined
}
[2020-12-28T18:14:39.408] [DEBUG] parser.formatSource - Translated ESLint config to newConfig: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'onSave',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  sortImportsBy: 'paths',
  groupRules: [ '^react(-dom)?$', '^@angular/', '^vue$', {}, '^[@]', '^[.]' ],
  sortRules: { paths: [ '_', 'aA' ], names: [ '_', 'aA' ] },
  keepUnused: [],
  emptyLinesBetweenGroups: 1,
  emptyLinesAfterAllImports: 1,
  removeLastSlashInPath: false,
  removeLastIndexInPath: false,
  maxBindingNamesPerLine: 1,
  maxDefaultAndBindingNamesPerLine: 2,
  maxExportNamesPerLine: 0,
  maxNamesPerWrappedLine: 1,
  development: { enableDebug: true },
  insertFinalNewline: true,
  maxLineLength: 100,
  tabType: 'space',
  tabSize: 2,
  hasSemicolon: true,
  quoteMark: 'single',
  trailingComma: 'multiLine',
  bracketSpacing: true,
  eol: 'LF'
}
[2020-12-28T18:14:39.408] [DEBUG] parser.formatSource - ESLint config processed data: undefined
[2020-12-28T18:14:39.422] [DEBUG] parser.formatSource - composeConfig: {
  maxLength: 100,
  maxWords: {
    withoutDefault: 1,
    withDefault: 2,
    wrapped: 1,
    exported: 9007199254740991
  },
  groupSep: '\n\n',
  groupEnd: 2,
  tab: '  ',
  quote: [Function],
  comma: ',',
  semi: ';',
  bracket: [Function],
  lastNewLine: true,
  nl: '\n'
}
[2020-12-28T18:14:39.486] [INFO] formatDocument - Finished format.

Add a groupRule to default options for `node:` prefixed builtin modules

Is your feature request related to a problem? Please describe.

The new node: prefix for module specifiers for builtin / core modules (currently in v16, but will be backported) is not specified in the groupRules default configuration, which means that it will be sorted inline around "n".

Describe the solution you'd like

Add a group rule at the beginning for module specifiers starting with node:

 "tsImportSorter.configuration.groupRules": [
+  "^node:",
   "^react(-dom)?$",
   "^@angular/",
   "^vue$",
   {},
   "^[@]",
   "^[.]"
 ],

Describe alternatives you've considered

Adding the group rule at some other position in the list

Support for maxLineLength setting in vscode-settings

I've seen it recommended a few places here to use the maxLineLength: 0 setting when running into issues with prettier.

Would it be possible to set this in vscode settings as opposed to the importSorter config?

Doesn't respect .eslintrc.json max-length

Lines above 80 characters are wrapped even if there's a max-len rule under "rules" in .estlintrc:
"max-len": [ "error", { "code": 200 } ],

Plugin debug output gives:

[2021-03-30T11:21:14.163] [DEBUG] format-imports.formatSource - composeConfig: {
maxLength: 80, <========== There it is :)
wrap: {
withoutDefault: 9007199254740991,
withDefault: 9007199254740991,
perLine: 9007199254740991,
exported: 9007199254740991,
parts: true
},

Other than that, it seems like a fantastic plugin! And since I'm writing, please add something like "if number of imports are less than 4 then don't apply emptyLinesBetweenGroups".

/T

Document how to configure keepUnused for any path

For now the default behaviour is removing all unused imports except of explicitly excluded.

The idea is to add simple option, which allow to enable "keep all" behaviour easy.

Possible variants:

keepUnused: true // IMHO preferable
keepUnused: "all"
keepUnused: ["all"]
keepUnused: "*"
keepUnused: ["*"]

Current workaround is usage of:
"keepUnused": [{ "path": "^" }]
(or "keepUnused": [".*"] as was advised by plugin author)

Exception: Cannot find module '@umijs/fabric'

Code snippet triggering the exception

// INSERT CODE HERE

Logs
(Please select ALL logs in "JS/TS Import/Export Sorter" Output window and copy/paste here)

INSERT LOG HERE

Edit:

Exception: Cannot find module '@umijs/fabric'
Require stack:- 
/Users/wangqi/ecs/myapp/.prettierrc.js-
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/node_modules/prettier/third-party.js- 
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/node_modules/prettier/index.js- 
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/out/config/prettier.js- 
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/out/config/importSorter.js- 
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/out/config/index.js- 
/Users/wangqi/.vscode/extensions/dozerg.tsimportsorter-3.0.4/out/extension.js- 
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js- 
/Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js- 
/Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js

Groups with similar starting regex doesn't group correctly

If you have custom group rules and both rules have the same start, it will default to the first group in the rules.
Expected behavior
A clear and concise description of what you expected to happen.

Actual behavior

Given:

import { Component } from '@angular/core';
import { MyService } from '@mymodule/common';

import { SomethingComponent } from './local-component'

will group to:

import { Component } from '@angular/core';
import { MyService } from '@mymodule/common';

import { SomethingComponent } from './local-component'

but I would expect:

import { Component } from '@angular/core';

import { MyService } from '@mymodule/common';

import { SomethingComponent } from './local-component'

OS (please complete the following information):
VS Code (please complete the following information):

Version: 1.53.0-insider
Commit: 7b0cfdd04ad530a9c8d782c618afd79290be3d64
Date: 2021-01-27T08:57:30.935Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 19.6.0

VS Code settings:

  "tsImportSorter.configuration.groupRules": ["^[@]", "^@mymodule/", {}, "^[.]"],
  "tsImportSorter.configuration.maxBindingNamesPerLine": 0,
  "tsImportSorter.configuration.maxDefaultAndBindingNamesPerLine": 0

Since upgrading to 1.2.11 constant "cannot format" errors and unused imports not removed

My config:

{
  "groupRules": [{
      "regex": "^react$"
    },
    {
      "regex": "^(prop-types|redux|ramda|i18n|memoize|clsx|color)"
    },
    {
      "regex": "^(@material-ui|react-select|react-beautiful-dnd|downshift|victory)"
    },
    {},
    {
      "regex": "^~"
    },
    {
      "regex": "^[.]"
    }
  ],
  "hasSemicolon": false,
  "maximumBindingNamesPerLine": 3,
  "maximumDefaultAndBindingNamesPerLine": 4,
  "maximumLineLength": 100,
  "trailingComma": "multiLine"
}

Imports will reorder properly if out of order, but I see the Extension 'JS/TS Import Sorter' cannot format 'src/path/to/file.js' in the VS Code status bar and unused imports are not removed.

Exception: Cannot read property 'path' of undefined

Code snippet triggering the exception
Unclear, just regular unsorted TS imports

Logs

[2020-05-12T16:19:26.132] [INFO] default - os: {
  arch: 'x64',
  platform: 'darwin',
  type: 'Darwin',
  release: '19.4.0',
  totalmem: 17179869184,
  freemem: 1482948608,
  EOL: '\n'
}
[2020-05-12T16:19:26.133] [INFO] default - vscode: { version: '1.45.0' }
[2020-05-12T16:19:26.134] [INFO] default - extensions: [
  {
    displayName: 'Windows Bat Language Basics',
    id: 'vscode.bat',
    version: '1.0.0'
  },
  {
    displayName: 'Clojure Language Basics',
    id: 'vscode.clojure',
    version: '1.0.0'
  },
  {
    displayName: 'CoffeeScript Language Basics',
    id: 'vscode.coffeescript',
    version: '1.0.0'
  },
  {
    displayName: 'Configuration Editing',
    id: 'vscode.configuration-editing',
    version: '1.0.0'
  },
  {
    displayName: 'C/C++ Language Basics',
    id: 'vscode.cpp',
    version: '1.0.0'
  },
  {
    displayName: 'C# Language Basics',
    id: 'vscode.csharp',
    version: '1.0.0'
  },
  {
    displayName: 'CSS Language Basics',
    id: 'vscode.css',
    version: '1.0.0'
  },
  {
    displayName: 'CSS Language Features',
    id: 'vscode.css-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Node Debug Auto-attach',
    id: 'vscode.debug-auto-launch',
    version: '1.0.0'
  },
  {
    displayName: 'Server Ready Action',
    id: 'vscode.debug-server-ready',
    version: '1.0.0'
  },
  {
    displayName: 'Docker Language Basics',
    id: 'vscode.docker',
    version: '1.0.0'
  },
  { displayName: 'Emmet', id: 'vscode.emmet', version: '1.0.0' },
  {
    displayName: 'Extension Authoring',
    id: 'vscode.extension-editing',
    version: '1.0.0'
  },
  {
    displayName: 'F# Language Basics',
    id: 'vscode.fsharp',
    version: '1.0.0'
  },
  { displayName: 'Git', id: 'vscode.git', version: '1.0.0' },
  { displayName: 'Git UI', id: 'vscode.git-ui', version: '1.0.0' },
  {
    displayName: 'GitHub Authentication',
    id: 'vscode.github-authentication',
    version: '0.0.1'
  },
  {
    displayName: 'Go Language Basics',
    id: 'vscode.go',
    version: '1.0.0'
  },
  {
    displayName: 'Groovy Language Basics',
    id: 'vscode.groovy',
    version: '1.0.0'
  },
  {
    displayName: 'Grunt support for VS Code',
    id: 'vscode.grunt',
    version: '1.0.0'
  },
  {
    displayName: 'Gulp support for VSCode',
    id: 'vscode.gulp',
    version: '1.0.0'
  },
  {
    displayName: 'Handlebars Language Basics',
    id: 'vscode.handlebars',
    version: '1.0.0'
  },
  {
    displayName: 'HLSL Language Basics',
    id: 'vscode.hlsl',
    version: '1.0.0'
  },
  {
    displayName: 'HTML Language Basics',
    id: 'vscode.html',
    version: '1.0.0'
  },
  {
    displayName: 'HTML Language Features',
    id: 'vscode.html-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Image Preview',
    id: 'vscode.image-preview',
    version: '1.0.0'
  },
  {
    displayName: 'Ini Language Basics',
    id: 'vscode.ini',
    version: '1.0.0'
  },
  {
    displayName: 'Jake support for VS Code',
    id: 'vscode.jake',
    version: '1.0.0'
  },
  {
    displayName: 'Java Language Basics',
    id: 'vscode.java',
    version: '1.0.0'
  },
  {
    displayName: 'JavaScript Language Basics',
    id: 'vscode.javascript',
    version: '1.0.0'
  },
  {
    displayName: 'JSON Language Basics',
    id: 'vscode.json',
    version: '1.0.0'
  },
  {
    displayName: 'JSON Language Features',
    id: 'vscode.json-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Less Language Basics',
    id: 'vscode.less',
    version: '1.0.0'
  },
  { displayName: 'Log', id: 'vscode.log', version: '1.0.0' },
  {
    displayName: 'Lua Language Basics',
    id: 'vscode.lua',
    version: '1.0.0'
  },
  {
    displayName: 'Make Language Basics',
    id: 'vscode.make',
    version: '1.0.0'
  },
  {
    displayName: 'Markdown Language Basics',
    id: 'vscode.markdown',
    version: '1.0.0'
  },
  {
    displayName: 'Markdown Language Features',
    id: 'vscode.markdown-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Merge Conflict',
    id: 'vscode.merge-conflict',
    version: '1.0.0'
  },
  {
    displayName: 'JavaScript Debugger Companion Extension',
    id: 'ms-vscode.js-debug-companion',
    version: '1.0.0'
  },
  {
    displayName: 'Node Debug (legacy)',
    id: 'ms-vscode.node-debug',
    version: '1.44.5'
  },
  {
    displayName: 'Node Debug',
    id: 'ms-vscode.node-debug2',
    version: '1.42.2'
  },
  {
    displayName: 'Reference Search View',
    id: 'ms-vscode.references-view',
    version: '0.0.51'
  },
  {
    displayName: 'NPM support for VS Code',
    id: 'vscode.npm',
    version: '1.0.1'
  },
  {
    displayName: 'Objective-C Language Basics',
    id: 'vscode.objective-c',
    version: '1.0.0'
  },
  {
    displayName: 'Perl Language Basics',
    id: 'vscode.perl',
    version: '1.0.0'
  },
  {
    displayName: 'PHP Language Basics',
    id: 'vscode.php',
    version: '1.0.0'
  },
  {
    displayName: 'PHP Language Features',
    id: 'vscode.php-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Powershell Language Basics',
    id: 'vscode.powershell',
    version: '1.0.0'
  },
  {
    displayName: 'Pug Language Basics',
    id: 'vscode.pug',
    version: '1.0.0'
  },
  {
    displayName: 'Python Language Basics',
    id: 'vscode.python',
    version: '1.0.0'
  },
  {
    displayName: 'R Language Basics',
    id: 'vscode.r',
    version: '1.0.0'
  },
  {
    displayName: 'Razor Language Basics',
    id: 'vscode.razor',
    version: '1.0.0'
  },
  {
    displayName: 'Ruby Language Basics',
    id: 'vscode.ruby',
    version: '1.0.0'
  },
  {
    displayName: 'Rust Language Basics',
    id: 'vscode.rust',
    version: '1.0.0'
  },
  {
    displayName: 'SCSS Language Basics',
    id: 'vscode.scss',
    version: '1.0.0'
  },
  {
    displayName: 'Search Result',
    id: 'vscode.search-result',
    version: '1.0.0'
  },
  {
    displayName: 'Shaderlab Language Basics',
    id: 'vscode.shaderlab',
    version: '1.0.0'
  },
  {
    displayName: 'Shell Script Language Basics',
    id: 'vscode.shellscript',
    version: '1.0.0'
  },
  {
    displayName: 'SQL Language Basics',
    id: 'vscode.sql',
    version: '1.0.0'
  },
  {
    displayName: 'Swift Language Basics',
    id: 'vscode.swift',
    version: '1.0.0'
  },
  {
    displayName: 'Abyss Theme',
    id: 'vscode.theme-abyss',
    version: '1.0.0'
  },
  {
    displayName: 'Default Themes',
    id: 'vscode.theme-defaults',
    version: '1.0.0'
  },
  {
    displayName: 'Kimbie Dark Theme',
    id: 'vscode.theme-kimbie-dark',
    version: '1.0.0'
  },
  {
    displayName: 'Monokai Theme',
    id: 'vscode.theme-monokai',
    version: '1.0.0'
  },
  {
    displayName: 'Monokai Dimmed Theme',
    id: 'vscode.theme-monokai-dimmed',
    version: '1.0.0'
  },
  {
    displayName: 'Quiet Light Theme',
    id: 'vscode.theme-quietlight',
    version: '1.0.0'
  },
  {
    displayName: 'Red Theme',
    id: 'vscode.theme-red',
    version: '1.0.0'
  },
  {
    displayName: 'Seti File Icon Theme',
    id: 'vscode.vscode-theme-seti',
    version: '1.0.0'
  },
  {
    displayName: 'Solarized Dark Theme',
    id: 'vscode.theme-solarized-dark',
    version: '1.0.0'
  },
  {
    displayName: 'Solarized Light Theme',
    id: 'vscode.theme-solarized-light',
    version: '1.0.0'
  },
  {
    displayName: 'Tomorrow Night Blue Theme',
    id: 'vscode.theme-tomorrow-night-blue',
    version: '1.0.0'
  },
  {
    displayName: 'TypeScript Language Basics',
    id: 'vscode.typescript',
    version: '1.0.0'
  },
  {
    displayName: 'TypeScript and JavaScript Language Features',
    id: 'vscode.typescript-language-features',
    version: '1.0.0'
  },
  {
    displayName: 'Visual Basic Language Basics',
    id: 'vscode.vb',
    version: '1.0.0'
  },
  {
    displayName: 'Microsoft Account',
    id: 'vscode.vscode-account',
    version: '0.0.1'
  },
  {
    displayName: 'XML Language Basics',
    id: 'vscode.xml',
    version: '1.0.0'
  },
  {
    displayName: 'YAML Language Basics',
    id: 'vscode.yaml',
    version: '1.0.0'
  },
  {
    displayName: 'Atom One Dark Theme',
    id: 'akamud.vscode-theme-onedark',
    version: '2.2.1'
  },
  {
    displayName: 'JS/TS Import/Export Sorter',
    id: 'dozerg.tsimportsorter',
    version: '2.0.6'
  },
  {
    displayName: 'GitLens — Git supercharged',
    id: 'eamodio.gitlens',
    version: '10.2.1'
  },
  {
    displayName: 'EditorConfig for VS Code',
    id: 'EditorConfig.EditorConfig',
    version: '0.14.5'
  },
  {
    displayName: 'Prettier - Code formatter',
    id: 'esbenp.prettier-vscode',
    version: '4.6.0'
  },
  {
    displayName: 'GitHub Pull Requests and Issues',
    id: 'GitHub.vscode-pull-request-github',
    version: '0.16.0'
  },
  {
    displayName: 'Winter is Coming Theme',
    id: 'johnpapa.winteriscoming',
    version: '1.4.3'
  },
  {
    displayName: 'GitHub',
    id: 'KnisterPeter.vscode-github',
    version: '0.30.3'
  },
  {
    displayName: 'TSLint',
    id: 'ms-vscode.vscode-typescript-tslint-plugin',
    version: '1.2.3'
  },
  {
    displayName: 'Debugger for Chrome',
    id: 'msjsdiag.debugger-for-chrome',
    version: '4.12.6'
  },
  {
    displayName: 'stylelint',
    id: 'stylelint.vscode-stylelint',
    version: '0.84.0'
  },
  {
    displayName: 'open in browser',
    id: 'techer.open-in-browser',
    version: '2.0.0'
  },
  {
    displayName: 'TSLint Snippets',
    id: 'zuoez02.tslint-snippets',
    version: '1.1.0'
  }
]
[2020-05-12T16:20:48.597] [INFO] formatDocument - config: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'off',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  groupRules: [ '^[A-Za-z].*$', '^@.*$', '^\\.' ],
  sortRules: { paths: [ '_', 'aA' ], names: [ 'aA', '_' ] },
  maxBindingNamesPerLine: 1,
  maxDefaultAndBindingNamesPerLine: 2,
  maxExportNamesPerLine: 0,
  maxNamesPerWrappedLine: 1,
  insertFinalNewline: true,
  eof: '\n',
  maxLineLength: 80,
  tabType: 'space',
  tabSize: 2,
  hasSemicolon: true,
  quoteMark: 'single',
  trailingComma: 'none',
  bracketSpacing: true,
  eol: 'LF',
  force: true
}
[2020-05-12T16:20:48.598] [INFO] formatDocument - tsCompilerOptions: {
  sourceMap: true,
  declaration: false,
  moduleResolution: 2,
  emitDecoratorMetadata: true,
  experimentalDecorators: true,
  importHelpers: true,
  noImplicitAny: true,
  noUnusedLocals: true,
  noUnusedParameters: true,
  target: 2,
  module: 99,
  typeRoots: [ '/Users/pete.burkindine/git/ccxp/ccxp-client/node_modules/@types' ],
  lib: [ 'lib.es2020.d.ts', 'lib.dom.d.ts' ],
  skipLibCheck: true,
  skipDefaultLibCheck: true,
  baseUrl: '/Users/pete.burkindine/git/ccxp/ccxp-client',
  paths: {
    '@ccxp/ccxp-data': [ 'node_modules/@ccxp/ccxp-data/lib-client/client/' ],
    '@ccxp-client/shared': [ 'libs/shared/src/index.ts' ],
    '@ccxp-client-testing/shared': [ 'libs/shared/src/testing.ts' ],
    '@ccxp-client/ccxp-material': [ 'libs/ccxp-material/src/index.ts' ],
    '@ccxp-client-testing/ccxp-material': [ 'libs/ccxp-material/src/testing.ts' ],
    '@ccxp-client/core': [ 'libs/core/src/index.ts' ],
    '@ccxp-client-testing/core': [ 'libs/core/src/testing.ts' ],
    '@ccxp-client/features/inspections': [ 'libs/features/inspections/src/index.ts' ],
    '@ccxp-client/features/provider-compare': [ 'libs/features/provider-compare/src/index.ts' ],
    '@ccxp-client/features/provider-details': [ 'libs/features/provider-details/src/index.ts' ],
    '@ccxp-client/features/provider-measures': [ 'libs/features/provider-measures/src/index.ts' ],
    '@ccxp-client-testing/features/provider-measures': [ 'libs/features/provider-measures/src/testing.ts' ],
    '@ccxp-client/features/provider-search': [ 'libs/features/provider-search/src/index.ts' ],
    '@ccxp-client/features/resources': [ 'libs/features/resources/src/index.ts' ],
    '@ccxp-client/new-relic': [ 'libs/new-relic/src/index.ts' ],
    '@ccxp-client-testing/new-relic': [ 'libs/new-relic/src/testing.ts' ],
    '@ccxp-client/maps': [ 'libs/maps/src/index.ts' ],
    '@ccxp-client-testing/maps': [ 'libs/maps/src/testing.ts' ],
    '@ccxp-client/tealium': [ 'libs/tealium/src/index.ts' ],
    '@ccxp-client-testing/tealium': [ 'libs/tealium/src/testing.ts' ]
  },
  types: [ 'node', 'jest' ],
  configFilePath: undefined
}
[2020-05-12T16:20:48.598] [INFO] formatDocument - fileName: /Users/pete.burkindine/git/ccxp/ccxp-client/libs/features/provider-search/src/lib/components/results/filters/nursing-home-other-rating/nursing-home-other-rating.helper.service.ts
[2020-05-12T16:20:48.606] [INFO] parser.formatSource - composeConfig: {
  maxLength: 80,
  maxWords: {
    withoutDefault: 1,
    withDefault: 2,
    wrapped: 1,
    exported: 9007199254740991
  },
  tab: '  ',
  quote: [Function],
  comma: '',
  semi: ';',
  bracket: [Function],
  lastNewLine: true,
  nl: '\n'
}
[2020-05-12T16:20:48.652] [ERROR] formatDocument - Found exception: [TypeError: Cannot read property 'path' of undefined
	at addReferencedFilesToTypeDirective (Project/node_modules/typescript/lib/typescript.js:66418:46)
	at Project/node_modules/typescript/lib/typescript.js:66253:21
	at Map.forEach (<anonymous>)
	at createResolver (Project/node_modules/typescript/lib/typescript.js:66246:49)
	at Object.createTypeChecker (Project/node_modules/typescript/lib/typescript.js:34393:28)
	at getDiagnosticsProducingTypeChecker (Project/node_modules/typescript/lib/typescript.js:98560:93)
	at Project/node_modules/typescript/lib/typescript.js:98695:35
	at runWithCancellationToken (Project/node_modules/typescript/lib/typescript.js:98665:24)
	at getBindAndCheckDiagnosticsForFileNoCache (Project/node_modules/typescript/lib/typescript.js:98691:20)
	at getAndCacheDiagnostics (Project/node_modules/typescript/lib/typescript.js:98956:26)
	at getBindAndCheckDiagnosticsForFile (Project/node_modules/typescript/lib/typescript.js:98688:20)
	at getSemanticDiagnosticsForFile (Project/node_modules/typescript/lib/typescript.js:98685:35)
	at getDiagnosticsHelper (Project/node_modules/typescript/lib/typescript.js:98604:24)
	at Object.getSemanticDiagnostics (Project/node_modules/typescript/lib/typescript.js:98617:20)
	at Object.getUnusedIds (Project/out/parser/unused.js:23:10)
	at unusedIds (Project/out/main/index.js:27:38)
	at formatImports (Project/out/main/index.js:40:52)
	at Object.formatSource [as default] (Project/out/main/index.js:29:18)
	at formatDocument (Project/out/extension.js:90:39)
	at sortImportsByCommand (Project/out/extension.js:58:27)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:897:216
	at t.ExtHostTextEditor.edit (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:584:588)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:897:205
	at e._executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:627:894)
	at e.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:628:295)
	at e._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:788:757)
	at e._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:788:449)
	at e._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:787:120)
	at e._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:785:970)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:784:213
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:232:615)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:957:179
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:232:615)
	at t.PersistentProtocol._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:237:17)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:234:155
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at p.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:230:129)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:229:483
	at Socket.t (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:238:565)
	at Socket.emit (events.js:203:13)
	at addChunk (_stream_readable.js:295:12)
	at readableAddChunk (_stream_readable.js:276:11)
	at Socket.Readable.push (_stream_readable.js:210:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)]
[2020-05-12T16:22:14.638] [INFO] formatDocument - config: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'off',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  groupRules: [ '^[A-Za-z].*$', '^@.*$', '^\\.' ],
  sortRules: { paths: [ '_', 'aA' ], names: [ 'aA', '_' ] },
  maxBindingNamesPerLine: 1,
  maxDefaultAndBindingNamesPerLine: 2,
  maxExportNamesPerLine: 0,
  maxNamesPerWrappedLine: 1,
  insertFinalNewline: true,
  eof: '\n',
  maxLineLength: 80,
  tabType: 'space',
  tabSize: 2,
  hasSemicolon: true,
  quoteMark: 'single',
  trailingComma: 'none',
  bracketSpacing: true,
  eol: 'LF',
  force: true
}
[2020-05-12T16:22:14.640] [INFO] formatDocument - tsCompilerOptions: {
  sourceMap: true,
  declaration: false,
  moduleResolution: 2,
  emitDecoratorMetadata: true,
  experimentalDecorators: true,
  importHelpers: true,
  noImplicitAny: true,
  noUnusedLocals: true,
  noUnusedParameters: true,
  target: 2,
  module: 99,
  typeRoots: [ '/Users/pete.burkindine/git/ccxp/ccxp-client/node_modules/@types' ],
  lib: [ 'lib.es2020.d.ts', 'lib.dom.d.ts' ],
  skipLibCheck: true,
  skipDefaultLibCheck: true,
  baseUrl: '/Users/pete.burkindine/git/ccxp/ccxp-client',
  paths: {
    '@ccxp/ccxp-data': [ 'node_modules/@ccxp/ccxp-data/lib-client/client/' ],
    '@ccxp-client/shared': [ 'libs/shared/src/index.ts' ],
    '@ccxp-client-testing/shared': [ 'libs/shared/src/testing.ts' ],
    '@ccxp-client/ccxp-material': [ 'libs/ccxp-material/src/index.ts' ],
    '@ccxp-client-testing/ccxp-material': [ 'libs/ccxp-material/src/testing.ts' ],
    '@ccxp-client/core': [ 'libs/core/src/index.ts' ],
    '@ccxp-client-testing/core': [ 'libs/core/src/testing.ts' ],
    '@ccxp-client/features/inspections': [ 'libs/features/inspections/src/index.ts' ],
    '@ccxp-client/features/provider-compare': [ 'libs/features/provider-compare/src/index.ts' ],
    '@ccxp-client/features/provider-details': [ 'libs/features/provider-details/src/index.ts' ],
    '@ccxp-client/features/provider-measures': [ 'libs/features/provider-measures/src/index.ts' ],
    '@ccxp-client-testing/features/provider-measures': [ 'libs/features/provider-measures/src/testing.ts' ],
    '@ccxp-client/features/provider-search': [ 'libs/features/provider-search/src/index.ts' ],
    '@ccxp-client/features/resources': [ 'libs/features/resources/src/index.ts' ],
    '@ccxp-client/new-relic': [ 'libs/new-relic/src/index.ts' ],
    '@ccxp-client-testing/new-relic': [ 'libs/new-relic/src/testing.ts' ],
    '@ccxp-client/maps': [ 'libs/maps/src/index.ts' ],
    '@ccxp-client-testing/maps': [ 'libs/maps/src/testing.ts' ],
    '@ccxp-client/tealium': [ 'libs/tealium/src/index.ts' ],
    '@ccxp-client-testing/tealium': [ 'libs/tealium/src/testing.ts' ]
  },
  types: [ 'node', 'jest' ],
  configFilePath: undefined
}
[2020-05-12T16:22:14.641] [INFO] formatDocument - fileName: /Users/pete.burkindine/git/ccxp/ccxp-client/libs/features/provider-search/src/lib/components/results/filters/nursing-home-other-rating/nursing-home-other-rating.component.ts
[2020-05-12T16:22:14.659] [INFO] parser.formatSource - composeConfig: {
  maxLength: 80,
  maxWords: {
    withoutDefault: 1,
    withDefault: 2,
    wrapped: 1,
    exported: 9007199254740991
  },
  tab: '  ',
  quote: [Function],
  comma: '',
  semi: ';',
  bracket: [Function],
  lastNewLine: true,
  nl: '\n'
}
[2020-05-12T16:22:14.751] [ERROR] formatDocument - Found exception: [TypeError: Cannot read property 'path' of undefined
	at addReferencedFilesToTypeDirective (Project/node_modules/typescript/lib/typescript.js:66418:46)
	at Project/node_modules/typescript/lib/typescript.js:66253:21
	at Map.forEach (<anonymous>)
	at createResolver (Project/node_modules/typescript/lib/typescript.js:66246:49)
	at Object.createTypeChecker (Project/node_modules/typescript/lib/typescript.js:34393:28)
	at getDiagnosticsProducingTypeChecker (Project/node_modules/typescript/lib/typescript.js:98560:93)
	at Project/node_modules/typescript/lib/typescript.js:98695:35
	at runWithCancellationToken (Project/node_modules/typescript/lib/typescript.js:98665:24)
	at getBindAndCheckDiagnosticsForFileNoCache (Project/node_modules/typescript/lib/typescript.js:98691:20)
	at getAndCacheDiagnostics (Project/node_modules/typescript/lib/typescript.js:98956:26)
	at getBindAndCheckDiagnosticsForFile (Project/node_modules/typescript/lib/typescript.js:98688:20)
	at getSemanticDiagnosticsForFile (Project/node_modules/typescript/lib/typescript.js:98685:35)
	at getDiagnosticsHelper (Project/node_modules/typescript/lib/typescript.js:98604:24)
	at Object.getSemanticDiagnostics (Project/node_modules/typescript/lib/typescript.js:98617:20)
	at Object.getUnusedIds (Project/out/parser/unused.js:23:10)
	at unusedIds (Project/out/main/index.js:27:38)
	at formatImports (Project/out/main/index.js:40:52)
	at Object.formatSource [as default] (Project/out/main/index.js:29:18)
	at formatDocument (Project/out/extension.js:90:39)
	at sortImportsByCommand (Project/out/extension.js:58:27)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:897:216
	at t.ExtHostTextEditor.edit (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:584:588)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:897:205
	at e._executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:627:894)
	at e.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:628:295)
	at e._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:788:757)
	at e._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:788:449)
	at e._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:787:120)
	at e._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:785:970)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:784:213
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:232:615)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:957:179
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:232:615)
	at t.PersistentProtocol._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:237:17)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:234:155
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:67)
	at p.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:230:129)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:229:483
	at Socket.t (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:238:565)
	at Socket.emit (events.js:203:13)
	at addChunk (_stream_readable.js:295:12)
	at readableAddChunk (_stream_readable.js:276:11)
	at Socket.Readable.push (_stream_readable.js:210:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)]

Doesn't respect eslint indent settings

Describe the bug
The @typescript-eslint/indent rule appears to be ignored, as when reformatting imports to multi-line form, it is only using 2 spaces, not 4 spaces.

By way of example: the following import line
import { parse, stringify } from 'teleport-javascript';
gets reformatted as

import {
  parse,
  stringify,
} from 'teleport-javascript';

when it should be

import {
    parse,
    stringify,
} from 'teleport-javascript';

To Reproduce
Steps to reproduce the behavior:

  1. have eslint indentation set to 4 spaces rather than 2
  2. reformat imports when it would switch to multi-line styling

Expected behavior
Either it should respect eslint spacing (which auto-fixes on save) or it should use the correct spacing. Or there should be a separate option to configure indents for this plugin.

Actual behavior
Eslint auto-fix and import sorter fight about spacing. Import sorter wins, meaning you can't use reoder-imports-on-save if you're using indents of 4.

Screenshots
N/A

OS (please complete the following information):

  • OS: Windows 10
  • Version: 20H2

VS Code (please complete the following information):

  • Version: 1.52.1 (using WSL remote extension)

Export sorting doesn't work the same as Import sorting.

I had expected exports to be sorted by the same criteria as imports, but discovered that only the barrel names are sorted.

Given

export * from "./t-named-file";
export * from "./z-named-file";
export * from "./a-named-file";

Nothing happens. If these were imports instead of exports, you'd see:

import * as aName from "./a-named-file";
import * as tName from "./t-named-file";
import * as zName from "./z-named-file";

Given:

export { Foo, Baz, Bar  } from "./some-file";

The export is correctly sorted as:

export { Bar, Baz, Foo } from "./some-file";

This is correct, as it is what also happens for imports.

Does not respect the VS Code preference for single/double quotes.

Describe the bug
When you hit save the import statements switch to using single quotes even when VS Code is configured to use double quotes for JavaScript/TypeScript.

To Reproduce
Steps to reproduce the behavior:

  1. Adjust the VS Code settings to use double quotes for JavaScript/TypeScript.
  2. Use double quotes with an import statement.
  3. Save the file.

Expected behavior
Double quotes should remain within the import statement.

Actual behavior
Double quotes get swapped to single quotes.

OS (please complete the following information):

  • OS: MacOS
  • Version: 10.15.7

VS Code (please complete the following information):

  • Version: 1.51.1

No blank line between .css / .scss and other imports

I just want a simple Boolean to say "no blank lines to all imports be it groups or subgroups"

Describe alternatives you've considered
Or a step by step instruction on readme to implement "no blank line separator" using the subgroup methods so it is easier for newbies to search "blank lines" on the wiki / readme and follow them. Right now, the instructions is quite vague and requires the user to understand regex rules.

Additional context
I tried this setting but the result is not what i intended:

	"tsImportSorter.configuration.groupRules": [
		[
			"^react(-dom)?$",
			"^@angular/",
			"^vue$",
			{},
			"^[@]",
			"^[.]",
			{
				"flag": "scripts",
				"regex": ".scss$"
			}
		]
	],

the result

//intended
import './App.scss'
import { SignPage } from '../SignPage/SignPage'

. . . my codes

//what happened
import './App.scss'

import { SignPage } from '../SignPage/SignPage'

. . . my codes

Flag to disable ESLint checking

Moving a new feature request to this new issue:

Is there any interest in adding a flag to disable ESLint checking? We currently use (and love) this tool but the 7.3.0 update broke our setup because the ESLInt config takes precedence over our import-sorter.json.

We use a max-len for our code, but not imports.

Our ESLint has a max length of 100, but for the import sorter it's 0 (no max at all).

We don't need nicely formatted imports, so we allow unlimited line length just for the imports.

When eslint max-len is set, it breaks that usage pattern since it "overrides" the import-sorter.json.

Thanks for taking the time to check it out!

.eslintrc

{
  "env": {
    "es6": true,
    "react-native/react-native": true
  },
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "plugins": [
    "@typescript-eslint",
    "jest",
    "react",
    "react-native",
    "react-hooks"
  ],
  "ignorePatterns": [
    "node_modules",
  ],
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:jest/recommended"
  ],
  "rules": {
    "max-len": ["warn", {
      "code": 100,
      "tabWidth": 2,
      "ignoreComments": true,
      "ignoreStrings": true,
      "ignoreTrailingComments": true,
      "ignoreTemplateLiterals": true,
      "ignoreRegExpLiterals": true,
    }],
}

import-sorter.json

{
  "autoFormat": "onSave",
  "formatExports": false,
  "exclude": ["scripts/", "node_modules"],
  "sortImportsBy": "paths",
  "maxLineLength": 0,
  "bracketSpacing": true,
  "wrappingStyle": {
    "maxBindingNamesPerLine": 0,
    "maxNamesPerWrappedLine": 0,
    "maxDefaultAndBindingNamesPerLine": 0,
    "maxExportNamesPerLine": 0
  },
  "emptyLinesAfterAllImports": 2,
  "groupRules": [
    {
      "regex": "^react(-native)?$"
    },
    {},
    {
      "subGroups": [
        "^@(src|assets|components|constants|context|helpers|hooks|navigation|screens|types|graphql)",
        "^@DATA$",
        "^[.]+",
        "^[.]"
      ]
    }
  ]
}

Imports sorted on line lengths equal to maximum

The import sorter should allow import lines that are as long as the maximum and only wrap lines that are strictly longer, but instead it also wraps lines as long as the maximum. The workaround is to set the maximumLineLength to be one higher than the actual intended maximum length, which is confusing.

Run on save with `editor.codeActionsOnSave`

I'd like to run some other operations on top of sorting imports. It'd be useful if I could use it with editor.codeActionsOnSave so I could potentially do something like this:

  "editor.codeActionsOnSave": [
    "source.organizeImports",
    "source.fixAll"
  ],

Prevent removal of "unused" twin.macro

Is your feature request related to a problem? Please describe.
The twin.macro is from a family of babel-plugin-macros for TailwindCSS framework. In practice, it might look like.

import tw from 'twin.macro'

export default function() {
  return <div tw="my-2" />
}

Unfortunately, that import is being removed as unused, but macros are a rather special beast similar to React.

Describe the solution you'd like
It would be probably best to cover this in groupRules, some different flag that prevents the removal of that group. The React/h could be handled this way too so it doesn't need to be hardcoded.

Describe alternatives you've considered
I tried the following, but it has no effect, and import is removed.

"tsImportSorter.configuration.groupRules": [
  {
    "flag": "all",
    "regex": "^twin.macro$"
  },
  "^react(-dom)?$",
  {},
  "^[@]",
  "^[.]"
]

Cannot read property 'kind' of undefined

With the latest version of the extension I'm seeing this error in VS Code:

Error found: Cannot read property 'kind' of undefined. 
If you believe this is a bug, please report on https://github.com/daidodo/tsimportsorter

I'm using "typescript": "3.8.3",.

My project dependencies have not changed since everything was previously working, only the extension version.

I updated my import-sorter.json to use the renamed rules:

"maxLineLength": 120,
"maxBindingNamesPerLine": 8,
"maxDefaultAndBindingNamesPerLine": 8,
"maxNamesPerWrappedLine": 4,
"autoFormat": "onSave",

But that hasn't resolved anything.

Option to allow for only sorting

In my projects, prettier controls line length and makes additional decisions about when to break the binding names onto multiple lines. Even with the following which gets it right most of the time to match prettier

{
  "maxBindingNamesPerLine": 0,
  "maxDefaultAndBindingNamesPerLine": 0
}

there are situations where there is a conflict between the maxLineLength from this project and prettier. For example the following import remains as one line with prettier despite breaking the line length rule because of the long import path, prettier decides to not break it up, but this plugin will force it onto 3 lines:

import { FakeImportWithVeryLooongName } from './components/fake-import-file-name-very-loooong/fake-import-file-name-very-loooong';

Since I want my projects to autofix to prettier rules, there will always be another change in this situation (you can see during on save, prettier fixes it to one line and then this plugin will force it to 3 immediately afterwards) and it will violate the prettier check in CI, and require the prettier fix to be done on the command line to make it match and pass the prettier check in CI.

Ideally the option would enforce formatting only to the specs of the rules in eslint and leave the bindings per line options up to prettier. Is this possible?

Exception: rule.forEach is not a function

Code snippet triggering the exception

// INSERT CODE HERE

Logs
(Please select ALL logs in "JS/TS Import/Export Sorter" Output window and copy/paste here)

[2020-10-17T23:30:30.574] [INFO] formatDocument - config: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'onSave',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  groupRules: [
    '^react(-dom)?$',
    {},
    '^@optika',
    '^~/',
    '^../',
    '^./(?!style)',
    '^./style'
  ],
  sortRules: { paths: '', names: [ '_', 'aA' ] },
  keepUnused: [ { path: '.*' } ],
  EmptyLinesBetweenGroups: 1,
  maxBindingNamesPerLine: 3,
  maxDefaultAndBindingNamesPerLine: 4,
  maxExportNamesPerLine: 0,
  maxNamesPerWrappedLine: 1,
  insertFinalNewline: true,
  maxLineLength: 80,
  tabType: 'space',
  tabSize: 2,
  hasSemicolon: false,
  quoteMark: 'double',
  trailingComma: 'multiLine',
  bracketSpacing: true,
  eol: 'LF'
}
[2020-10-17T23:30:30.574] [INFO] formatDocument - tsCompilerOptions: undefined
[2020-10-17T23:30:30.575] [INFO] formatDocument - fileName: /Users/ggyorfi/Projects/bridge/src/__tests__/parser.spec.js
[2020-10-17T23:30:30.578] [INFO] parser.formatSource - composeConfig: {
  maxLength: 80,
  maxWords: {
    withoutDefault: 3,
    withDefault: 4,
    wrapped: 1,
    exported: 9007199254740991
  },
  groupSep: '\n\n',
  tab: '  ',
  quote: [Function],
  comma: ',',
  semi: '',
  bracket: [Function],
  lastNewLine: true,
  nl: '\n'
}
[2020-10-17T23:30:30.578] [ERROR] formatDocument - Found exception: [TypeError: rule.forEach is not a function
	at comparatorFromRule (Project/out/format/sort/compare.js:142:54)
	at Object.sorterFromRules (Project/out/format/sort/compare.js:9:68)
	at Object.formatSource (Project/out/format/main/index.js:43:27)
	at formatDocument (Project/out/extension.js:79:34)
	at sortImportsBeforeSavingDocument (Project/out/extension.js:54:27)
	at Project/out/extension.js:21:75
	at t.ExtHostDocumentSaveParticipant._deliverEventAsync (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:621:150)
	at t.ExtHostDocumentSaveParticipant._deliverEventAsyncAndBlameBadListeners (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:620:396)
	at t.ExtHostDocumentSaveParticipant.$participateInSave (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:620:98)
	at g._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:464)
	at g._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:156)
	at g._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:858:817)
	at g._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:857:623)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:855:691
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1047:649
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
	at t.PersistentProtocol._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:261:451)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:258:489
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at p.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:851)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:203
	at Socket.t (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:263:54)
	at Socket.emit (events.js:223:5)
	at addChunk (_stream_readable.js:309:12)
	at readableAddChunk (_stream_readable.js:290:11)
	at Socket.Readable.push (_stream_readable.js:224:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)]

Support Type-Only imports in group rules

Is your feature request related to a problem? Please describe.
I can not find a correct setting to sort all the Type-Only import statements to the last group.

Describe the solution you'd like
It would be very helpful for me if I can define the following rules:
"tsImportSorter.configuration.groupRules": [{}, "^[@]", "^[#]", "^[.]", "Type-Only"]

Additional context
This is an example of the original sort result (with groupRules: [{}, "^[@]", "^[#]", "^[.]"]):

import type {
  CognitoIdToken,
  CognitoUserSession,
} from 'amazon-cognito-identity-js';
import {
  AuthenticationDetails,
  CognitoUser,
  CognitoUserPool,
} from 'amazon-cognito-identity-js';

import {
  BadRequestException,
  Inject,
  Injectable,
  Logger,
} from '@nestjs/common';

import { AuthError } from './auth.constant';
import type { LogInDTO } from './dtos/log-in.dto';

This is what I prefer (with groupRules: [{}, "^[@]", "^[#]", "^[.]", "Type-Only"]):

import {
  AuthenticationDetails,
  CognitoUser,
  CognitoUserPool,
} from 'amazon-cognito-identity-js';

import {
  BadRequestException,
  Inject,
  Injectable,
  Logger,
} from '@nestjs/common';

import Config, { AWSConfig } from '#configs';

import { AuthError } from './auth.constant';

import type {
  CognitoIdToken,
  CognitoUserSession,
} from 'amazon-cognito-identity-js';
import type { CognitoUserJWTPayload } from 'nestjs-xion/model';
import type { LogInDTO } from './dtos/log-in.dto';

How to set extension respect prettier wrap style?

Describe the bug

I use prettier to format my code, but It often happens that prettier format the code after this extension modify code. In face, I think the wrap style should be prettier's responsibility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.