Skip to content

feat: support the all tag to enable every rule - #1514

Open
bartlomieju wants to merge 1 commit into
mainfrom
feat-all-tag
Open

feat: support the all tag to enable every rule#1514
bartlomieju wants to merge 1 commit into
mainfrom
feat-all-tag

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Refs #1244.

Adds a special all tag to filtered_rules: when the requested tag set
contains all, every rule matches regardless of its own tags. This lets a
configuration opt into the complete rule set with

{ "lint": { "rules": { "tags": ["all"] } } }

instead of enumerating every rule under include. It composes with the
existing exclude list to drop individual rules, e.g. tags: ["all"] +
exclude: ["no-explicit-any"].

This is the deno_lint-side primitive only. Two related ideas from the issue
are intentionally out of scope here and can build on top of this:

  • tag-level negation (tags: ["all", "-fresh"]) — needs the config layer in
    the Deno CLI to map the negated tag onto excludes;
  • user-defined custom tags.

Adds tests for all alone (returns every rule) and all + exclude.

Add a special `all` tag to `filtered_rules` that matches every rule regardless
of the rule's own tags, so a config can opt into the full rule set with
`tags: ["all"]` instead of listing each rule by name. Combine it with
`exclude` to drop individual rules.

Refs #1244
@bartlomieju

Copy link
Copy Markdown
Member Author

Verdict: LGTM — correct and tested. Recommend merge (public-behavior change, so flagging rather than auto-merging; needs green CI / rebase).

Correctness — good

  • tags_set.contains("all") || rule.tags().iter().any(...) short-circuits to include every rule when all is present, and composes correctly with exclude (applied downstream) — both paths are covered by the added tests (allget_all_rules().len(), and all + exclude → len() - 1 with the excluded code absent).
  • contains("all") on the HashSet<String> resolves via Borrow<str>, so no allocation for the check. The || any(...) ordering also means the common all case avoids the per-tag scan.

Minor

  • all is now effectively a reserved tag name. No current rule uses it, but worth a one-line note in the doc comment that all is reserved, so a future rule doesn't accidentally define a real all tag.
  • Scope is correctly limited to the deno_lint primitive; tag-negation (-fresh) and custom tags are appropriately deferred to the CLI config layer, as you note.

Perf: neutral/slightly better (short-circuit on all).

Housekeeping: public API/behavior addition → maintainer sign-off (your own PR). mergeable: UNKNOWN → rebase.

No changes requested. Good to merge once CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant