Setting up linting

Contents

oxlint is a static code analysis tool for identifying problematic patterns in JavaScript and TypeScript code.

oxlint is part of the same Oxc toolchain that powers tsdown, implements the most common ESLint (and typescript-eslint) rules, and lints TypeScript natively — without depending on the typescript package. Having linting as a part of the build process is considered a good practice.

Install

npm install --save-dev oxlint

Configure

package.json

Add the following scripts to the package.json file:

{
  "scripts": {
    "check": "concurrently -c auto -g --timings npm:check:types npm:lint",
    "lint": "oxlint src",
  }
}
Note that check command was added to package.json in the previous chapter about type checking. Here we just modify it to execute linting as a part of the check command.

.oxlintrc.json

Create the following file:

.oxlintrc.json
{
  "$schema": "./node_modules/oxlint/configuration_schema.json",

  // An array of glob patterns indicating the files that should not be linted.
  "ignorePatterns": [
    "src/jest/server/setupFile.ts",
    "src/**/*.js"
  ],

  "rules": {
    "no-unused-vars": [
      "warn",
      {
        "argsIgnorePattern": "^_"
      }
    ]
  }
}

Linting will now be executed as a part of the check command and, therefore, as a part of the build process.

Summary

Now, you have activated linting - and only one step remains. Prepare your project for testing.


Contents

Contents