[
  {
    "path": ".bazelignore",
    "content": "example/\ntests/bcr\n"
  },
  {
    "path": ".bazelversion",
    "content": "7.3.1\n"
  },
  {
    "path": ".gitignore",
    "content": ".ijwb/\n*~\n*.swp\n**/bazel-*\n**/MODULE.bazel.lock\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "\n# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, religion, or sexual identity\nand orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n## Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n* Demonstrating empathy and kindness toward other people\n* Being respectful of differing opinions, viewpoints, and experiences\n* Giving and gracefully accepting constructive feedback\n* Accepting responsibility and apologizing to those affected by our mistakes,\n  and learning from the experience\n* Focusing on what is best not just for us as individuals, but for the\n  overall community\n\nExamples of unacceptable behavior include:\n\n* The use of sexualized language or imagery, and sexual attention or\n  advances of any kind\n* Trolling, insulting or derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or email\n  address, without their explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n## Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official e-mail address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at\n[INSERT CONTACT METHOD].\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n## Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n### 2. Warning\n\n**Community Impact**: A violation through a single incident or series\nof actions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or\npermanent ban.\n\n### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior,  harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within\nthe community.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.0, available at\nhttps://www.contributor-covenant.org/version/2/0/code_of_conduct.html.\n\nCommunity Impact Guidelines were inspired by [Mozilla's code of conduct\nenforcement ladder](https://github.com/mozilla/diversity).\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see the FAQ at\nhttps://www.contributor-covenant.org/faq. Translations are available at\nhttps://www.contributor-covenant.org/translations.\n\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2020 Software Freedom Conservancy (SFC)\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "MODULE.bazel",
    "content": "module(\n    name = \"apple_rules_lint\",\n    version = \"0.4.0\",\n)\n\nbazel_dep(name = \"bazel_skylib\", version = \"1.7.1\")\n\nbazel_dep(name = \"stardoc\", version = \"0.7.0\", dev_dependency = True, repo_name = \"io_bazel_stardoc\")\n\nlinter = use_extension(\"//lint:extensions.bzl\", \"linter\")\nuse_repo(linter, \"apple_linters\")\n"
  },
  {
    "path": "README.md",
    "content": "# apple_rules_lint\nA linting framework for Bazel\n\n## Users\n\nYou must load and configure the linting framework before anything else.\nThis is because later rulesets that depend on the linting framework will\nattempt to ensure that linters are configured by registering no-op\nimplementations of lint configs. You can do this by:\n\n```py\n# WORKSPACE\n\nload(\"@apple_rules_lint//lint:repositories.bzl\", \"lint_deps\")\n\nlint_deps()\n\nload(\"@apple_rules_lint//lint:setup.bzl\", \"lint_setup\")\n\nlint_setup({\n    \"java-checkstyle\": \"//your:checkstyle-config\",\n})\n```\n\nAlternatively, using Bzlmod:\n\n```py\n# MODULE.bazel\nbazel_dep(name = \"apple_rules_lint\", version = \"0.4.0\")\n\nlinter = use_extension(\"@apple_rules_lint//lint:extensions.bzl\", \"linter\")\nlinter.configure(name = \"java-checkstyle\", config = \"//your:checkstyle-config\")\nuse_repo(linter, \"apple_linters\")\n```\n\nYou may override specific lint configurations on a per-package basis by:\n\n```py\n# BUILD.bazel\n\nload(\"@apple_rules_lint//lint:defs.bzl\", \"package_lint_config\")\n\npackage_lint_config({\n    \"java-checkstyle\": \":alternative-checkstyle-config\",\n})\n```\n\n### Missing `@@apple_linters` error\n\nBazel may report an error like this:\n```\nERROR: Failed to load Starlark extension '@@apple_linters//:defs.bzl'.\nCycle in the workspace file detected. This indicates that a repository is used prior to being defined.\nThe following chain of repository dependencies lead to the missing definition.\n - @@apple_linters\nThis could either mean you have to add the '@@apple_linters' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.\n```\n\nThe `@apple_linters` repository is defined when `lint_setup` is called. You'll need to figure out where `load(\"@apple_linters//:defs.bzl, ...)` is getting called, and modify your build to ensure that `lint_setup` is called _before_ linting is loaded.\n\n\n### API Documentation\n\nCan be found in [the api docs](api.md)\n\n## Ruleset Authors\n\n### WORKSPACE setup\n\nTo add linter support to your repo, add this to...\n\n```py\n# repositories.bzl\nload(\"@apple_rules_lint//lint:repositories.bzl\", \"lint_deps\")\n\nlint_deps()\n```\n\nThen add this to...\n\n```py\n# setup.bzl\nload(\"@apple_rules_lint//lint:setup.bzl\", \"ruleset_lint_setup\")\n\nruleset_lint_setup()\n```\n\n### Bzlmod setup\n\nAdd:\n\n```py\n# MODULE.bazel\n\nbazel_dep(name = \"apple_rules_lint\", version = \"0.1.1\")\n\nlinter = use_extension(\"@apple_rules_lint//lint:extensions.bzl\", \"linter\")\nlinter.register(name = \"java-checkstyle\")\n```\n\n### Getting the configured config for a linter\n\nTo obtain the currently configured config for a ruleset, use:\n\n```py\n# your_rules.bzl\n\nload(\"@apple_rules_lint//lint:defs.bzl\", \"get_lint_config\")\n\nconfig = get_lint_config(\"java-checkstyle\", tags)\nif config != None:\n    # set up lint targets\n    pass\n```\n\nWhere `tags` are the tags of the rule to check.\n\n\n# Integrating `apple_rules_lint` With Your Rulesets\n\nFor the sake of this example, we'll show how `apple_rules_lint` is\nintegrated with the Selenium project, but the same process can be\nfollowed for any linter:\n\n1. Wrap the linter with a `_test` rule, so you can run them with bazel\n   test. In Selenium, this is the\n   [spotbugs_test](https://github.com/SeleniumHQ/selenium/blob/selenium-4.0.0-beta-1/java/private/spotbugs.bzl)\n\n2. It is recommended, but not required, that your test return a `LinterInfo`\n   so that other tooling can detect whether this is a lint test.\n\n3. Create a config rule or a marker rule of some sort. For example,\n   [spotbugs_config](https://github.com/SeleniumHQ/selenium/blob/selenium-4.0.0-beta-1/java/private/spotbugs_config.bzl)\n\n4. Pick a \"well known\" name: `lang-tool` seems to work well (such as\n   `java-spotbugs`, but you might have `go-gofmt` or `py-black`)\n\n5. Create a macro that uses\n   [get_lint_config](./api.md#get_lint_config) to look up the config\n   for you. If that's present, create a new instance of your test\n   rule. You can see this in action\n   [here](https://github.com/SeleniumHQ/selenium/blob/selenium-4.0.0-beta-1/java/private/library.bzl).\n\n6. As you write code, make sure your macro is called. If you're a\n   ruleset author, this can be as lightweight as exporting the macro created\n   above as the default way to call your rules.\n\n7. ...\n\n8. Profit!\n\nUsers can then use the \"well known\" name to point to an instance of\nthe config rule in their `WORKSPACE` files:\n\n```starlark\nlint_setup({\n    \"java-spotbugs\": \"//java:spotbugs-config\",\n})\n```\n"
  },
  {
    "path": "RELEASE.md",
    "content": "# Releasing `apple_rules_lint`\n\n1. Update the `MODULE.bazel` and bump the version number to whatever the \n   next release will be.\n2. `git tag \"${TAG}\"` where `${TAG}` is whatever the next release will be.\n3. `./scripts/build-release-artifacts`\n4. Create a new release on GitHub, and attach the artifacts generated by the \n   previous step.\n5. Update the BCR with the new release\n6. ...\n7. Profit!\n"
  },
  {
    "path": "WORKSPACE",
    "content": "workspace(name = \"apple_rules_lint\")\n\nload(\"//lint:repositories.bzl\", \"lint_deps\")\n\nlint_deps()\n\nload(\"//lint:setup.bzl\", \"lint_setup\")\n\nlint_setup()\n"
  },
  {
    "path": "WORKSPACE.bzlmod",
    "content": "workspace(name = \"apple_rules_lint\")\n"
  },
  {
    "path": "api.md",
    "content": "<!-- Generated with Stardoc: http://skydoc.bazel.build -->\n\n\n\n<a id=\"LinterInfo\"></a>\n\n## LinterInfo\n\n<pre>\nload(\"@apple_rules_lint//lint:defs.bzl\", \"LinterInfo\")\n\nLinterInfo(<a href=\"#LinterInfo-language\">language</a>, <a href=\"#LinterInfo-name\">name</a>)\n</pre>\n\n**FIELDS**\n\n| Name  | Description |\n| :------------- | :------------- |\n| <a id=\"LinterInfo-language\"></a>language |  The language or kind of thing we are linting.    |\n| <a id=\"LinterInfo-name\"></a>name |  The name of the linter    |\n\n\n<a id=\"get_lint_config\"></a>\n\n## get_lint_config\n\n<pre>\nload(\"@apple_rules_lint//lint:defs.bzl\", \"get_lint_config\")\n\nget_lint_config(<a href=\"#get_lint_config-linter_name\">linter_name</a>, <a href=\"#get_lint_config-tags\">tags</a>)\n</pre>\n\nGets the lint config for a particular linter from the tags of a rule.\n\nThis will return either `None` or the label configured in `lint_setup`.\nIf the tags `no-lint` or `no-linter_name` (eg. `no-java-checkstyle`) are\nfound, then `None` will be returned. This allows linting to be turned off\nfor specific rules.\n\n\n**PARAMETERS**\n\n\n| Name  | Description | Default Value |\n| :------------- | :------------- | :------------- |\n| <a id=\"get_lint_config-linter_name\"></a>linter_name |  The \"well known\" name of the linter (eg. `java-checkstyle`)   |  none |\n| <a id=\"get_lint_config-tags\"></a>tags |  The tags from the rule (eg. `ctx.attr.tags`)   |  none |\n\n\n<a id=\"package_lint_config\"></a>\n\n## package_lint_config\n\n<pre>\nload(\"@apple_rules_lint//lint:defs.bzl\", \"package_lint_config\")\n\npackage_lint_config(<a href=\"#package_lint_config-linters\">linters</a>)\n</pre>\n\nRegister the given linters for the current bazel package.\n\nThis is expected to be near the top of the `BUILD.bazel` file and\nallows users to override or configure specific linters for a bazel\npackage.\n\n\n**PARAMETERS**\n\n\n| Name  | Description | Default Value |\n| :------------- | :------------- | :------------- |\n| <a id=\"package_lint_config-linters\"></a>linters |  a dict of \"well known name\" to Label.   |  none |\n\n\n"
  },
  {
    "path": "example/BUILD.bazel",
    "content": "load(\"//lint_rule:amazing_linter.bzl\", \"example_linter_config\")\n\n# This is configured as the default lint config for `lintable_rule`\n# targets. We configure it to always fail the build to demonstrate\n# what could be done.\nexample_linter_config(\n    name = \"default_config\",\n    always_pass = False,\n    visibility = [\n        \"//visibility:public\",\n    ],\n)\n"
  },
  {
    "path": "example/MODULE.bazel",
    "content": "module(\n    name = \"lint_example\",\n)\n\nbazel_dep(name = \"apple_rules_lint\", version = \"0.0.0\")\nlocal_path_override(\n    module_name = \"apple_rules_lint\",\n    path = \"..\",\n)\n\nlinter = use_extension(\"@apple_rules_lint//lint:extensions.bzl\", \"linter\")\nlinter.register(name = \"lint_example\")\n\n#linter.configure(\n#    name = \"lint_example\",\n#    config = \"//:default_config\",\n#)\nuse_repo(linter, \"apple_linters\")\n"
  },
  {
    "path": "example/README.md",
    "content": "# Example Lint Project\n\nThis example demonstrates some of the features of the `apple_rules_lint`.\n\nTo get started run:\n\n`bazel build //project/...`\n\nThe build will pass. It should do! It does almost nothing! Now run:\n\n`bazel test //project/...`\n\nNo tests are run. Boo! That's no fun! But all's not lost! Open up the `WORKSPACE` and change:\n\n```py\nlint_setup({\n#    \"lint_example\": \"//:default_config\",\n})\n```\n\nto:\n\n```py\nlint_setup({\n    \"lint_example\": \"//:default_config\",\n})\n```\n\nWhat does this do? It says that rules that are aware of the `lint_example`\ntool should be using the `//:default_config` configuration for tests. By \ndefault, we've set this up to fail all the lint tests.\n\nBut if you look closely, not all the lint tests have failed. This is because\nthe build file in `//project/override` uses the `package_lint_config_override`\nrule to override the configuration for the `lint_example` tool.\n\n"
  },
  {
    "path": "example/WORKSPACE",
    "content": "workspace(name = \"lint_example\")\n\nlocal_repository(\n    name = \"apple_rules_lint\",\n    path = \"..\",\n)\n\nload(\"@apple_rules_lint//lint:repositories.bzl\", \"lint_deps\")\n\nlint_deps()\n\nload(\"@apple_rules_lint//lint:setup.bzl\", \"lint_setup\")\n\nlint_setup({\n    #    \"lint_example\": \"//:default_config\",\n})\n"
  },
  {
    "path": "example/lint_rule/BUILD.bazel",
    "content": ""
  },
  {
    "path": "example/lint_rule/amazing_linter.bzl",
    "content": "load(\"@apple_rules_lint//lint:defs.bzl\", \"get_lint_config\")\n\nExampleConfigInfo = provider(\n    fields = {\n        \"always_pass\": \"Whether the lint check should always pass\",\n    },\n)\n\ndef _example_linter_config_impl(ctx):\n    return [\n        ExampleConfigInfo(\n            always_pass = ctx.attr.always_pass,\n        ),\n    ]\n\nexample_linter_config = rule(\n    _example_linter_config_impl,\n    attrs = {\n        \"always_pass\": attr.bool(),\n    },\n    provides = [\n        ExampleConfigInfo,\n    ],\n)\n\ndef _lintable_test_impl(ctx):\n    config = ctx.attr.config[ExampleConfigInfo]\n    exit_flag = 0 if config.always_pass else 1\n\n    test = ctx.actions.declare_file(ctx.label.name)\n    ctx.actions.write(\n        test,\n        \"#!/bin/sh\\nexit %d\" % exit_flag,\n        is_executable = True,\n    )\n\n    return [\n        DefaultInfo(\n            executable = test,\n        ),\n    ]\n\nlintable_test = rule(\n    _lintable_test_impl,\n    test = True,\n    attrs = {\n        \"target\": attr.label(\n            mandatory = True,\n        ),\n        \"config\": attr.label(\n            providers = [\n                [ExampleConfigInfo],\n            ],\n        ),\n    },\n)\n\ndef _lintable_rule_impl(ctx):\n    return [\n    ]\n\n_lintable_rule = rule(\n    _lintable_rule_impl,\n    attrs = {\n    },\n)\n\ndef lintable_rule(name, tags = [], visibility = None):\n    _lintable_rule(name = name, visibility = visibility)\n\n    config = get_lint_config(\"lint_example\", tags)\n    if config != None:\n        lintable_test(\n            name = \"%s-test\" % name,\n            target = name,\n            config = config,\n        )\n"
  },
  {
    "path": "example/project/BUILD.bazel",
    "content": "load(\"//lint_rule:amazing_linter.bzl\", \"lintable_rule\")\n\n# Because we've not overridden the lint config, we get the default config,\n# which will cause the lint tests to fail.\nlintable_rule(\n    name = \"will_fail\",\n)\n"
  },
  {
    "path": "example/project/override/BUILD.bazel",
    "content": "load(\"@apple_rules_lint//lint:defs.bzl\", \"package_lint_config\")\nload(\"//lint_rule:amazing_linter.bzl\", \"example_linter_config\", \"lintable_rule\")\n\n# Override the default linter for \"lint_example\" only\npackage_lint_config({\n    \"lint_example\": \":override_config\",\n})\n\n# This config will cause the lint tests to always pass\nexample_linter_config(\n    name = \"override_config\",\n    always_pass = True,\n)\n\n# And because the linting config has been overridden for this package\n# alone, this lint test will pass.\nlintable_rule(\n    name = \"will_pass\",\n)\n"
  },
  {
    "path": "lint/BUILD.bazel",
    "content": "load(\"@bazel_skylib//:bzl_library.bzl\", \"bzl_library\")\n\nexports_files([\n    \"defs.bzl\",\n])\n\nbzl_library(\n    name = \"implementation\",\n    srcs = [\n        \":defs.bzl\",\n        \":setup.bzl\",\n        \"@apple_linters//:defs.bzl\",\n    ],\n    visibility = [\n        \"//visibility:public\",\n    ],\n    deps = [\n        \"//lint/private:implementation\",\n    ],\n)\n"
  },
  {
    "path": "lint/defs.bzl",
    "content": "load(\"//lint/private:get_lint_config.bzl\", _get_lint_config = \"get_lint_config\")\nload(\n    \"//lint/private:package_lint_config.bzl\",\n    _package_lint_config = \"package_lint_config\",\n)\nload(\"//lint/private:providers.bzl\", _LinterInfo = \"LinterInfo\")\n\nLinterInfo = _LinterInfo\nget_lint_config = _get_lint_config\npackage_lint_config = _package_lint_config\n"
  },
  {
    "path": "lint/extensions.bzl",
    "content": "load(\"//lint/private:register_linters.bzl\", \"COMMON_NAME\", \"register_linters\")\n\ndef _linter_impl(module_ctx):\n    linters = {}\n\n    for mod in module_ctx.modules:\n        for tag in mod.tags.register:\n            if not tag.name.islower():\n                fail(\"Linter names are expected to be in lowercase: {linter}\".format(\n                    linter = tag.name,\n                ))\n            if tag.name in linters:\n                fail(\"Linter '{linter}' has been registered by both '{mod_1}' and '{mod_2}'\".format(\n                    linter = tag.name,\n                    mod_1 = linters[tag.name],\n                    mod_2 = mod.name,\n                ))\n            linters[tag.name] = mod.name\n\n    name_to_linter_config = {}\n    for mod in module_ctx.modules:\n        # Only the root module's linter configuration should apply.\n        if not mod.is_root:\n            continue\n        for tag in mod.tags.configure:\n            if tag.name not in linters:\n                fail(\"Linter '{linter}' has not been registered\".format(\n                    linter = tag.name,\n                ))\n            if tag.name in name_to_linter_config:\n                fail(\"Linter '{linter}' is configured multiple times\".format(\n                    linter = tag.name,\n                ))\n            name_to_linter_config[tag.name] = str(tag.config)\n\n    register_linters(\n        name = COMMON_NAME,\n        linters = name_to_linter_config,\n    )\n\n_register = tag_class(\n    attrs = {\n        \"name\": attr.string(mandatory = True),\n    },\n)\n\n_configure = tag_class(\n    attrs = {\n        \"name\": attr.string(mandatory = True),\n        \"config\": attr.label(mandatory = True),\n    },\n)\n\nlinter = module_extension(\n    implementation = _linter_impl,\n    tag_classes = {\n        \"register\": _register,\n        \"configure\": _configure,\n    },\n)\n"
  },
  {
    "path": "lint/private/BUILD.bazel",
    "content": "load(\"@bazel_skylib//:bzl_library.bzl\", \"bzl_library\")\n\nbzl_library(\n    name = \"implementation\",\n    srcs = [\n        \"get_lint_config.bzl\",\n        \"package_lint_config.bzl\",\n        \"providers.bzl\",\n    ],\n    visibility = [\"//visibility:public\"],\n)\n"
  },
  {
    "path": "lint/private/docs/BUILD.bazel",
    "content": "load(\"@io_bazel_stardoc//stardoc:stardoc.bzl\", \"stardoc\")\n\nstardoc(\n    name = \"docs\",\n    out = \"api.md\",\n    input = \"//lint:defs.bzl\",\n    symbol_names = [\n        \"LinterInfo\",\n        \"get_lint_config\",\n        \"package_lint_config\",\n    ],\n    deps = [\n        \"//lint:implementation\",\n        \"//lint/private:implementation\",\n    ],\n)\n"
  },
  {
    "path": "lint/private/get_lint_config.bzl",
    "content": "load(\"@apple_linters//:defs.bzl\", \"configured_linters\")\nload(\"//lint/private:package_lint_config.bzl\", \"OVERRIDE_RULE_NAME\")\n\ndef get_repo_name():\n    repo_name = getattr(native, \"repo_name\", None)\n    if not repo_name:\n        # We're using an old Bazel version (5.x), so this will be fine\n        return native.repository_name()\n\n    # Are we using `bzlmod` or not?\n    is_bzlmod = str(Label(\"@does_not_exist_i_promise//:BUILD.bazel\")).startswith(\"@@\")\n    prefix = \"@@\" if is_bzlmod else \"@\"\n    return prefix + repo_name()\n\ndef get_lint_config(linter_name, tags):\n    \"\"\"Gets the lint config for a particular linter from the tags of a rule.\n\n    This will return either `None` or the label configured in `lint_setup`.\n    If the tags `no-lint` or `no-linter_name` (eg. `no-java-checkstyle`) are\n    found, then `None` will be returned. This allows linting to be turned off\n    for specific rules.\n\n    Args:\n      linter_name: The \"well known\" name of the linter (eg. `java-checkstyle`)\n      tags: The tags from the rule (eg. `ctx.attr.tags`)\n    \"\"\"\n    if not linter_name.islower():\n        fail(\"Linter names are expected to be in lowercase: %s\" % linter_name)\n\n    skip_names = [\n        \"no-lint\",\n        \"no-%s\" % linter_name,\n    ]\n    skip_tags = [name for name in skip_names if name in tags]\n    if len(skip_tags) > 0:\n        return None\n\n    if native.existing_rule(\"%s_%s\" % (OVERRIDE_RULE_NAME, linter_name)) != None:\n        return Label(\"%s//%s:%s_%s\" % (get_repo_name(), native.package_name(), OVERRIDE_RULE_NAME, linter_name))\n\n    if linter_name in configured_linters:\n        return Label(\"@apple_linters//:%s_%s\" % (OVERRIDE_RULE_NAME, linter_name))\n\n    return None\n"
  },
  {
    "path": "lint/private/package_lint_config.bzl",
    "content": "def _empty_rule_impl(ctx):\n    return [\n        DefaultInfo(),\n    ]\n\n_empty_rule = rule(\n    _empty_rule_impl,\n    attrs = {\n    },\n)\n\nOVERRIDE_RULE_NAME = \"package_lint_config\"\n\ndef package_lint_config(linters):\n    \"\"\"Register the given linters for the current bazel package.\n\n    This is expected to be near the top of the `BUILD.bazel` file and\n    allows users to override or configure specific linters for a bazel\n    package.\n\n    Args:\n      linters: a dict of \"well known name\" to Label.\n    \"\"\"\n\n    if native.existing_rule(\":%s\" % OVERRIDE_RULE_NAME):\n        fail(\"Lint configurations may only be overridden once per package\")\n\n    for (key, value) in linters.items():\n        if not key.islower():\n            fail(\"All linter names should be lower case. eg. \\\"java-checkstyle\\\": %s\" % key)\n\n        native.alias(\n            name = \"%s_%s\" % (OVERRIDE_RULE_NAME, key),\n            actual = value,\n        )\n\n    # Add a marker rule to indicate that we've finished overriding things\n    _empty_rule(name = OVERRIDE_RULE_NAME)\n"
  },
  {
    "path": "lint/private/providers.bzl",
    "content": "LinterInfo = provider(\n    fields = {\n        \"language\": \"The language or kind of thing we are linting.\",\n        \"name\": \"The name of the linter\",\n    },\n)\n"
  },
  {
    "path": "lint/private/register_linters.bzl",
    "content": "COMMON_NAME = \"apple_linters\"\n\ndef _register_linters_impl(repository_ctx):\n    linter_names = [name.lower() for name in repository_ctx.attr.linters.keys()]\n    repository_ctx.file(\"defs.bzl\", \"configured_linters = %s\" % linter_names)\n\n    # Ensure that all values are actually labels\n    linters = {}\n    for (name, value) in repository_ctx.attr.linters.items():\n        # Apparently the `Label` isn't available in this context. *sigh*\n        # Manually munge rule names so that they evaluate nicely\n        if value.startswith(\"//\"):\n            linters.update({name.lower(): \"@%s\" % value})\n        elif value.startswith(\":\"):\n            linters.update({name.lower(): \"@//%s%s\" % (native.package_name, value)})\n        else:\n            linters.update({name.lower(): value})\n\n    repository_ctx.file(\n        \"BUILD.bazel\",\n        \"\"\"\nload(\"@apple_rules_lint//lint/private:package_lint_config.bzl\", \"package_lint_config\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\npackage_lint_config(%s)\n\nexports_files([\"defs.bzl\"])\n\"\"\" % repr(linters),\n    )\n\nregister_linters = repository_rule(\n    _register_linters_impl,\n    attrs = {\n        \"linters\": attr.string_dict(\n            doc = \"Dict of well-known linter name to label of linter configuration.\",\n            allow_empty = True,\n        ),\n    },\n)\n"
  },
  {
    "path": "lint/repositories.bzl",
    "content": "load(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\nload(\"@bazel_tools//tools/build_defs/repo:utils.bzl\", \"maybe\")\n\ndef lint_deps():\n    maybe(\n        http_archive,\n        name = \"bazel_skylib\",\n        sha256 = \"bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f\",\n        urls = [\n            \"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz\",\n            \"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz\",\n        ],\n    )\n"
  },
  {
    "path": "lint/setup.bzl",
    "content": "load(\"@bazel_skylib//:workspace.bzl\", \"bazel_skylib_workspace\")\nload(\"//lint/private:register_linters.bzl\", \"COMMON_NAME\", \"register_linters\")\n\ndef do_register_linters(name_to_linter_config):\n    for name in name_to_linter_config.keys():\n        if not name.islower():\n            fail(\"Linter names are expected to be in lowercase: %s\" % name)\n\n    register_linters(\n        name = COMMON_NAME,\n        linters = name_to_linter_config,\n    )\n\ndef lint_setup(name_to_linter_config = {}):\n    \"\"\"Register the given linters.\n\n    This rule is designed to be run by users from the `WORKSPACE`. Ruleset\n    authors are expected to use `ruleset_lint_config`.\n\n    Args:\n         linters: a dict of \"well known name\" to Label.\n    \"\"\"\n\n    bazel_skylib_workspace()\n\n    if native.existing_rule(COMMON_NAME):\n        fail(\n            \"Linting has already been configured. Please ensure that the call \" +\n            \"to `register_linters` is included as early as possible in your \" +\n            \"WORKSPACE. If you experience problems or need help, please raise an issue \" +\n            \"at https://github.com/apple/apple_rules_lint/issues/new\",\n        )\n        return\n\n    # Ensure that labels are correct\n    do_register_linters(name_to_linter_config)\n\ndef ruleset_lint_setup():\n    \"\"\"Register the given linters.\n\n    This rule is designed to be run by authors of rulesets so that they\n    can ensure that they can call `get_lint_config` safely. Users should\n    use `lint_setup` instead.\n    \"\"\"\n\n    if not native.existing_rule(COMMON_NAME):\n        do_register_linters({})\n"
  },
  {
    "path": "scripts/build-release-artifacts",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nTAG=\"$1\"\ngit archive --format=tar --prefix=apple_rules_lint-\"${TAG}\"/ \"${TAG}\" | gzip > apple_rules_lint-\"${TAG}\".tar.gz\n"
  },
  {
    "path": "scripts/generate-docs",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nbazel build lint/private/docs\ncp -f bazel-bin/lint/private/docs/api.md api.md"
  },
  {
    "path": "tests/bcr/.bazelignore",
    "content": "other_module\n"
  },
  {
    "path": "tests/bcr/.bazelrc",
    "content": "build --experimental_enable_bzlmod\nbuild --incompatible_unambiguous_label_stringification\n"
  },
  {
    "path": "tests/bcr/.bazelversion",
    "content": "c4a1ab8b6577c4376aaaa5c3c2d4ef07d524175c\n"
  },
  {
    "path": "tests/bcr/BUILD.bazel",
    "content": "exports_files([\"foo_config.json\"])\n\nalias(\n    name = \"foo-check-config\",\n    actual = \"@other_module//:foo-check-config\",\n)\n"
  },
  {
    "path": "tests/bcr/MODULE.bazel",
    "content": "module()\n\nbazel_dep(name = \"apple_rules_lint\", version = \"\")\nlocal_path_override(\n    module_name = \"apple_rules_lint\",\n    path = \"../..\",\n)\n\nbazel_dep(name = \"other_module\", version = \"\")\nlocal_path_override(\n    module_name = \"other_module\",\n    path = \"other_module\",\n)\n\nlinter = use_extension(\"@apple_rules_lint//lint:extensions.bzl\", \"linter\")\nlinter.configure(\n    name = \"foo-check\",\n    config = \"//:foo_config.json\",\n)\n# No config for bar-lint\n"
  },
  {
    "path": "tests/bcr/WORKSPACE",
    "content": ""
  },
  {
    "path": "tests/bcr/foo_config.json",
    "content": "{\n    \"enabled\": false\n}\n"
  },
  {
    "path": "tests/bcr/other_module/BUILD.bazel",
    "content": "load(\"@apple_rules_lint//lint:defs.bzl\", \"get_lint_config\")\n\nfail(\"Expected no config for bar-lint\") if get_lint_config(\"bar-lint\", []) != None else []\n\nfail(\"Expected config for foo-check\") if get_lint_config(\"foo-check\", []) == None else []\n\nfilegroup(\n    name = \"foo-check-config\",\n    srcs = [get_lint_config(\"foo-check\", [])],\n    visibility = [\"//visibility:public\"],\n)\n"
  },
  {
    "path": "tests/bcr/other_module/MODULE.bazel",
    "content": "module(\n    name = \"other_module\",\n    version = \"\",\n)\n\nbazel_dep(name = \"apple_rules_lint\", version = \"0.4.0\")\n\nlinter = use_extension(\"@apple_rules_lint//lint:extensions.bzl\", \"linter\")\nlinter.register(name = \"foo-check\")\nlinter.register(name = \"bar-lint\")\n\n# This config is ignored if other_module is not the root module.\nlinter.configure(\n    name = \"bar-lint\",\n    config = \"//:does_not_exist\",\n)\n"
  },
  {
    "path": "tests/bcr/other_module/WORKSPACE",
    "content": ""
  }
]