lint-js.yml
Comprehensive JavaScript/TypeScript file linting using ESLint with automatic runtime and package manager detection. Supports Node.js and Bun runtimes with npm, pnpm, yarn, and bun package managers. Automatically sets up @antfu/eslint-config
if no ESLint configuration exists.
Inputs
Input | Type | Description | Required | Default |
---|---|---|---|---|
RUNTIME_VERSION | string | Runtime version to use (Node.js or Bun version) | No | "22" |
PACKAGE_MANAGER | string | Package manager to use (npm, pnpm, yarn, bun) | No | "npm" |
RUNTIME | string | JavaScript runtime to use (node, bun) | No | "node" |
ESLINT_CONFIG | string | ESLint config package to use | No | "@antfu/eslint-config" |
WORKING_DIRECTORY | string | Working directory for the project | No | "." |
LINT_PATHS | string | Paths to lint (space or comma-separated) | No | "." |
ESLINT_CONFIG_FILE | string | Path to custom ESLint config file | No | "" |
FAIL_ON_ERROR | boolean | Whether to fail the workflow on linting errors | No | true |
Permissions
Scope | Access | Description |
---|---|---|
contents | read | Read source files for linting |
Notes
- Automatic Detection: Intelligently detects package manager and runtime based on lock files and configuration files.
- Multi-Runtime Support: Works with Node.js and Bun runtimes.
- Multi-Package Manager Support: Supports npm, pnpm, yarn, and bun package managers.
- Auto-Configuration: Automatically installs and configures
@antfu/eslint-config
if no ESLint config exists. - File Type Support: Lints JavaScript, TypeScript, JSON, JSONC, Markdown, and YAML files.
- Package Manager Detection: Looks for
bun.lockb
/bun.lock
→ uses Bun,pnpm-lock.yaml
→ uses pnpm,yarn.lock
→ uses Yarn, falls back to npm. - Runtime Detection: Looks for Bun lock files → uses Bun, falls back to Node.js.
- ESLint Config Detection: Checks for existing ESLint config files, creates
eslint.config.js
with@antfu/eslint-config
if none found. - The workflow creates a temporary ESLint configuration using
@antfu/eslint-config
if no configuration is detected. - The default configuration enables linting for JS, TS, JSON, JSONC, YAML, and Markdown files.
- Custom ESLint configurations take precedence over the auto-generated one.
Examples
Simple example
yaml
jobs:
lint:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
RUNTIME_VERSION: "18"
PACKAGE_MANAGER: "pnpm"
LINT_PATHS: "src tests"
Bun runtime
yaml
jobs:
lint:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
RUNTIME: "bun"
PACKAGE_MANAGER: "bun"
LINT_PATHS: "src,tests,docs"
Custom ESLint config
yaml
jobs:
lint:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
ESLINT_CONFIG: "@company/eslint-config"
LINT_PATHS: "apps packages"
Monorepo with working directory
yaml
jobs:
lint-frontend:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
WORKING_DIRECTORY: "packages/frontend"
LINT_PATHS: "src components"
lint-backend:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
WORKING_DIRECTORY: "packages/backend"
PACKAGE_MANAGER: "pnpm"
LINT_PATHS: "src,tests"
Non-blocking linting
yaml
jobs:
lint:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
FAIL_ON_ERROR: false
LINT_PATHS: "src tests docs"
Custom config file
yaml
jobs:
lint:
uses: this-is-tobi/github-workflows/.github/workflows/lint-js.yml@main
with:
ESLINT_CONFIG_FILE: ".eslintrc.custom.js"
LINT_PATHS: "apps,packages,tools"