Skip to content

linter: --tsconfig flag is ignored, causing false positives #20328

@smitrovic-figma

Description

@smitrovic-figma

What version of Oxlint are you using?

latest

What command did you run?

npx oxlint --config oxlintrc.json --tsconfig tsconfig.json

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript"],
  "rules": {
    "typescript/no-floating-promises": "warn",
    "typescript/no-for-in-array": "warn",
    "typescript/await-thenable": "warn",
    "typescript/no-misused-promises": "warn",
    "typescript/noredundant-type-constituents": "warn"
  },
  "options": {
    "typeAware": true
  }
}

What happened?

Summary

The --tsconfig CLI flag is only wired up to the import resolver but is never forwarded to tsgolint. When a file's nearest tsconfig.json doesn't include the file, tsgolint marks it as "unmatched", even if --tsconfig points to a config that does include it.

Imported types in unmatched files resolve to error types acting as any, producing false positives from rules like no-redundant-type-constituents.

Repro steps

Create a directory structure like:

repro/
  ├── tsconfig.json        # includes ["src", "types"], has paths config
  ├── oxlintrc.json
  ├── types/
  │   └── lib.ts
  └── src/
      ├── tsconfig.json    # includes ["bar.ts"] only — does NOT cover foo.ts
      ├── bar.ts
      └── foo.ts           # imports from @types/lib using path alias

tsconfig.json (root — covers all files, has path aliases)

{
  "compilerOptions": {
    "strict": true,
    "paths": { "@types/*": ["./types/*"] }
  },
  "include": ["src", "types"]
}

src/tsconfig.json (nearest to foo.ts — only covers bar.ts):

{
  "compilerOptions": { "strict": true },
  "include": ["bar.ts"]
}

oxlintrc.json

{ "rules": { "typescript/no-redundant-type-constituents": "error" } }

types/lib.ts

export type Success = { kind: "success"; data: string };
export type Failure = { kind: "failure"; error: Error };

src/bar.ts

export const bar = 42;

src/foo.ts

import { Success, Failure } from "@types/lib";

type Result = Success & Failure;

export function handle(r: Result): string {
  return r.kind;
}

Then run:

OXC_LOG=debug oxlint --config oxlintrc.json --tsconfig tsconfig.json --type-aware src/foo.ts src/bar.ts

Expected: 0 errors. The --tsconfig tsconfig.json points to the root config which includes foo.ts and has the paths config needed to resolve the imports.

Actual: --tsconfig tsconfig.json gets ignored; tsgolint seems to find the nearest tsconfig, in this case the one in src/, notes that it doesn't include src/foo.ts, and marks the file as unmatched. Without paths to resolve the imports properly, we get a false positive no-redundant-type-constituents lint error on two types which are clearly not redundant:

Got tsconfig for file .../src/foo.ts: <none>
Done assigning files to programs. Total programs: 1. Unmatched files: 1

typescript-eslint(no-redundant-type-constituents): 'Success' is an 'error' type that acts as 'any'
typescript-eslint(no-redundant-type-constituents): 'Failure' is an 'error' type that acts as 'any'

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions