Skip to content

Conversation

@KristjanESPERANTO
Copy link
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented Sep 11, 2025

This prevents prettier from failing when lint-staged passes unknown/binary files, making the pre-commit hook more robust.

In concrete terms this could happen, when we, for example, add a new PNG file. Since we rarely do this, it has not been noticed so far.

This is recommended when using asterisk: https://github.com/lint-staged/lint-staged#automatically-fix-code-style-with-prettier-for-any-format-prettier-supports

before

$ npx lint-staged <-- after staging a new PNG file
✔ Backed up original state in git stash (c3247d4b)
✔ Hiding unstaged changes to partially staged files...
⚠ Running tasks for staged files...
  ❯ package.json — 2 files
    ❯ * — 2 files
      ✖ prettier --write [FAILED]
    ↓ *.js — no files
    ↓ *.css — no files
↓ Skipped because of errors from tasks.
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ prettier --write:
[error] No parser could be inferred for file "~/MagicMirror/test.png".
...

after

$ npx lint-staged <-- after staging a new PNG file
✔ Backed up original state in git stash (0c3fe285)
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...

…oid errors on unsupported files

Prevents Prettier from failing when lint-staged passes unknown/binary files, making the pre-commit hook more robust.

This is recommended when using asterisk: https://github.com/lint-staged/lint-staged#automatically-fix-code-style-with-prettier-for-any-format-prettier-supports
@KristjanESPERANTO
Copy link
Collaborator Author

By the way: It's actually somewhat good that we didn't have it before. Otherwise we wouldn't be formatting the njk files now – see #3887 😃

@rejas
Copy link
Collaborator

rejas commented Sep 11, 2025

By the way: It's actually somewhat good that we didn't have it before. Otherwise we wouldn't be formatting the njk files now – see #3887 😃

thats the only downside of this PR: we would need to manually run prettier to find these un-linted file extension

@rejas rejas merged commit d81386f into MagicMirrorOrg:develop Sep 11, 2025
9 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the lint-staged-prettier branch September 11, 2025 16:47
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.

2 participants