Skip to content

Commit

Permalink
Bump to Bazel 7.3.1
Browse files Browse the repository at this point in the history
And regenerate docs, since we're bumping stardoc too.
  • Loading branch information
shs96c committed Aug 28, 2024
1 parent 8f32863 commit a5711a2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.0
7.3.1
5 changes: 3 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module(
name = "apple_rules_lint",
version = "0.3.2",
version = "0.4.0",
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "stardoc", version = "0.5.3", repo_name = "io_bazel_stardoc", dev_dependency = True)

bazel_dep(name = "stardoc", version = "0.7.0", dev_dependency = True, repo_name = "io_bazel_stardoc")

linter = use_extension("//lint:extensions.bzl", "linter")
use_repo(linter, "apple_linters")
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ Alternatively, using Bzlmod:

```py
# MODULE.bazel
bazel_dep(name = "apple_rules_lint", version = "0.1.1")
bazel_dep(name = "apple_rules_lint", version = "0.4.0")

linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter")
linter.configure(name = "java-checkstyle", config = "//your:checkstyle-config")
use_repo(linter, "apple_linters")
```

You may override specific lint configurations on a per-package basis by:
Expand Down
15 changes: 0 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,3 @@ lint_deps()
load("//lint:setup.bzl", "lint_setup")

lint_setup()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_stardoc",
sha256 = "3fd8fec4ddec3c670bd810904e2e33170bedfe12f90adf943508184be458c8bb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz",
],
)

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()
13 changes: 8 additions & 5 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
## LinterInfo

<pre>
load("@apple_rules_lint//lint:defs.bzl", "LinterInfo")

LinterInfo(<a href="#LinterInfo-language">language</a>, <a href="#LinterInfo-name">name</a>)
</pre>



**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="LinterInfo-language"></a>language | The language or kind of thing we are linting. |
Expand All @@ -26,6 +25,8 @@ LinterInfo(<a href="#LinterInfo-language">language</a>, <a href="#LinterInfo-nam
## get_lint_config

<pre>
load("@apple_rules_lint//lint:defs.bzl", "get_lint_config")

get_lint_config(<a href="#get_lint_config-linter_name">linter_name</a>, <a href="#get_lint_config-tags">tags</a>)
</pre>

Expand All @@ -42,15 +43,17 @@ for specific rules.

| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="get_lint_config-linter_name"></a>linter_name | The "well known" name of the linter (eg. <code>java-checkstyle</code>) | none |
| <a id="get_lint_config-tags"></a>tags | The tags from the rule (eg. <code>ctx.attr.tags</code>) | none |
| <a id="get_lint_config-linter_name"></a>linter_name | The "well known" name of the linter (eg. `java-checkstyle`) | none |
| <a id="get_lint_config-tags"></a>tags | The tags from the rule (eg. `ctx.attr.tags`) | none |


<a id="package_lint_config"></a>

## package_lint_config

<pre>
load("@apple_rules_lint//lint:defs.bzl", "package_lint_config")

package_lint_config(<a href="#package_lint_config-linters">linters</a>)
</pre>

Expand Down
18 changes: 18 additions & 0 deletions example/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module(
name = "lint_example",
)

bazel_dep(name = "apple_rules_lint", version = "0.0.0")
local_path_override(
module_name = "apple_rules_lint",
path = "..",
)

linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter")
linter.register(name = "lint_example")

#linter.configure(
# name = "lint_example",
# config = "//:default_config",
#)
use_repo(linter, "apple_linters")
13 changes: 12 additions & 1 deletion lint/private/get_lint_config.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
load("@apple_linters//:defs.bzl", "configured_linters")
load("//lint/private:package_lint_config.bzl", "OVERRIDE_RULE_NAME")

def get_repo_name():
repo_name = getattr(native, "repo_name", None)
if not repo_name:
# We're using an old Bazel version (5.x), so this will be fine
return native.repository_name()

# Are we using `bzlmod` or not?
is_bzlmod = str(Label("@does_not_exist_i_promise//:BUILD.bazel")).startswith("@@")
prefix = "@@" if is_bzlmod else "@"
return prefix + repo_name()

def get_lint_config(linter_name, tags):
"""Gets the lint config for a particular linter from the tags of a rule.
Expand All @@ -25,7 +36,7 @@ def get_lint_config(linter_name, tags):
return None

if native.existing_rule("%s_%s" % (OVERRIDE_RULE_NAME, linter_name)) != None:
return Label("%s//%s:%s_%s" % (native.repository_name(), native.package_name(), OVERRIDE_RULE_NAME, linter_name))
return Label("%s//%s:%s_%s" % (get_repo_name(), native.package_name(), OVERRIDE_RULE_NAME, linter_name))

if linter_name in configured_linters:
return Label("@apple_linters//:%s_%s" % (OVERRIDE_RULE_NAME, linter_name))
Expand Down

0 comments on commit a5711a2

Please sign in to comment.