Skip to content

Fix: cross-platform compatibility for npm run lint on Windows#1969

Merged
tyrasd merged 1 commit intoopenstreetmap:mainfrom
piyushduebycse:fix/windows-lint-cross-platform-compatibility
Mar 3, 2026
Merged

Fix: cross-platform compatibility for npm run lint on Windows#1969
tyrasd merged 1 commit intoopenstreetmap:mainfrom
piyushduebycse:fix/windows-lint-cross-platform-compatibility

Conversation

@piyushduebycse
Copy link
Copy Markdown
Contributor

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:

  1. After you submit your PR, the system will create a preview and comment on your PR:

    🍱 Your pull request preview is ready.
    If this is your first contribution to this project, the preview will not happen right away but requires a click from one of the project members. We will do this ASAP.

  2. Once the preview is ready, use it to test your changes.

  3. Now copy the snippet below into a new comment and fill out the blanks.

  4. Now your PR is ready to be reviewed.

## Test-Documentation

### Preview links & Sidebar Screenshots

<!-- Use the preview to find examples, select the feature in question and **copy this link here**.
     Find examples of nodes/areas. Find examples with a lot of tags or very few tags. – Whatever helps to test this thoroughly.
     Add relevant **screenshots** of the sidebar of those examples. -->

<!-- FYI: What we will check:
     - Is the [icon](https://github.com/ideditor/schema-builder/blob/main/ICONS.md) well chosen.
     - Are the fields well-structured and have good labels.
     - Do the dropdowns (etc.) work well and show helpful data. -->

### Search

<!-- **Test the search** of your preset and share relevant **screenshots** here.
     - Test the preset name as search terms.
     - Also test the preset terms and aliases as search terms (if present). -->

### Info-`i`

<!-- **Test the info-i** for your fields and preset and share relevant **screenshots** here.
     The info needs to help mappers understand the preset and when to use it.
     [Learn more…](https://github.com/openstreetmap/id-tagging-schema/blob/main/CONTRIBUTING.md#info-i)
 -->

### Wording

- [ ] American English
- [ ] `name`, `aliases` (if present) use Title Case
- [ ] `terms` (if present) use lower case, sorted A-Z
<!-- Learn more in https://github.com/openstreetmap/id-tagging-schema/blob/main/GUIDELINES.md#2-design-the-preset -->

@tordans
Copy link
Copy Markdown
Collaborator

tordans commented Feb 28, 2026

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
piyushduebycse@fa267ab

@piyushduebycse
Copy link
Copy Markdown
Contributor Author

Hi @tordans Thank you for the quick review and suggestion!

I agree — updating the Prettier config to handle MD and JSON
formatting directly would be a cleaner solution than relying
on the glob pattern workaround.

I'll look into updating the prettier config file to include
proper overrides for MD and JSON files.

Could you point me to the config file you had in mind?
I can see a .prettierrc or prettier.config.js approach —
which would you prefer for this project?

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.
@piyushduebycse piyushduebycse force-pushed the fix/windows-lint-cross-platform-compatibility branch from c9ee4e3 to e840e29 Compare February 28, 2026 16:04
@tyrasd tyrasd merged commit 8156149 into openstreetmap:main Mar 3, 2026
5 checks passed
@tyrasd tyrasd added the ci label Mar 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

🍱 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.

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.

3 participants