Skip to content

Commit 0cb345a

Browse files
committed
Document dprint
Closes #127.
1 parent 7d4947a commit 0cb345a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Easy autofixable import sorting.
88
- ✅️ Handles type imports/exports
99
- ✅️ [TypeScript] friendly \(via [@typescript-eslint/parser])
1010
- ✅️ [Prettier] friendly
11+
- ✅️ [dprint] friendly ([with configuration])
1112
- ✅️ [eslint-plugin-import] friendly
1213
- ✅️ `git diff` friendly
1314
- ✅️ 100% code coverage
@@ -17,10 +18,12 @@ Easy autofixable import sorting.
1718
This is for those who use `eslint --fix` (autofix) a lot and want to completely forget about sorting imports!
1819

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

2528
## Example
2629

@@ -646,6 +649,24 @@ Some other differences:
646649
- 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.
647650
- 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.
648651

652+
### How do I use this with `dprint`?
653+
654+
[dprint] also sorts imports and exports – but does not group them. Instead, it preserves your own grouping.
655+
656+
The first question to ask yourself is if dprint is good enough. If so, you’ve got one tool less to worry about!
657+
658+
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:
659+
660+
```json
661+
{
662+
"typescript": {
663+
"module.sortImportDeclarations": "maintain"
664+
}
665+
}
666+
```
667+
668+
Source: https://dprint.dev/plugins/typescript/config/
669+
649670
## License
650671

651672
[MIT](LICENSE)

0 commit comments

Comments
 (0)