Skip to content

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

InputTypeDescriptionRequiredDefault
RUNTIME_VERSIONstringRuntime version to use (Node.js or Bun version)No"22"
PACKAGE_MANAGERstringPackage manager to use (npm, pnpm, yarn, bun)No"npm"
RUNTIMEstringJavaScript runtime to use (node, bun)No"node"
ESLINT_CONFIGstringESLint config package to useNo"@antfu/eslint-config"
WORKING_DIRECTORYstringWorking directory for the projectNo"."
LINT_PATHSstringPaths to lint (space or comma-separated)No"."
ESLINT_CONFIG_FILEstringPath to custom ESLint config fileNo""
FAIL_ON_ERRORbooleanWhether to fail the workflow on linting errorsNotrue

Permissions

ScopeAccessDescription
contentsreadRead 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"