Rules

force-ts-extension

Compatibility rule combining required extensions with ts normalization.

Purpose and behavior

Compatibility rule combining required extensions with ts normalization.

Retained for existing configurations. Reports missing extensions without a fix and fixes .js/.jsx to .ts/.tsx. Shares the same relative/# scope and import/export/dynamic-import coverage as the split rules. Prefer require-import-extension plus consistent-import-extension. Presets omit this alias to avoid duplicate reports.

Options

{ mode: "ts" } (default) or { mode: "js" }, matching consistent-import-extension. Missing extensions are still reported without a fix. Examples below use ts mode.

Invalid example

import { foo } from './foo.js'

Valid example

import { foo } from './foo.ts'

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/force-ts-extension -- 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.

force-ts-extension.ts · Tests