question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier --write command changed not only staged files.

See original GitHub issue

I have monorepo with lerna. The setup is like here https://github.com/sudo-suhas/lint-staged-multi-pkg/blob/master/package.json

Steps to reproduce

In each folder i have this .linkstagedrc.yml with

linters:
  "src/main/js/**/*.{js,jsx,mjs}":
    - "prettier --write 'src/main/js/**/*.{js,jsx,mjs}'"
    - "git add"

The problem is - i modified only one js file. I do commit, and then in git i see much more files than one. But i want modify only staged file. Can someone help me with that? Thanks.

Environment

  • OS: Macos
  • Node.js: current LTS (10*)
  • lint-staged: latest

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
okonetcommented, Jun 13, 2019

@DonikaV I thought I did:

Instead, remove the glob from arguments since that’s exactly what lint-staged is doing for you under the hood.

You should change it to this:

linters:
  "src/main/js/**/*.{js,jsx,mjs}":
-    - "prettier --write 'src/main/js/**/*.{js,jsx,mjs}'"
+    - "prettier --write"
    - "git add"
0reactions
DonikaVcommented, Jun 14, 2019

@okonet I mean, backend guys are to lazy and they don’t want run npm install. 😄 Ok, I will try to find something in google 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via `git add` before you...
Read more >
How Do I Run Prettier Only on Files That I Want to Commit?
This project contains a script that will run arbitrary npm and shell tasks with a list of staged files as an argument, filtered...
Read more >
Linting Staged Git Files with lint-staged -- newline - Fullstack.io
Anytime a JavaScript file is staged for a commit, lint-staged runs the ESLint linter with the --cache and --fix options. --cache tells ESLint ......
Read more >
Automate and Keep Your Code Consistent Using ESLint ...
In this article, we will automate the process using ESLint, Prettier, Husky, and Lint-Staged to make sure that the code is formatted and ......
Read more >
Enabling Prettier - Rush.js
Note that the Git hook will implicitly filter any files that are not committed to Git, ... This command invokes Prettier to reformat...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found