Repository navigation
fix(ci): pass only existing scripts to ESLint and existing stylesheets to Stylelint - #52
Closed
HILAYTRIVEDI wants to merge 1 commit into
Closed
HILAYTRIVEDI wants to merge 1 commit into
HILAYTRIVEDI wants to merge 1 commit into
Conversation
…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.
Contributor
There was a problem hiding this comment.
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.ymlto lint only existing script files; otherwise fall back to project-wide lint. - Update
ci-lint-css.ymlto 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
ci-lint-js.ymlpasses every path fromci-detect-changes'js-filesstraight to ESLint, including scripts the PR deleted. ESLint 10 exits 2 withNo 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.jsoncase 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), runlint-commandover the whole project. Thechanged-filesdescription 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:
Testing
The new
run:block was extracted and run inubuntu:24.04(GNUxargs, as on the runners), witheslintreplaced byecho:changed-filespackage.json/ lock (amc-auto-pilot#17's list)lint-commandover the whole projectlint-commandover the whole projectlint-commandover the whole projectactionlintpasses on both workflows.