Skip to content

[TEST] Add BATS tests for eslint.sh #3

@prog-time

Description

@prog-time

Note

The task was generated using the MCP server — prog-time/github-issues-server

Release: 1
Type: test
Priority: high
Blocks:
Blocked by:
Status: todo


Description

The script scripts/shell/linters/eslint.sh has no corresponding BATS test file. Every other linter script in scripts/shell/linters/ has a test counterpart in tests/linters/ (hadolint, htmlhint, markdownlint, shellcheck, stylelint, yamllint), but eslint.bats does not exist. This violates the project rule that every shell script must be covered by a BATS unit test (rules/process/ci-cd.md, section 9).


Motivation

Without tests, regressions in eslint.sh — config discovery logic, file collection, the ERROR_FOUND accumulator — will not be caught by CI. ESLint's config file detection is the most complex of all linter scripts: it checks seven possible filename variants (eslintrc.json, eslint.config.js, and five others). This logic is especially brittle without test coverage.


Target Structure

tests/
└── linters/
    ├── eslint.bats         ← new file
    ├── hadolint.bats
    ├── htmlhint.bats
    ├── markdownlint.bats
    ├── shellcheck.bats
    ├── stylelint.bats
    └── yamllint.bats

Checklist

  • Create tests/linters/eslint.bats modelled on tests/linters/htmlhint.bats
  • Test: no ESLint config file found → exit 1, output contains ::error::No ESLint config file found
  • Test: config .eslintrc.json found, no JS/TS files → exit 0, output contains ⚠️ No JS/TS files found. Skipping.
  • Test: config eslint.config.js found (alternative format), all files pass → exit 0, output contains ✅ All JS/TS files passed ESLint checks!
  • Test: config found, one file fails → exit 1, output contains ❌ ESLint found issues!
  • Test: config found, multiple files, one fails — all files are checked (accumulator pattern, does not stop on first error)
  • Verify the test file uses helpers from tests/helpers/common.bash (mock_tool / conditional stub pattern matching htmlhint.bats)
  • Run bats tests/linters/eslint.bats locally — all tests pass
  • Run bats --recursive tests/ — the full test suite passes

Affected Files

File Change
tests/linters/eslint.bats create

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions