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

File matching a parent directory #487

Closed
rondog opened this issue Sep 4, 2018 · 7 comments
Closed

File matching a parent directory #487

rondog opened this issue Sep 4, 2018 · 7 comments

Comments

@rondog
Copy link

rondog commented Sep 4, 2018

I just have a question of file matching and dont even know if this is possible. I have my package.json in a subfolder /docroot/themes/custom/my_theme/package.json and I am using lint-staged to run some precommit git hooks, but I cant get the file pattern matching to work for files that are in parent directories.

I want to search for files in /docroot/modules/custom/**/*.php

I have tried

"docroot/modules/custom/**/*.php": [
  "phpcs --standard=Drupal"
]

"/docroot/modules/custom/**/*.php": [
  "phpcs --standard=Drupal"
]

"modules/custom/**/*.php": [
  "phpcs --standard=Drupal"
]

"../../../modules/custom/**/*.php": [
  "phpcs --standard=Drupal"
]

and I cannot get any of them to match files. My git root is in the /docroot folder. Any ideas?

@kevinhuang28
Copy link

See #425

I had the same issue but settled on using 4.x until @sudo-suhas adds a flag to disable path-inside.

I personally prefer we don't go down this route as this is a rare use-case AFAIK.

I think it has garnered enough interest to warrant this change.

@sudo-suhas
Copy link
Collaborator

I'd be open to a PR which adds a flag for disabling the path-is-inside check which would default to true so that it is backward compatible. @okonet Are we in agreement on this? TBH I still stand by the concerns I had raised in #425 (comment).

@rondog
Copy link
Author

rondog commented Sep 11, 2018

I agree, path-is-inside should default to true. I would need it false for our internal development testing. My use case is using drupal, we distribute a theme file per project that contains the package.json and gulpfile.js that helps us with our sass compiling, but recently I have added husky and lint-staged that runs eslint, stylelint and phpcs to keep our devs using the standards we define.

The one caveat is we usually do custom module development in PHP which I would like to run phpcs against, but those modules live in some parent directories as described in my OP.

To your comment in 425, our use case is the project is always organized the exact same way, but I would say the majority if projects you are correct in it should not assume out of scope organization.

My other option would be to move package.json to webroot, but that would require some initial changes to our gulpfile which is what I was trying to avoid.

@sudo-suhas
Copy link
Collaborator

@rondog
Copy link
Author

rondog commented Sep 20, 2018

awesome, thank you very much!

@rondog
Copy link
Author

rondog commented Sep 20, 2018

@sudo-suhas looking at your note:

Note that patterns like *.js, **/*.js will still only match the project files and not any of the files in parent or sibling directories.

Am I understanding that the change committed in #425 can't use pattern matching in the parent folders? If I am understanding that correctly, that means I would have to define exactly which file to lint? Can you confirm that my original question will work with this commit?

@rondog
Copy link
Author

rondog commented Sep 20, 2018

never mind, I understand your note now. You mean specifically *.js and **/*.js will be project level only. Makes sense. Thank you for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants