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.

Question: Is there a way to use lint-staged with git submodules?

See original GitHub issue

We have a folder that is shared between some of our project. We have made it into its own git repo and added it as a submodule to the projects. The configurations of the project are always in sync (or they should be), and we treat the submodule as a simple folder.

The problem is that lint-staged won’t report the changed files inside the submodule to our code formatter. This has made us run a full reformat of the whole code base on each commit.

Is there a work around this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Shayan-Tocommented, Jul 4, 2020

Okay, it seems like that thanks to your guidance, I have found a solution to my problem. I can run this:

npx lint-staged && git submodule foreach --recursive npx lint-staged
0reactions
Shayan-Tocommented, Jul 1, 2020

Just a slightly unrelated question. I have tried to put this into an npm script, but as I am running Windows, I got this error:

D:/Program_Files/Git/mingw64/libexec/git-core\git-submodule: line 22: .: git-sh-setup: file not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! delijan@0.1.0 format:staged: `lint-staged && git submodule foreach --recursive npx lint-staged`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the delijan@0.1.0 format:staged script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Shayan\AppData\Roaming\npm-cache\_logs\2020-07-01T19_09_40_482Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! delijan@0.1.0 format: `git add --all && npm run format:staged && git reset -q`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the delijan@0.1.0 format script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Shayan\AppData\Roaming\npm-cache\_logs\2020-07-01T19_09_40_512Z-debug.log

Have you got any experience with this? (I think that the problem is probably that git scripts are written in bash, and npm on windows works in cmd environment.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Question: Is there a way to use lint-staged with git submodules?
We have a folder that is shared between some of our project. We have made it into its own git repo and added...
Read more >
Using Husky Git Hooks and Lint-Staged With Nested Folders
cd into the directory with your package. · Install husky and lint-staged: · Add a “prepare” npm script to your package. · Run...
Read more >
Pre commit hook checks for source lint (not staged)
It will only lint the staged files, which is really efficient. That means that it would force the developer in your example to...
Read more >
gitmodules Documentation - Git
Defines the default update procedure for the named submodule, i.e. how the submodule is updated by the git submodule update command in the...
Read more >
Linting Staged Git Files with lint-staged -- newline - Fullstack.io
This lets you continue working on the application code without any interruptions, and once you are done with the code, you can stage...
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