Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
chore(bazel): fixup custom eslint test rule after bump to rules_js 2 (#…
Browse files Browse the repository at this point in the history
…63143)

This regressed in https://github.com/sourcegraph/sourcegraph/pull/63022
where the custom `gather_files_from_js_providers` function that was
copied over from rules_js 1.x was including runfiles.

Resolves eslint failures seen in
https://buildkite.com/sourcegraph/sourcegraph/builds/277072#018fe743-abac-44d8-911b-d5a7ed425413
and observed locally:

```
(07:19:15) INFO: From ESLint client/wildcard/wildcard_lib_eslint-output.txt:
  |  
  | Oops! Something went wrong! :(
  |  
  | ESLint: 8.57.0
  |  
  | ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:
  |  
  | npm init @eslint/config
  |  
  | ESLint looked for configuration files in /tmp/bazel-working-directory/__main__/bazel-out/k8-fastbuild/bin/client/wildcard/src/components/Alert and its ancestors. If it found none, it then looked in your home directory.
  |  
  | If you think you already have a configuration file or if you need more help, please stop by the ESLint Discord server: https://eslint.org/chat

```

## Test plan

CI (check test logs)

## Changelog
  • Loading branch information
gregmagolan authored Jun 6, 2024
1 parent c5f0e9b commit 27da789
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions dev/eslint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,26 @@ def eslint_config_and_lint_root(name = "eslint_config", config_deps = [], root_j
def _custom_eslint_impl(ctx):
copied_srcs = copy_files_to_bin_actions(ctx, ctx.files.srcs)

inputs_depset = depset(
input_targets = [ctx.attr.config] + ctx.attr.deps

input_depsets = [depset(
copied_srcs + [ctx.executable.binary],
transitive = [js_lib_helpers.gather_files_from_js_infos(
targets = [ctx.attr.config] + ctx.attr.deps,
include_sources = False,
targets = input_targets,
include_sources = True, # include sources & transitives sources so the eslint config .js files are picked up
include_types = True, # we have to include types because we need to lint the types.
include_transitive_sources = False,
include_transitive_sources = True, # include sources & transitives sources so the eslint config .js files are picked up
include_transitive_types = True, # we have to include types because we need to lint the types.
include_npm_sources = True,
)],
)
)]

# include runfiles in inputs as well so they can be resolved from the execroot
input_depsets.extend([
target[DefaultInfo].default_runfiles.files
for target in input_targets
if DefaultInfo in target and hasattr(target[DefaultInfo], "default_runfiles")
])

runfiles = js_lib_helpers.gather_runfiles(
ctx = ctx,
Expand Down Expand Up @@ -118,7 +127,7 @@ def _custom_eslint_impl(ctx):
# Generate and run a bash script to wrap the binary
ctx.actions.run_shell(
env = env,
inputs = inputs_depset,
inputs = depset([], transitive = input_depsets),
outputs = [report, exit_code_out],
command = command,
arguments = [args],
Expand Down

0 comments on commit 27da789

Please sign in to comment.