prettier-plugin-organize-imports

Make Prettier organize your imports using the TypeScript language service API.

MIT License

Downloads
3.4M
Stars
964
Committers
9

Bot releases are hidden (Show)

prettier-plugin-organize-imports - 3.2.4 Latest Release

Published by simonhaenisch 11 months ago

prettier-plugin-organize-imports - 3.2.3

Published by simonhaenisch 11 months ago

Just readme updates to explain compatibility with Prettier 3. Also bumped TypeScript to v5 as a dev dependency to ensure compatibility.

prettier-plugin-organize-imports - 3.2.2

Published by simonhaenisch almost 2 years ago

Fixes a performance regression introduced in 3.2.0 (see #90).

prettier-plugin-organize-imports -

Published by simonhaenisch almost 2 years ago

This version fixes the implementation of the language service host's getCurrentDirectory method to return the directory containing the tsconfig, rather than using ts.sys.getCurrentDirectory (which returns process.cwd()). This should prevent issues with resolving compiler plugins with Volar (which is used for Vue support).

Hopefully it doesn't break anything else 🤞 I don't think the tsconfig location is always the project root because of nested/extended tsconfigs, but it should be good enough for module resolution. If someone knows a better way of finding a project's root via the TypeScript API please let me know 🙏

prettier-plugin-organize-imports -

Published by simonhaenisch almost 2 years ago

This version adds and fixes support for pug templates in Vue files (via @volar/vue-language-plugin-pug). Please be aware that you'll need to update your version of the @volar/vue-typescript peer dependency from 0.x to 1.x.

prettier-plugin-organize-imports -

Published by simonhaenisch about 2 years ago

  • fix: path comparison on Windows
  • fix: bump @volar/vue-typescript peer dependency to higher version which fixes removal of imports used in the template only
prettier-plugin-organize-imports - 3.1.0

Published by simonhaenisch about 2 years ago

New Feature: Skip Destructive Code Actions

If you don't want destructive code actions (like removing unused imports), you can enable the option organizeImportsSkipDestructiveCodeActions via your Prettier config.

// prettierrc.js

module.exports = {
  // ...
  organizeImportsSkipDestructiveCodeActions: true,
};
prettier-plugin-organize-imports - 3.0.3

Published by simonhaenisch about 2 years ago

Fixes a performance regression that was introduced in 3.0.2.

prettier-plugin-organize-imports - 3.0.2

Published by simonhaenisch about 2 years ago

This version fixes a regression introduced by adding some file-system related methods (fileExists and readFile) to the language service host (to fix #63), which revealed that the implementation of getScriptSnapshot was incorrect.

prettier-plugin-organize-imports - 3.0.1

Published by simonhaenisch about 2 years ago

  • @volar/vue-typescript is now an optional peer dependency and requires version 0.39.0 or later. This should fix a couple of issues, e.g. not removing imports anymore when a component was used in the template via kebab-case.
  • The language service host now implements fileExists and readFile which should fix some issues with NodeNext module resolution.
prettier-plugin-organize-imports - 3.0.0

Published by simonhaenisch over 2 years ago

Switched to a different package for Vue support, so if you're using this plugin with Vue, you'll have to install @volar/vue-typescript as a dev dependency now, and you can remove @vue/compiler-sfc/@vue/component-compiler-utils/vue-template-compiler.

Otherwise, no breaking changes.

prettier-plugin-organize-imports - 2.3.4

Published by simonhaenisch about 3 years ago

Fixed a bug where empty comment lines were inserted into Vue 2 files.

prettier-plugin-organize-imports - 2.3.3

Published by simonhaenisch about 3 years ago

  • Fixed a bug where default imports were erroneously removed.
prettier-plugin-organize-imports -

Published by simonhaenisch about 3 years ago

  • Try to use @vue/compiler-sfc (Vue 3.x) first before the@vue/component-compiler-utils and vue-template-compiler combo (which -theoretically is for Vue 2.x but probably also works for 3.x).
prettier-plugin-organize-imports - 2.3.1

Published by simonhaenisch about 3 years ago

The version published to npm was missing files which has been fixed now.

prettier-plugin-organize-imports - 2.3.0

Published by simonhaenisch about 3 years ago

Warning: Don't use this version from npm as it was missing files when being published. Please use v2.3.1 instead.

  • Adds logging when the DEBUG env var is set.
  • Fixes Vue.js support.
prettier-plugin-organize-imports - 2.2.0

Published by simonhaenisch over 3 years ago

  • feat: use cache map for compiler options (closes #19)

Thanks @blidblid for helping debug this performance issue.

prettier-plugin-organize-imports - 2.1.0

Published by simonhaenisch over 3 years ago

Adds support for Vue.js (.vue) files (see #16 and 474bbcb1202535ba374f340a481c1e3f3b8033a6).

prettier-plugin-organize-imports - 2.0.0

Published by simonhaenisch over 3 years ago

Now supports JavaScript via the babel parser and also supports TypeScript via the babel-ts parser 🎉

Special thanks to @duniul for the contribution (see #18)!

Both parsers are only available since Prettier v2, therefore the peer dependency has had a major version bump, which led me to release this as a major version as well. There are no breaking changes otherwise, so unless you're still on Prettier v1, you can just upgrade.

(The parser was called babylon in Prettier v1 but had a different signature so it would not have been easy to do a backwards-compatible implementation)

prettier-plugin-organize-imports - 1.1.1

Published by simonhaenisch over 4 years ago

Added the files list to package.json to reduce the size on npm.