ts-npm-oxlint-setup

$npx mdskill add kongyo2/ts-npm-oxlint-setup/ts-npm-oxlint-setup

Initialize Oxlint for fast TypeScript linting.

  • Installs oxlint and configures baseline rules.
  • Depends on npm and TypeScript project structure.
  • Merges existing configuration while adding missing items.
  • Generates package.json scripts and .oxlintrc.json.
SKILL.md
.github/skills/ts-npm-oxlint-setupView on GitHub ↗
---
name: ts-npm-oxlint-setup
description: Set up Oxlint in a TypeScript project.
---

# TS + npm Oxlint Setup

Use this when a project uses TypeScript + npm and you want a fast lint baseline.

## Expected Outcome

- `oxlint` exists in `devDependencies`
- `scripts` contains `lint`, `lint:strict`, `check:file`
- `.oxlintrc.json` exists with baseline categories/rules/ignore patterns

## Setup

```bash
npm add -D oxlint
```

### package.json scripts

```json
{
  "scripts": {
    "lint": "oxlint --silent",
    "lint:strict": "oxlint --deny-warnings",
    "check:file": "oxlint"
  }
}
```

- If `scripts.lint` already exists, replace it with `oxlint --silent`.
- Keep non-lint scripts (for example `test`, `dev`, `build`) unchanged.
- Add missing `lint:strict` and `check:file` without deleting other scripts.

### .oxlintrc.json

```json
{
  "plugins": ["promise", "import", "node"],
  "categories": {
    "correctness": "error",
    "suspicious": "warn"
  },
  "rules": {
    "no-console": "warn",
    "typescript/no-explicit-any": "error"
  },
  "ignorePatterns": ["node_modules", "dist", "build", "coverage", "*.min.js"]
}
```

- If `.oxlintrc.json` does not exist, create it from the baseline above.
- If it already exists, merge with this rule:
  - Keep existing project values on conflicts.
  - Add only missing keys/items from the baseline.
  - For arrays (`plugins`, `ignorePatterns`), keep existing order and append only missing baseline items (no duplicates).
  - Never delete existing project-specific rules.

## Verification

Run required check:

```bash
npm run lint
```

- `npm run lint` should pass (exit code `0`) before considering setup complete.
- Optional strict check (recommended):

```bash
npm run lint:strict
```

- `npm run lint:strict` may fail if warnings exist (`--deny-warnings` behavior). That is expected and does not mean setup failed.
- `check:file` must be exactly `oxlint`.
- `npm run check:file` runs a full-project lint.
- `npm run check:file -- src/example.ts` runs lint for the provided path only.