Skip to content

Commit

Permalink
chore: delete the Aspect CLI plugin (#26)
Browse files Browse the repository at this point in the history
* chore: delete the Aspect CLI plugin

With that code removed, we're okay with licensing this as Apache 2.0

* Update linting.md

* Update BUILD.bazel
  • Loading branch information
alexeagle authored Oct 19, 2023
1 parent 80a1458 commit 5ebb836
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 1,011 deletions.
53 changes: 2 additions & 51 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,60 +1,11 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load("//release:release.bzl", "local_plugin")
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")

gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//bzl",
],
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
)

gazelle(
name = "gazelle",
gazelle = "gazelle_bin",
)

# gazelle:prefix github.com/aspect-build/rules_lint
# Buildozer ships with BUILD files but doesn't follow our naming convention
# gazelle:resolve go github.com/bazelbuild/buildtools/edit @com_github_bazelbuild_buildtools//edit:go_default_library
go_library(
name = "lint-plugin_lib",
srcs = ["plugin.go"],
importpath = "github.com/aspect-build/rules_lint",
visibility = ["//:__subpackages__"],
deps = [
"@build_aspect_cli//bazel/command_line",
"@build_aspect_cli//pkg/aspecterrors",
"@build_aspect_cli//pkg/bazel",
"@build_aspect_cli//pkg/ioutils",
"@build_aspect_cli//pkg/plugin/sdk/v1alpha4/config",
"@build_aspect_cli//pkg/plugin/sdk/v1alpha4/plugin",
"@com_github_fatih_color//:color",
"@com_github_hashicorp_go_plugin//:go-plugin",
"@in_gopkg_yaml_v2//:yaml_v2",
],
)

# Only used for local development.
# Release binaries are created by the target in /release
go_binary(
name = "lint-plugin",
embed = [":lint-plugin_lib"],
visibility = ["//visibility:public"],
)

# TODO: add a Go unit test of the plugin logic.
# For now we just test that it builds.
build_test(
name = "test",
targets = [":lint-plugin"],
)

# Build this target to copy the plugin to bazel-bin/plugin and checksum it.
# Referenced by the .aspect/cli/config.yaml in the `From:` line.
local_plugin(
name = "dev",
binary = ":lint-plugin",
path = "plugin",
)
16 changes: 0 additions & 16 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,3 @@ bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf"
bazel_dep(name = "rules_go", version = "0.39.1", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.31.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps", dev_dependency = True)
go_deps.from_file(go_mod = "//:go.mod")
go_deps.gazelle_override(
build_file_generation = "on",
path = "github.com/bazelbuild/bazelisk",
)

# All *direct* Go dependencies of the module have to be listed explicitly.
use_repo(
go_deps,
"build_aspect_cli",
"com_github_fatih_color",
"com_github_hashicorp_go_plugin",
"in_gopkg_yaml_v2",
)
13 changes: 4 additions & 9 deletions docs/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ in the lint runner.
If you use the Aspect CLI, then include a block like the following in `.aspect/cli/config.yaml`:

```yaml
plugins:
- name: lint-plugin
from: rules_lint
properties:
lint_aspects:
- //tools:lint.bzl%eslint
lint:
aspects:
- //tools:lint.bzl%eslint
```
If you don't use Aspect CLI, you can put these in some other wrapper like a shell script that runs the linter aspects over the requested targets.
Expand All @@ -35,9 +32,7 @@ See the `lint.sh` script in the `example/` folder.

### 1. Warnings in the terminal with `bazel lint`

This ruleset provides an Aspect CLI plugin, so it can register the missing 'lint' command.

Users just type `bazel lint //path/to:targets`.
Aspect CLI adds the missing 'lint' command, so users just type `bazel lint //path/to:targets`.

Reports are then written to the terminal.

Expand Down
17 changes: 6 additions & 11 deletions example/.aspect/cli/config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
plugins:
- name: lint-plugin
# For this to work, you must first `bazel build dev` in the root of the repo
from: ../bazel-bin/plugin
log_level: warn
properties:
lint_aspects:
- //tools:lint.bzl%eslint
- //tools:lint.bzl%buf
- //tools:lint.bzl%flake8
- //tools:lint.bzl%pmd
lint:
aspects:
- //tools:lint.bzl%eslint
- //tools:lint.bzl%buf
- //tools:lint.bzl%flake8
- //tools:lint.bzl%pmd
9 changes: 2 additions & 7 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ It contains sources in multiple languages.

### With Aspect CLI

We haven't published the plugin from this repo yet, so build it from source:
Run `bazel lint src:all`

```bash
cd ..
bazel build dev
```

Then you can run `bazel lint src:all`
> If the 'lint' command isn't found, make sure you have a new enough version of Aspect CLI.
### Without Aspect CLI

Expand Down
2 changes: 1 addition & 1 deletion example/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Shows an end-to-end workflow for linting without failing the build.
# This is meant to mimic the behavior of the `bazel lint` command that you'd have
# by using the Aspect CLI with the plugin in this repository.
# by using the Aspect CLI.
#
# We recommend using Aspect CLI instead!
set -o errexit -o pipefail -o nounset
Expand Down
48 changes: 0 additions & 48 deletions go.mod

This file was deleted.

Loading

0 comments on commit 5ebb836

Please sign in to comment.