Skip to content

chore: quote the scratch-vm format-message lint glob so Windows lints… - #753

Open
jonathanmendoza-tx wants to merge 1 commit into
scratchfoundation:developfrom
jonathanmendoza-tx:fix/750-vm-format-message-lint-glob
Open

jonathanmendoza-tx wants to merge 1 commit into
scratchfoundation:developfrom
jonathanmendoza-tx:fix/750-vm-format-message-lint-glob

Conversation

@jonathanmendoza-tx

Copy link
Copy Markdown

… the same files as CI

Resolves

Refs #750 (the format-message lint finding from the comments). One of several fixes for that issue.

Proposed Changes

In packages/scratch-vm/package.json, the lint script changes from

"lint": "eslint && format-message lint src/**/*.js"

to

"lint": "eslint && format-message lint \"src/*/*.js\""

That is the only change. The pattern is now quoted and spelled src/*/*.js, which is the set of files the unquoted src/**/*.js has always expanded to on Linux.

What this does not do: the format-message lint step does not lint src/index.js, src/virtual-machine.js or src/extensions/*/index.js, on any platform, and it never has. It has been that way since the step was added in 2017 (commit 652316c, "Preliminary localization (#777)"). This PR keeps that as is. It does not add or remove coverage.

Reason for Changes

npm run lint in scratch-vm fails on Windows even with LF line endings. The unquoted src/**/*.js is handled differently by each shell:

  • On Linux, npm runs scripts with /bin/sh, which expands ** as a single *. format-message lint therefore receives the 77 files matching src/*/*.js, and CI passes.
  • On Windows, cmd.exe passes the pattern through unexpanded. The CLI's bundled glob then recurses and finds 99 files. The extra 22 are src/index.js, src/virtual-machine.js, the 14 src/extensions/*/index.js files and 6 helper files under src/extensions.

format-message-cli 6.2.4 bundles ESLint 6.8 with ecmaVersion: 2019 hard-coded and no option to change it. Those 22 extra files make it exit 23:

  • 22 x Definition for rule '@stylistic/max-len' was not found in the extension entry points
  • src/virtual-machine.js 809:65 Parsing error: Unexpected token . (optional chaining)

My comment on #750 offered two fixes. The other one was to quote "src/**/*.js" so both platforms lint the deeper files. That is not viable, because the CLI's parser cannot read that syntax; it would make Linux CI fail the same way. Quoting "src/*/*.js" is the conservative option. The 77 files are the same whether the shell expands the pattern or the CLI's glob does (checked both ways: Git Bash ls, which behaves like CI's sh, and the bundled glob 5).

Real coverage of the extension entry points would mean running eslint-plugin-format-message under the repo's ESLint 9 config, which currently enables none of those rules. That is a different and larger change.

Test Coverage

No new test file. This changes a dev script, not package code, so there is nothing for a unit test to exercise. The evidence is the lint runs in packages/scratch-vm on Windows (cmd.exe, Node 24.21.0):

  • Before: format-message lint "src/**/*.js" run directly exits 23, with the 22 @stylistic/max-len errors and the virtual-machine.js parse error described above.
  • After: npm run lint exits 0. ESLint reports 0 errors and 714 warnings. The format-message step reports 0 errors and 11 warnings (literal-pattern and literal-locale, in engine/runtime.js, extension-support/extension-manager.js and util/maybe-format-message.js). The file set is 77.
  • On Linux, the file set is the same 77 as before, so CI behaves as it did.

… the same files as CI

Refs scratchfoundation#750 The quoted single-level pattern gives the same 77 files on both platforms

This branch has not been deployed

No deployments
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.

1 participant