Skip to main content
Version: 1.0-beta

ESLint

The ESLint module checks JavaScript and TypeScript source with ESLint, running the same lint check locally and in CI so issues get caught before a PR lands. Each ESLint config roots a project, and the module lints each project with its own config.

Add it to your workspace​

dagger module install dagger.io/js/eslint

Run the check​

dagger check --eslint                          # lint every project
dagger check --eslint-project=packages/ui # lint one project

The check is eslint/projects/lint. It installs dependencies and runs the project's own ESLint from the project directory, so the result matches what developers see locally. A check over several projects reports every project that fails.

Projects​

FlagCollectionKey
--eslint-projectprojectsDirectory holding the ESLint config, relative to the workspace root. The root is .

List the keys with dagger list eslint-projects -a. Select collection items describes how to select items.

A project is a directory holding a flat config (eslint.config.js, .mjs, .cjs, .ts, .mts, or .cts) or a legacy config (.eslintrc, .eslintrc.js, .cjs, .json, .yaml, or .yml). A nested project is linted on its own, and the project that encloses it skips its files. A config in a directory that the enclosing flat config ignores globally is not a project.

Projects are found at or below the directory dagger runs from, plus the nearest project that encloses it.

Dependencies install at the nearest workspace root (a pnpm-workspace.yaml or a package.json with workspaces), else the nearest lockfile, else the nearest package.json.

Fix issues​

Each project has a fix function that runs eslint --fix and returns the repaired source as a changeset. Problems ESLint cannot fix are left for the check to report. It is a regular function rather than a check, so it does not run during dagger check:

dagger -c 'eslint | projects | get packages/ui | fix | export .'

Configure it​

List the current settings and their values with dagger module settings eslint, then set one with dagger module settings eslint <key> <value>. Settings are stored in dagger.toml under [modules.eslint.settings] and apply to every project:

  • packageManager (default empty) is the package manager that installs dependencies: npm, pnpm, yarn, or bun. Empty detects it from the packageManager field of package.json, then from the lockfile, then uses npm.
  • baseImageAddress (default node:25-alpine) is the Node base image ESLint runs in. Pin it to the project's Node version, for example node:22-alpine.
  • installFlags (default empty) are extra arguments for the install command, such as ["--ignore-scripts"].
  • environment (default empty) sets environment variables for ESLint, as KEY=VALUE.
[modules.eslint.settings]
baseImageAddress = "node:22-alpine"
installFlags = ["--ignore-scripts"]

Working with other modules​

Use ESLint with Prettier when the project separates lint rules from formatting. Use Biome when the project has moved linting and formatting into one tool.

source code