Fix: cross-platform compatibility for npm run lint on Windows#1969
Conversation
|
We could also look into updating the config to use the regular formatting for MD and JSON for everything else. AFAIK prettiest should support this since |
|
Hi @tordans Thank you for the quick review and suggestion! I agree — updating the Prettier config to handle MD and JSON I'll look into updating the prettier config file to include Could you point me to the config file you had in mind? I'll push the update shortly! |
…ignore The `npm run lint` and `npm run lint:fix` commands were failing on Windows due to the use of single quotes around the glob pattern in `package.json`: "lint": "prettier --check 'data/**/!(*.md)'" On Windows (cmd.exe/PowerShell), single quotes are not treated as string delimiters, causing Prettier to receive literal quotes and throw a "No files matching the pattern" error. This broke the automated build process entirely. Instead of just fixing the quotes, refactored the Prettier configuration for a cleaner solution: - Added `*.md` to `.prettierignore` to natively enforce excluding markdown files - Simplified `package.json` scripts to target the `data` directory generically (`prettier --check data` and `prettier --write data`) This ensures cross-platform consistency by avoiding complex, error-prone shell glob exclusions within npm scripts outright.
c9ee4e3 to
e840e29
Compare
|
🍱 Your pull request preview is ready Please use this preview to check your changes. Ideally use the test documentation template and document your test results by commenting on the PR. This will speed up the review process for everyone. FYI, once this PR is merged, you can use the iD Editor Preview to test your changes in interaction with all other changes. |
The original lint script used single quotes around the glob pattern:
prettier --check 'data/**/!(*.md)'
Single quotes work on macOS/Linux but fail on Windows (cmd.exe/PowerShell) because cmd.exe passes literal quotes to Prettier, causing a 'No files matching pattern' error and breaking npm run build entirely.
Fixed by replacing single quotes with escaped double quotes:
prettier --check "data/**/!(*.md)"
Also updated lint:fix to use the same pattern for consistency and to correctly exclude markdown files (was previously using prettier --write data which formatted ALL files including .md)
Description, Motivation & Context
Related issues
Links and data
Relevant OSM Wiki links:
Relevant tag usage stats:
Checklist and Test-Documentation Template
Read on to get your PR merged faster…
Follow these steps to test your PR yourself and make it a lot easier and faster for maintainers to check and approve it.
This is how it works:
After you submit your PR, the system will create a preview and comment on your PR:
Once the preview is ready, use it to test your changes.
Now copy the snippet below into a new comment and fill out the blanks.
Now your PR is ready to be reviewed.