Skip to content

Commit

Permalink
Document why some require is supported and others not
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Feb 5, 2024
1 parent 1a9e529 commit 1ae536b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ The final whitespace rule is that this plugin puts one import/export per line. I

No. This is intentional to keep things simple. Use some other sorting rule, such as [import/order], for sorting `require`. Or consider migrating your code using `require` to `import`. `import` is well supported these days.

The only `require`-like thing supported is TypeScript import assignments like `import Thing = require("something")`. They’re much easier to support since they are very restricted: The thing to the left of the `=` has to be a single identifier, and inside `require()` there has to be a single string literal. This makes it sortable as if it was `import Thing from "something"`.

### Why sort on `from`?

Some other import sorting rules sort based on the first name after `import`, rather than the string after `from`. This plugin intentionally sorts on the `from` string to be `git diff` friendly.
Expand Down

0 comments on commit 1ae536b

Please sign in to comment.