Skip to content

fix(cli): lint files whose names contain glob characters - #3101

Merged
Michał Rychel (micryc) merged 1 commit into
stoplightio:developfrom
efeesrefinal:fix/cli-literal-file-paths
Nov 4, 2026
Merged

Michał Rychel (micryc) merged 1 commit into
stoplightio:developfrom
efeesrefinal:fix/cli-literal-file-paths

Conversation

@efeesrefinal

Copy link
Copy Markdown
Contributor

Fixes #2814.

listFiles passes every CLI argument to fast-glob, so spectral lint my-json(1).json treats (1) as a glob group, matches nothing, and lints no file. This is not Windows specific; the same happens on Linux. Braces (spec{a,b}.json) fail the same way.

Now an argument that is the path of an existing file is used as is (resolved to an absolute, normalized path like fast-glob returns), and everything else is still expanded as a glob. A file listed both directly and through a glob is only reported once. The check is a synchronous statSync per argument, so the existing call shape of fast-glob stays the same and the current listFiles.test.ts passes unchanged.

Checklist

  • Tests added / updated
  • Docs added / updated (no doc change needed)

Does this PR introduce a breaking change?

  • Yes
  • No

Additional context

New listFiles.jest.test.ts uses real files in a temp directory (no fast-glob mock): spec(1).json, spec[v2].yaml and spec{a,b}.json are found by relative and absolute path, *.json is still expanded, files and globs mixed are listed once, and a missing missing(1).json is still reported as unmatched. With the current listFiles.ts, 3 of these fail (the ( ) and { } cases and the mixed one).

Ran in a node:22 container: yarn build, ESLint on the changed files, and the CLI Jest project (71 passed). I did not run the Karma or test-harness suites, and I have not tried it on Windows.

Every CLI argument went straight to fast-glob, so a file such as
`openapi(1).json` was read as a pattern with a group and never matched
itself, and nothing was linted. Arguments that are the path of an
existing file are now used as is; everything else is still expanded as a
glob.

Fixes stoplightio#2814
@efeesrefinal
Efe İnal (efeesrefinal) requested a review from a team as a code owner November 2, 2026 20:51
@micryc
Michał Rychel (micryc) merged commit bf782be into stoplightio:develop Nov 4, 2026
10 checks passed
@micryc

Copy link
Copy Markdown
Contributor

Hi Efe İnal (@efeesrefinal) thank you for your contribution, this fix will be included in next spectral release 🥳

Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [6.17.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-cli-6.17.0...@stoplight/spectral-cli-6.17.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [1.24.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-core-1.24.0...@stoplight/spectral-core-1.24.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [1.23.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-1.23.0...@stoplight/spectral-rulesets-1.23.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)

### Features

* **repo:** minor release trigger ([#3079](#3079)) ([eabafec](eabafec))
@stoplight-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.17.1 🎉

The release is available on @stoplight/spectral-cli-6.17.1

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spectral fails to lint file on Windows with () in filename

3 participants