Rules

no-js-extension-imports

Official opt-in rule converting JavaScript extensions in relative imports.

Purpose and behavior

Official opt-in rule converting JavaScript extensions in relative imports.

Checks static imports and re-exports beginning with ./ or ../ and ending exactly in .js, .jsx, .mjs or .cjs. Fixes them to .ts, .tsx, .mts or .cts using a double-quoted literal. Does not cover dynamic imports, # aliases, missing extensions or paths ending with query strings/fragments. It is not equivalent to the custom extension family: mjs/cjs coverage is unique, but js/jsx diagnostics overlap and conflict with mode js. Presets leave it disabled.

Options

No configurable options. Enable with "rules/no-js-extension-imports": "error".

Invalid example

import { value } from './value.mjs'

Valid example

import { value } from './value.mts'

Fixes and exceptions

This rule supplies an automatic code fix. Review the resulting import bindings and runtime resolution before applying it.

For a genuine boundary exception, use an oxlint-disable-next-line rules/no-js-extension-imports -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.

Source and tests

Opt-in compatibility rule. Not enabled by either preset because its import convention conflicts or its diagnostics overlap with the selected default policy.

no-js-extension-imports.ts · Tests