From 011adc6984f12d93e59c4349393946aa3b5cc92a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 10 May 2024 07:03:06 -0700 Subject: [PATCH] chore: compatibility with rules_js 2 (#221) --- example/MODULE.bazel | 4 ++-- lint/eslint.bzl | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/example/MODULE.bazel b/example/MODULE.bazel index 7614d224..33fab47b 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -2,8 +2,8 @@ bazel_dep(name = "aspect_rules_lint", version = "0.0.0") bazel_dep(name = "aspect_bazel_lib", version = "2.6.1") -bazel_dep(name = "aspect_rules_js", version = "1.40.0") -bazel_dep(name = "aspect_rules_ts", version = "2.2.0") +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.4") +bazel_dep(name = "aspect_rules_ts", version = "3.0.0-alpha.0") bazel_dep(name = "rules_buf", version = "0.2.0") bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "toolchains_llvm", version = "0.10.3") diff --git a/lint/eslint.bzl b/lint/eslint.bzl index 6c22b30d..8f692744 100644 --- a/lint/eslint.bzl +++ b/lint/eslint.bzl @@ -63,13 +63,25 @@ def _gather_inputs(ctx, srcs): inputs = copy_files_to_bin_actions(ctx, srcs) # Add the config file along with any deps it has on npm packages - inputs.extend(js_lib_helpers.gather_files_from_js_providers( - ctx.attr._config_files + [ctx.attr._workaround_17660, ctx.attr._formatter], - include_transitive_sources = True, - include_declarations = False, - include_npm_linked_packages = True, - ).to_list()) - + if "gather_files_from_js_providers" in dir(js_lib_helpers): + # rules_js 1.x + js_inputs = js_lib_helpers.gather_files_from_js_providers( + ctx.attr._config_files + [ctx.attr._workaround_17660, ctx.attr._formatter], + include_transitive_sources = True, + include_declarations = False, + include_npm_linked_packages = True, + ) + else: + # rules_js 2.x + js_inputs = js_lib_helpers.gather_files_from_js_infos( + ctx.attr._config_files + [ctx.attr._workaround_17660, ctx.attr._formatter], + include_sources = True, + include_transitive_sources = True, + include_types = False, + include_transitive_types = False, + include_npm_sources = True, + ) + inputs.extend(js_inputs.to_list()) return inputs def eslint_action(ctx, executable, srcs, report, exit_code = None):