Skip to content

fix(ci): pass only existing scripts to ESLint and existing stylesheets to Stylelint - #52

Closed
HILAYTRIVEDI wants to merge 1 commit into
rtCamp:release/v1.0.0from
HILAYTRIVEDI:fix/lint-js-existing-files
Closed

HILAYTRIVEDI wants to merge 1 commit into
rtCamp:release/v1.0.0from
HILAYTRIVEDI:fix/lint-js-existing-files

Conversation

@HILAYTRIVEDI

Copy link
Copy Markdown

Summary

ci-lint-js.yml passes every path from ci-detect-changes' js-files straight to ESLint, including scripts the PR deleted. ESLint 10 exits 2 with No files matching the pattern "…" for each deleted script, so any PR that deletes a JS file fails the ESLint job.

#40 fixed the same problem for PHPCS (and the package.json case for Stylelint). This applies the same pattern to ESLint, and adds the missing existence check to Stylelint.

Changes

  • ci-lint-js.yml: lint changed scripts (.js, .jsx, .ts, .tsx, .mjs, .cjs) that still exist, file by file. If the list is empty, holds only deleted scripts, or holds anything else (package.json, package-lock.json), run lint-command over the whole project. The changed-files description is updated to match.
  • ci-lint-css.yml: Stylelint only gets stylesheets that still exist.
  • CHANGELOG.md: entries under Unreleased → Fixed.

How it was found

rtCamp/amc-auto-pilot#17 deletes the skeleton's example blocks. Its ESLint job failed:

ESLint: 10.5.0
No files matching the pattern "src/blocks/example-block-dynamic/edit.js" were found.
##[error]Process completed with exit code 123.

Testing

The new run: block was extracted and run in ubuntu:24.04 (GNU xargs, as on the runners), with eslint replaced by echo:

changed-files Result
Existing scripts + deleted scripts + package.json / lock (amc-auto-pilot#17's list) lint-command over the whole project
Existing scripts + deleted scripts ESLint on the existing scripts only
Only deleted scripts lint-command over the whole project
Empty lint-command over the whole project

actionlint passes on both workflows.

…s to Stylelint

ci-detect-changes lists deleted files in js-files and css-files. ESLint
exits 2 with "No files matching the pattern" for each deleted script,
so any PR that deletes a JS file failed lint-js. Mirror the ci-lint-php
fix: lint changed scripts that still exist file by file, and run
lint-command over the whole project when the list holds anything else
(package.json, package-lock.json) or only deleted scripts. Stylelint
gets the same existence filter.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Fixes CI lint failures when ci-detect-changes includes deleted files (or non-lintable files) by filtering to existing, relevant paths before invoking linters.

Changes:

  • Update ci-lint-js.yml to lint only existing script files; otherwise fall back to project-wide lint.
  • Update ci-lint-css.yml to pass only existing stylesheets to Stylelint.
  • Document the fixes in CHANGELOG.md.
File Description
CHANGELOG.md Adds Fixed entries describing the CI lint behavior changes.
.github/​workflows/​ci-lint-js.yml Filters js-files down to existing script files and avoids passing deleted/non-script files to ESLint.
.github/​workflows/​ci-lint-css.yml Filters css-files down to existing stylesheet files before running Stylelint.

Review effort: Lite

default: "npm run lint:js"
changed-files:
description: "Newline-separated list of JS files to lint. Empty = run lint-command over the whole project."
description: "Newline-separated changed files (ci-detect-changes' js-files). Scripts that still exist are linted file by file; if the list is empty, holds only deleted scripts, or holds anything else (package.json, package-lock.json), lint-command runs over the whole project."
Comment on lines +66 to +68
scripts=$(printf '%s\n' "$CHANGED_FILES" | grep -E '\.[cm]?[jt]sx?$' \
| while IFS= read -r file; do [ ! -f "$file" ] || printf '%s\n' "$file"; done || true)
others=$(printf '%s\n' "$CHANGED_FILES" | grep -vE '^$|\.[cm]?[jt]sx?$' || true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants