Fresh Windows checkout: lint, the root build and `scratch-gui` unit tests fail without any code changes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- eslint, javascript, node.js
- Domain
- build-system, devtools, testing
Research direction
Start with the root .gitattributes and packages/scratch-gui/package.json; the issue identifies the three failing commands and their causes. Check the existing *.js line-ending rule, the neighboring build scripts, and the quoted Jest patterns in scratch-storage. Done when a fresh Windows checkout passes lint and the root build, and test:unit runs only the unit suites.
Written by the indexing model from the issue text.
Description
Hello! Windows-native developer here. I found a few issues that come up when using Windows and they are small and easy changes that would allow better cross-os developer collaboration. None of these issues affect scratch users or CI, and each is a one-line fix. I searched issues and PRs and found no prior work or reports on these. Details below:
Expected Behavior
On a fresh clone of develop with npm ci done, a Windows contributor can run the same commands
as on Linux or macOS with the same results:
npm run lint/npm run test:lintpasses in every package.npm run buildfrom the repo root builds all eight packages.npm run test:unitinpackages/scratch-guiruns only the unit suites.
Actual Behavior
Three independent things go wrong, none of which involve a code change. CI is unaffected because
it runs on Linux. Each has a one-line cause and a workaround.
1. Lint fails in seven of eight packages because .mjs files check out with CRLF
With Git for Windows' default core.autocrlf=true, every eslint.config.mjs, typedoc.config.mjs,
prettier.config.mjs and scripts/prepare.mjs is checked out with CRLF. ESLint then reports one
error per line in each of them:
1:59 error Expected linebreaks to be 'LF' but found 'CRLF' @stylistic/linebreak-style
2:45 error Expected linebreaks to be 'LF' but found 'CRLF' @stylistic/linebreak-style
...
and in task-herder Prettier fails the same way:
[warn] eslint.config.mjs
[warn] prettier.config.mjs
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.
Error counts on an untouched checkout: scratch-gui 241, scratch-paint 72, scratch-vm 56,
scratch-render 53, scratch-svg-renderer 52, scratch-storage 47. Only scratch-media-lib-scripts
passes, because it has no .mjs files.
Cause: .gitattributes sets text eol=lf for *.js, *.jsx, *.ts, *.tsx, *.json and many
other types, but has no entry for *.mjs. git check-attr eol -- packages/scratch-vm/eslint.config.mjs
reports eol: unspecified, so the 14 tracked .mjs files follow core.autocrlf instead.
Workaround: git config core.autocrlf false in the clone and re-checkout.
2. npm run build exits 1 at scratch-gui
The seven other packages build, then:
> @scratch/[email protected] build:dev
> BUILD_TYPE=dev webpack
'BUILD_TYPE' is not recognized as an internal or external command,
operable program or batch file.
Cause: packages/scratch-gui/package.json has "build:dev": "BUILD_TYPE=dev webpack". That is
POSIX shell syntax, and npm runs scripts through cmd.exe on Windows regardless of the calling
shell. The neighbouring build:dist and build:dist-standalone scripts already use cross-env
for the same variable, and cross-env is already in scratch-gui's devDependencies.
Workaround: npm run build --workspace=packages/scratch-gui --script-shell="C:\Program Files\Git\bin\bash.exe".
3. scratch-gui npm run test:unit runs every suite
Jest rejects the path pattern and falls back to running everything:
Invalid testPattern test[\\\]unit supplied. Running all tests instead.
The unit, integration, Playwright and smoke suites then run together. Without a gui build and
browsers that shows as 21 failed suites (127 failed, 328 passed of 463 tests) instead of the 50
unit suites passing. test:integration and test:smoke use the same pattern shape.
Cause: the patterns in packages/scratch-gui/package.json are passed unquoted:
"test:unit": "cross-env JEST_JUNIT_OUTPUT_NAME=unit-tests-results.xml jest test[\\\\/]unit",
"test:integration": "cross-env JEST_JUNIT_OUTPUT_NAME=integration-tests-results.xml jest --maxWorkers=4 test[\\\\/]integration",
"test:smoke": "jest --runInBand test[\\\\/]smoke",
Through cmd.exe the pattern reaches Jest as an invalid regex. scratch-storage passes the same
kind of pattern in double quotes (jest "test[\\\\/]unit") and works on Windows. The scratch-gui
README's advice to use cmd.exe instead of Git Bash makes no difference, because npm runs the
script through cmd.exe either way; the result is identical from PowerShell and Git Bash.
Workaround: npx jest test/unit runs exactly the unit suites (50 suites, 328 passed, 1 skipped,
about 10 seconds).
Steps to Reproduce
- On Windows with Git for Windows defaults (
core.autocrlf=true), clonescratch-editor, check
outdevelop, runnpm cifrom the repo root. cd packages/scratch-vmand runnpm run lint: see the@stylistic/linebreak-styleerrors.
Any package other thanscratch-media-lib-scriptsshows the same.- From the repo root run
npm run build: see'BUILD_TYPE' is not recognizedand exit code 1
after the other seven packages build. cd packages/scratch-guiand runnpm run test:unit: seeInvalid testPattern ... Running all tests instead.followed by integration, Playwright and smoke suites running. Compare with
npx jest test/unit, which runs only the unit suites and passes.
System Details
- Windows 10 Pro 22H2 (build 19045); identical results from PowerShell 5.1 and Git Bash
- Git for Windows with
core.autocrlf=true; npmscript-shellunset (scripts run incmd.exe) - Node v24.21.0, npm 12.0.2, Jest 29.7.0
scratch-editordevelopat 7b5559d29 (v15.3.0), freshnpm ci
Notes
Each cause has a small, self-contained fix, and I would be glad to open them as two separate PRs
referencing this issue so each is easy to review:
- Add
*.mjs text eol=lfto.gitattributes. The committed blobs are already LF, so only
checkout behaviour changes. Existing Windows clones need a re-checkout
(git rm --cached -r . && git reset --hard). "build:dev": "cross-env BUILD_TYPE=dev webpack", matching the two neighbouring scripts.- Either quote the three Jest patterns as
scratch-storagedoes, or use plaintest/unit,
test/integration,test/smoke, which Jest matches on every platform because it normalises
separators before applying the regex.
Bugs 2 and 3 are collapsed into one commit since they touch the same file.
- Dominant language
- JavaScript
- Stars
- 310
- Forks
- 299
- Avg merge
- 19h 41m
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scratchfoundation/scratch-editor
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
scratchfoundation/scratch-editor#754 ·
Maintainers usually reply within 1 day
-
spork
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
scratchfoundation/scratch-editor#646 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
scratchfoundation/scratch-editor#406 ·
Maintainers usually reply within 1 day
-
Monitor context menus shrink the EditorPossibly taken @mxmou claimed this 3 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 50/100
scratchfoundation/scratch-editor#744 · 6 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Large SVG costumes exhaust memory during playback on low-RAM devices — no texture budget or warningOpen
Difficulty 5/5 Over a week Newbie friendliness 35/100
scratchfoundation/scratch-editor#722 ·
Maintainers usually reply within 1 day
All issues in scratchfoundation/scratch-editor
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 96/100
google/site-kit-wp#14102 ·
Maintainers usually reply within 2 days
-
area:growth priority:P1 type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tecnologiasantos/bogoboom#66 ·
Maintainers usually reply within 1 day
-
desktop docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
npm/write-file-atomic#245 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ktwu01/benchmark-radar#1181 ·
Maintainers usually reply within 1 day