Skip to content

Commit

Permalink
Revert "chore: workaround eslint bug (#22)"
Browse files Browse the repository at this point in the history
This reverts commit 73df24f.
  • Loading branch information
alexeagle committed Oct 19, 2023
1 parent a744a59 commit 97b6dc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
10 changes: 1 addition & 9 deletions example/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Demonstrates how to enforce zero-lint-tolerance policy with tests"

load("//tools:lint.bzl", "eslint_test", "flake8_test", "pmd_test")
load("//tools:lint.bzl", "flake8_test", "pmd_test")

flake8_test(
name = "flake8",
Expand All @@ -17,11 +17,3 @@ pmd_test(
# Normally you'd fix the file instead of tagging this test.
tags = ["manual"],
)

eslint_test(
name = "eslint",
srcs = ["//src:ts"],
# Expected to fail based on current content of the file.
# Normally you'd fix the file instead of tagging this test.
tags = ["manual"],
)
2 changes: 0 additions & 2 deletions example/tools/lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ eslint = eslint_aspect(
config = "@@//:eslintrc",
)

eslint_test = make_lint_test(aspect = eslint)

flake8 = flake8_aspect(
binary = "@@//:flake8",
config = "@@//:.flake8",
Expand Down
15 changes: 5 additions & 10 deletions lint/eslint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,22 @@ def eslint_action(ctx, executable, srcs, report, use_exit_code = False):
outputs = [report]

if not use_exit_code:
exit_code_out = ctx.actions.declare_file("_{}.exit_code_out".format(ctx.label.name))
exit_code_out = ctx.actions.declare_file("exit_code_out")
outputs.append(exit_code_out)
env["JS_BINARY__EXIT_CODE_OUTPUT_FILE"] = exit_code_out.path

ctx.actions.run_shell(
inputs = inputs + [executable._eslint],
ctx.actions.run(
inputs = inputs,
outputs = outputs,
# Workaround https://github.com/eslint/eslint/issues/17660
# If the output wasn't created, then put empty file there.
command = "./{eslint} $@; [ -f {output} ] || touch {output}".format(
eslint = executable._eslint.path,
output = report.path,
),
executable = executable._eslint,
arguments = [args],
env = env,
mnemonic = "ESLint",
)

# buildifier: disable=function-docstring
def _eslint_aspect_impl(target, ctx):
if ctx.rule.kind in ["ts_project", "ts_project_rule"]:
if ctx.rule.kind in ["ts_project_rule"]:
report = ctx.actions.declare_file(target.label.name + ".eslint-report.txt")
eslint_action(ctx, ctx.executable, ctx.rule.files.srcs, report, ctx.attr.fail_on_violation)
results = depset([report])
Expand Down

0 comments on commit 97b6dc9

Please sign in to comment.