Rules
require-import-extension
Require explicit extensions without guessing module resolution.
Purpose and behavior
Require explicit extensions without guessing module resolution.
The rule reports missing extensions in relative paths and # aliases containing a slash, including directory paths. It checks static imports, re-exports and literal dynamic imports. The rule cannot choose .ts, .tsx or an index filename and provides no fix. It ignores bare packages, absolute paths and slashless aliases such as #utils. It allows explicit asset extensions.
Options
No configurable options. Enable with "rules/require-import-extension": "error".
Invalid example
import { foo } from './foo'Valid example
import { foo } from './foo.ts'Fixes and exceptions
This rule provides no automatic fix. Rewrite the code to preserve its intended behavior.
For a boundary exception, use oxlint-disable-next-line rules/require-import-extension -- reason. Examples cover this rule only and may omit imports or declarations.
Source and tests
Enabled by the TypeScript preset.