aspect-build / rules_lint

Run static analysis tools with Bazel
Apache License 2.0
73 stars 40 forks source link

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

Open Mamadou888 opened 2 months ago

Mamadou888 commented 2 months ago

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
alexeagle commented 1 month ago

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 commented 4 weeks ago

@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 commented 2 weeks ago

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.