From aac472536020c7491080f7809559488d3aa9c6d9 Mon Sep 17 00:00:00 2001 From: "Azat S." Date: Wed, 31 Jul 2024 19:49:26 +0300 Subject: [PATCH] fix: define as builtin modules that require a node prefix --- rules/sort-imports.ts | 2 ++ test/sort-imports.test.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rules/sort-imports.ts b/rules/sort-imports.ts index c7b5bd50..68700caa 100644 --- a/rules/sort-imports.ts +++ b/rules/sort-imports.ts @@ -309,10 +309,12 @@ export default createEslintRule, MESSAGE_ID>({ 'undici', 'ws', ] + let builtinPrefixOnlyModules = ['sea', 'sqlite', 'test'] return ( builtinModules.includes( value.startsWith('node:') ? value.split('node:')[1] : value, ) || + builtinPrefixOnlyModules.some(module => `node:${module}` === value) || (options.environment === 'bun' ? bunModules.includes(value) : false) ) } diff --git a/test/sort-imports.test.ts b/test/sort-imports.test.ts index 3906b6f1..230bb9d9 100644 --- a/test/sort-imports.test.ts +++ b/test/sort-imports.test.ts @@ -4561,6 +4561,8 @@ describe(ruleName, () => { { code: dedent` import {} from 'node:os' + import sqlite from 'node:sqlite' + import { describe, test } from 'node:test' import { c } from 'c' import 'node:os' `,