From 29500d4945a4704a85114bb465908d745d04d913 Mon Sep 17 00:00:00 2001 From: Frederic Barthelemy Date: Mon, 16 May 2022 13:43:06 -0700 Subject: [PATCH] Readme Updates - Fixes #13 (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As discussed in #13 here are a few tweaks to the README, the commits tell the story! - [x] Proposed wording for the project introduction - [x] misc tweaks suggested by my markdown linter - [x] Fix the Github-Autogenerated Outline
▶️ Github's Outline was Confusing **Current Outline** ![Screenshot of Current Outline](https://user-images.githubusercontent.com/209712/168663271-7c1b6f6d-eae7-43ca-bfa3-f42530e57dd7.png) **New Outline** ![Screenshot of New Outline](https://user-images.githubusercontent.com/209712/168663580-3e5bb74a-4782-4ae2-8b08-f0e03d20a790.png)
--- .editorconfig | 14 +++++++++++++ README.md | 55 +++++++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..00c17ac --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +# Set default charset (override if necessary) +charset = utf-8 +indent_style = space +indent_size = 4 diff --git a/README.md b/README.md index af2832f..7d6ec44 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ # Prettier plugin sort imports -A prettier plugin to sort import declarations by provided Regular Expression order. +A prettier plugin to sort import declarations by provided Regular Expression order. -This was forked from https://github.com/trivago/prettier-plugin-sort-imports. The main difference is that this project will not change the order of your side-effect imports (see [How it works](#how-does-import-sort-work-)), to avoid breaking your styles or your code. I will try to keep it up-to-date with the Trivago version, but it may drift apart at some point. +This was forked from [@trivago/prettier-plugin-sort-imports](https://github.com/trivago/prettier-plugin-sort-imports). + +The first change was preserving the order of [side-effect imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#import_a_module_for_its_side_effects_only) to avoid breaking situations where import-order has correctness implications (such as styles). + +Since then more critical features & fixes have been added. As a result, this repo intends to stay compatible with the upstream, but may continue to gain features not present in the original version of the plugin. + +[We welcome contributions!](./CONTRIBUTING.md) + +## Sample ### Input @@ -30,7 +38,6 @@ import { Popup } from '@ui/Popup'; import { createConnection } from '@server/database'; ``` - ### Output ```javascript @@ -61,7 +68,7 @@ import { Message } from '../Message'; import { add, filter, repeat } from '../utils'; ``` -### Install +## Install npm @@ -77,7 +84,7 @@ yarn add --dev @ianvs/prettier-plugin-sort-imports **Note: If you are migrating from v2.x.x to v3.x.x, [Please Read Migration Guidelines](./docs/MIGRATION.md)** -### Usage +## Usage Add an order in prettier config file. @@ -96,7 +103,7 @@ module.exports = { ### APIs -### Prevent imports from being sorted +#### Prevent imports from being sorted This plugin supports standard prettier ignore comments. By default, side-effect imports (like `import "core-js/stable";`) are not sorted, so in most cases things should just work. But if you ever need to, you can @@ -118,14 +125,14 @@ entire import statements can be ignored, line comments (`// prettier-ignore`) ar A collection of Regular expressions in string format. -``` +```json "importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"], ``` _Default behavior:_ The plugin moves the third party imports to the top which are not part of the `importOrder` list. To move the third party imports at desired place, you can use `` to assign third party imports to the appropriate position: -``` +```json "importOrder": ["^@core/(.*)$", "", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"], ``` @@ -138,7 +145,7 @@ To move the third party imports at desired place, you can use `` special word in the `importOrder`. -### FAQ / Troubleshooting +## FAQ / Troubleshooting -Having some trouble or an issue ? You can check [FAQ / Troubleshooting section](./docs/TROUBLESHOOTING.md). +Having some trouble or an issue? You can check [FAQ / Troubleshooting section](./docs/TROUBLESHOOTING.md). -### Compatibility +## Compatibility | Framework | Supported | Note | | ---------------------- | ------------------------ | ------------------------------------------------ | @@ -280,13 +285,11 @@ Having some trouble or an issue ? You can check [FAQ / Troubleshooting section]( | Vue | ⚠️ Soon to be supported. | Any contribution is welcome. | | Svelte | ⚠️ Soon to be supported. | Any contribution is welcome. | - -### Contribution +## Contribution For more information regarding contribution, please check the [Contributing Guidelines](./CONTRIBUTING.md). If you are trying to debug some code in the plugin, check [Debugging Guidelines](./docs/DEBUG.md) - -### Disclaimer +## Disclaimer This plugin modifies the AST which is against the rules of prettier.