Skip to content

Commit

Permalink
Document dprint
Browse files Browse the repository at this point in the history
Closes #127.
  • Loading branch information
lydell committed Jan 31, 2023
1 parent 7d4947a commit 0cb345a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
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

0 comments on commit 0cb345a

Please sign in to comment.