Skip to content

Commit

Permalink
chore: minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Sep 27, 2023
1 parent 1754383 commit 0d7edfc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
22 changes: 4 additions & 18 deletions e2e/eslint/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:eslint/package_json.bzl", eslint_bin = "bin")

package(default_visibility = ["//visibility:public"])

npm_link_all_packages(name = "node_modules")

eslint_bin.eslint_binary(name = "eslint")

js_library(
name = "eslintrc",
srcs = [".eslintrc.cjs"],
Expand All @@ -14,19 +16,3 @@ js_library(
":node_modules/@typescript-eslint/parser",
],
)

# Reach into the node_modules to find the entry points
directory_path(
name = "eslint_entry",
tags = ["manual"],
directory = ":node_modules/eslint/dir",
path = "bin/eslint.js",
)

js_binary(
name = "eslint",
data = [
":node_modules/eslint",
],
entry_point = "eslint_entry",
)
4 changes: 4 additions & 0 deletions e2e/eslint/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Run eslint

The `simple/` folder contains a ts_project target that we want to lint.

This folder simply follows the instructions at https://typescript-eslint.io/getting-started
to create the ESLint setup.
1 change: 1 addition & 0 deletions e2e/eslint/simple/file.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// this is a linting violation
const a: string = "a";
console.log(a);
4 changes: 2 additions & 2 deletions lint/eslint.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Public API re-exports"

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_file_to_bin_action", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_files_to_bin_actions")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")

def _eslint_action(ctx, executable, srcs, report, use_exit_code = False):
Expand Down Expand Up @@ -32,14 +32,14 @@ def _eslint_action(ctx, executable, srcs, report, use_exit_code = False):
env = {"BAZEL_BINDIR": ctx.bin_dir.path}

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_file],
include_transitive_sources = True,
include_declarations = False,
include_npm_linked_packages = True,
).to_list())

inputs.append(copy_file_to_bin_action(ctx, ctx.file._config_file))
outputs = [report]

if not use_exit_code:
Expand Down

0 comments on commit 0d7edfc

Please sign in to comment.