Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for some reason validjson does not play well with lint-staged #5

Open
michahell opened this issue Jul 18, 2022 · 2 comments
Open

for some reason validjson does not play well with lint-staged #5

michahell opened this issue Jul 18, 2022 · 2 comments
Assignees

Comments

@michahell
Copy link

michahell commented Jul 18, 2022

And just hangs. I've been running lint-staged both with --verbose and --debug flags, but this does not yield any usable debugging info unfortunately.

My lint-staged config looks like:

export default {
  'src/**/*.ts': 'ng-lint-staged lint:dwp --', // works fine
  '*.json': (filenames) => filenames.map((filename) => `npm run validjson ${filename}`), // or just npx validjson ${filename}
};

This is what I see when 3 .json files are found:

Screenshot 2022-07-18 at 13 29 52

@dotnetCarpenter
Copy link
Owner

Unfortunately I don't have time right now but I will get back to this ASAP

@airtonix
Copy link

airtonix commented Sep 27, 2022

a more pragmatic solution would be to "not try re-using your npm scripts",

the other thing to note is that npm scripts do not accept arguments without decoration (unlike yarn and pnpm), so you need to add -- :

npm run validjson -- ./path/to/filename.json

otherwise npm thinks ./path/to/filename.json is an argument for npm and not what ever the command you have in validjson:

check what happens when you make your lintstaged look like:

export default {
  'src/**/*.ts': 'ng-lint-staged lint:dwp --', // works fine
  '*.json': (filenames) => filenames.map((filename) => `npm run validjson -- ${filename}`), // or just npx validjson ${filename}
};

your comment there indicates that you're just running a tool called validjson, so did you try just having this:

export default {
  'src/**/*.ts': 'ng-lint-staged lint:dwp --', // works fine
  '*.json': 'validjson'
};

lint-staged will pass the filename(s) as argument to validjson.

which brings up another thing: does validjson support this:

$ validjson ./filename.json ./otherfilename.json ./yet/more/filenames.json ./ALLLLLTHEFILESNAMES.json

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

No branches or pull requests

3 participants