From 1ae536b0840449c480d9f8f755cc818ac3293163 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Mon, 5 Feb 2024 22:56:53 +0100 Subject: [PATCH] Document why some `require` is supported and others not --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f54e540..c3f8389 100644 --- a/README.md +++ b/README.md @@ -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.