eslint
Lint a project with ESLint.
Lint a project with ESLint 9 or later and its flat config. The task runs in a node container and is skipped when the sources and the configuration are unchanged.
Install first
The task runs the tool from node_modules, and a container task only sees the files it
declares and the outputs of its dependencies, so the install must be a dependency. Include
the entry of your package manager (npm, yarn or
pnpm) and extend the task to add it, which works with any of them
and keeps the entry free of a package manager:
includes:
npm:
git: https://github.com/no0dles/hammerkit.git
ref: v1.22.0
path: catalog/npm
eslint:
git: https://github.com/no0dles/hammerkit.git
ref: v1.22.0
path: catalog/eslint
tasks:
lint:
extend: eslint:check
deps: [npm:install]extend keeps the entry's image, sources and commands and adds the dependency
(see extending).
Tasks
| Task | What it does | Reads | Produces |
|---|---|---|---|
check | Lint the sources with eslint. | package.json, eslint.config.*, SOURCE_DIR | nothing |
Inputs
| Input | Default | Meaning |
|---|---|---|
NODE_VERSION | 24 | Tag of the node image the task runs in, e.g. 22 or 24. The image is node:<NODE_VERSION>-alpine. |
SOURCE_DIR | src | Folder with the sources to lint, relative to the working directory. |
Fixing
The entry only checks. A task that rewrites its own sources cannot be cached, so there is no
--fix task; run npx eslint --fix on your machine when you want one.
The entry
# Lints a project with ESLint. The project's own dependencies must be installed first, see the
# page of this entry.
envs:
# tag of the node image eslint runs in
NODE_VERSION: 24
# folder with the sources to lint, relative to the working directory
SOURCE_DIR: src
tasks:
check:
description: lint the sources with eslint
image: node:${NODE_VERSION}-alpine
src: [package.json, 'eslint.config.*', '${SOURCE_DIR}']
cmds:
- node_modules/.bin/eslint ${SOURCE_DIR}