Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document dprint #128

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Easy autofixable import sorting.
- ✅️ Handles type imports/exports
- ✅️ [TypeScript] friendly \(via [@typescript-eslint/parser])
- ✅️ [Prettier] friendly
- ✅️ [dprint] friendly ([with configuration])
- ✅️ [eslint-plugin-import] friendly
- ✅️ `git diff` friendly
- ✅️ 100% code coverage
Expand All @@ -17,10 +18,12 @@ Easy autofixable import sorting.
This is for those who use `eslint --fix` (autofix) a lot and want to completely forget about sorting imports!

[@typescript-eslint/parser]: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
[dprint]: https://dprint.dev/
[eslint-plugin-import]: https://github.com/import-js/eslint-plugin-import/
[no-require]: https://github.com/lydell/eslint-plugin-simple-import-sort/#does-it-support-require
[prettier]: https://prettier.io/
[typescript]: https://www.typescriptlang.org/
[with configuration]: https://github.com/lydell/eslint-plugin-simple-import-sort/#TODO

## Example

Expand Down Expand Up @@ -646,6 +649,24 @@ Some other differences:
- This plugin gives you a single error for each chunk of imports/exports, while `import/order` can give multiple (see [Can I use this without autofix?][autofix] for details). In other words, this plugin is noisier in terms of underlined lines in your editor, while `import/order` is noisier in terms of error count.
- This plugin has a single (though very powerful) option that is a bunch of regexes, while `import/order` has bunch of different options. It’s unclear which is easier to configure. But `eslint-plugin-simple-import-sort` tries to do the maximum out of the box.

### How do I use this with `dprint`?

[dprint] also sorts imports and exports – but does not group them. Instead, it preserves your own grouping.

The first question to ask yourself is if dprint is good enough. If so, you’ve got one tool less to worry about!

If you’d like to enforce grouping, though, you could still use `eslint-plugin-simple-import-sort`. However, the two might disagree slightly on some sorting edge cases. So it’s better to turn off sorting in your dprint config file:

```json
{
"typescript": {
"module.sortImportDeclarations": "maintain"
}
}
```

Source: https://dprint.dev/plugins/typescript/config/

## License

[MIT](LICENSE)
Expand Down