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

[Bug]: Why is prettier not ignoring node_modules folder? #313

Open
Mamadou888 opened this issue Jul 5, 2024 · 5 comments
Open

[Bug]: Why is prettier not ignoring node_modules folder? #313

Mamadou888 opened this issue Jul 5, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Mamadou888
Copy link

Mamadou888 commented Jul 5, 2024

What happened?

I run bazel run //:format path_to_dir_to_check, where format is an alias to //tools/format:format.check, which subsequently runs the format_multirun, where javascript = ":prettier". The results I receive in the terminal are [error] No matching files. Patterns: path_to_dir_to_check/node_modules/, followed by a list of node_modules it could not pattern match.

What I expect to happen is a successful prettier check of the path_to_dir_to_check with the results of the check.

Version

Development (host) and target OS/architectures: Darwin Kernel Version 22.6.0 arm64

Output of bazel --version: aspect 5.9.36

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved: Typescript, Javascript

How to reproduce

Running `bazel run //:format path_to_dir_to_check` at the root directory.

Any other information?

Example output after running the command

Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //:format (0 packages loaded, 0 targets configured)
Analyzing: target //:format (0 packages loaded, 0 targets configured)
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
INFO: Analyzed target //:format (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tools/format:format up-to-date:
  bazel-bin/tools/format/format.bash
INFO: Elapsed time: 0.137s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/tools/format/format.bash path_to_dir_to_check
[error] No matching files. Patterns: apps/app_one_name/node_modules/@jest/core/node_modules/chalk/node_modules/ansi-styles/index.js path_to_dir_to_check/node_modules/@jest/core/node_modules/supports-color/index.js path_to_dir_to_check/node_modules/@jest/core/node_modules/supports-color/browser.js path_to_dir_to_check/node_modules/@jest/core/node_modules/pretty-format/build/types.js path_to_dir_to_check/node_modules/@jest/core/node_modules/pretty-format/build/plugins/ReactTestComponent.js path_to_dir_to_check/node_modules/@jest/core/node_modules/pretty-format/build/plugins/ReactElement.js
@Mamadou888 Mamadou888 added the bug Something isn't working label Jul 5, 2024
@alexeagle
Copy link
Member

What does prettier do when you run it outside of Bazel? I would expect an exclude for node_modules to be in the prettierrc file.

@jmeekhof
Copy link
Contributor

jmeekhof commented Aug 9, 2024

@alexeagle I work with @Mamadou888. We do not currently have an explicit ignore for node_modules in our prettierrc file. It hadn't occurred to add it, as the prettier documentation states that node_modules is ignored by default. We can of course add that to our prettierrc file.

@alexeagle
Copy link
Member

Maybe you were missing a .gitignore for the node_modules folder? I'm not able to reproduce this in the example in this repo, which doesn't have a .prettierrc.
Note that the format tool runs this ls-files function which asks git what files exist, then only formats those.

@Mamadou888
Copy link
Author

@alexeagle prettier runs just fine when we run it outside of Bazel (it ignores the node_modules directory). As far as I'm aware, I do not see anyway to add an explicit ignore to a prettierrc file but we did add it to our prettierignore file and are still seeing the same issues. We are also ignoring the node_modules folder in .gitignore.

@alexeagle
Copy link
Member

@Mamadou888 hm, can you find a way to repro? I'm not seeing the same thing. Ideally using the example in this repo will save you time instead of making a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants