Skip to content

Commit

Permalink
fix: define as builtin modules that require a node prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jul 31, 2024
1 parent 68632df commit aac4725
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rules/sort-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ export default createEslintRule<Options<string[]>, 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)
)
}
Expand Down
2 changes: 2 additions & 0 deletions test/sort-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
`,
Expand Down

0 comments on commit aac4725

Please sign in to comment.