Skip to content

Support top-level custom linter rules#795

Merged
jviotti merged 4 commits into
mainfrom
linter-top-level
Jul 15, 2026
Merged

Support top-level custom linter rules#795
jviotti merged 4 commits into
mainfrom
linter-top-level

Conversation

@jviotti

@jviotti jviotti commented Jul 15, 2026

Copy link
Copy Markdown
Member

No description provided.

jviotti added 2 commits July 15, 2026 17:42
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti jviotti changed the title linter top level Support registering top-level custom linter rules Jul 15, 2026
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
jviotti marked this pull request as ready for review July 15, 2026 21:19
@jviotti jviotti changed the title Support registering top-level custom linter rules Support top-level custom linter rules Jul 15, 2026
@augmentcode

augmentcode Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR adds support for registering custom linter rules that run only at the document root (top-level).

Changes:

  • Introduced a new CLI option --top-level-rule/-t alongside existing --rule/-a to scope custom rules to the root schema only.
  • Extended jsonschema.json configuration so lint.rules can contain either strings or objects ({ path, topLevel }) to declare rule scope.
  • Refactored lint rule loading to share logic between option-based rule registration paths.
  • Updated bash/zsh completions and CLI help text to document the new option.
  • Added a comprehensive set of shell-based tests covering top-level rules (pass/fail, YAML, exclude/only, duplicate names, fix behavior) and new config entry validation.
  • Vendor update to Blaze adding rule scoping support, improving annotation-collection decision logic, and registering the Sourcemeta Extension vocabulary/dialects with better evaluator descriptions for new annotation keywords.

Technical Notes: Top-level scoping is implemented in Blaze’s SchemaRule by skipping evaluation for non-root schema locations, and config parsing now validates mixed (string/object) rule entries with clear error locations.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/configuration.markdown">

<violation number="1" location="docs/configuration.markdown:65">
P2: The new type notation `String[] / Object[]` incorrectly suggests `lint.rules` must be homogeneous (all strings **or** all objects), but the implementation allows mixing both types in the same array — each entry can independently be a string or an object with a `path`/`topLevel` shape. Consider reverting to the previous `(String / Object)[]` notation, which more accurately describes `(String | Object)[]` — an array whose individual elements can be either type.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

| `dependencies` | Object | A mapping of URIs to relative file paths for external schema dependencies to install (see [`jsonschema install`](./install.markdown)) | `{}` |
| `lint` | Object | Lint configuration | `{}` |
| `lint.rules` | String[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)) | `[]` |
| `lint.rules` | String[] / Object[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)). An entry may also be an object with a required `path` string property and an optional `topLevel` boolean property (defaults to `false`) that makes the rule only run against the document root | `[]` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new type notation String[] / Object[] incorrectly suggests lint.rules must be homogeneous (all strings or all objects), but the implementation allows mixing both types in the same array — each entry can independently be a string or an object with a path/topLevel shape. Consider reverting to the previous (String / Object)[] notation, which more accurately describes (String | Object)[] — an array whose individual elements can be either type.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/configuration.markdown, line 65:

<comment>The new type notation `String[] / Object[]` incorrectly suggests `lint.rules` must be homogeneous (all strings **or** all objects), but the implementation allows mixing both types in the same array — each entry can independently be a string or an object with a `path`/`topLevel` shape. Consider reverting to the previous `(String / Object)[]` notation, which more accurately describes `(String | Object)[]` — an array whose individual elements can be either type.</comment>

<file context>
@@ -62,7 +62,7 @@ describes the available configuration options:
 | `dependencies` | Object | A mapping of URIs to relative file paths for external schema dependencies to install (see [`jsonschema install`](./install.markdown)) | `{}` |
 | `lint` | Object | Lint configuration | `{}` |
-| `lint.rules` | (String / Object)[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)). An entry may also be an object with a required `path` string property and an optional `topLevel` boolean property (defaults to `false`) that makes the rule only run against the document root | `[]` |
+| `lint.rules` | String[] / Object[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)). An entry may also be an object with a required `path` string property and an optional `topLevel` boolean property (defaults to `false`) that makes the rule only run against the document root | `[]` |
 
 Lookup Algorithm
</file context>
Suggested change
| `lint.rules` | String[] / Object[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)). An entry may also be an object with a required `path` string property and an optional `topLevel` boolean property (defaults to `false`) that makes the rule only run against the document root | `[]` |
| `lint.rules` | (String / Object)[] | Paths to custom lint rule schemas relative to `jsonschema.json` (see [lint](./lint.markdown)). An entry may also be an object with a required `path` string property and an optional `topLevel` boolean property (defaults to `false`) that makes the rule only run against the document root | `[]` |

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="completion/jsonschema.bash">

<violation number="1" location="completion/jsonschema.bash:145">
P3: After `jsonschema lint -t `, Bash completion offers `typescript`, which is not a valid top-level rule argument. The new alias needs a `lint`-specific `-t` argument completion before the existing codegen/upgrade handling.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread test/lint/fail_lint_top_level_rule_fix.sh
;;
lint)
local options="--fix -f --extension -e --ignore -i --exclude -x --only -o --list -l --indentation -n"
local options="--fix -f --extension -e --ignore -i --exclude -x --only -o --list -l --indentation -n --rule -a --top-level-rule -t"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: After jsonschema lint -t , Bash completion offers typescript, which is not a valid top-level rule argument. The new alias needs a lint-specific -t argument completion before the existing codegen/upgrade handling.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At completion/jsonschema.bash, line 145:

<comment>After `jsonschema lint -t `, Bash completion offers `typescript`, which is not a valid top-level rule argument. The new alias needs a `lint`-specific `-t` argument completion before the existing codegen/upgrade handling.</comment>

<file context>
@@ -142,7 +142,7 @@ _jsonschema() {
       ;;
     lint)
-      local options="--fix -f --extension -e --ignore -i --exclude -x --only -o --list -l --indentation -n"
+      local options="--fix -f --extension -e --ignore -i --exclude -x --only -o --list -l --indentation -n --rule -a --top-level-rule -t"
       if [[ ${current} == -* ]]
       then
</file context>

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
jviotti merged commit 12d64a9 into main Jul 15, 2026
15 checks passed
@jviotti
jviotti deleted the linter-top-level branch July 15, 2026 21:43
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 18, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [sourcemeta/jsonschema](https://github.com/sourcemeta/jsonschema) | minor | `v16.1.0` → `v16.2.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>sourcemeta/jsonschema (sourcemeta/jsonschema)</summary>

### [`v16.2.0`](https://github.com/sourcemeta/jsonschema/releases/tag/v16.2.0)

[Compare Source](sourcemeta/jsonschema@v16.1.0...v16.2.0)

#### What's Changed

- Fix crashes on boolean schemas in various commands by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;792](sourcemeta/jsonschema#792)
- Report a non-zero exit code if a `test` file has no tests by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;794](sourcemeta/jsonschema#794)
- Support top-level custom linter rules by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;795](sourcemeta/jsonschema#795)

**Full Changelog**: <sourcemeta/jsonschema@v16.1.0...v16.2.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjMuNiIsInVwZGF0ZWRJblZlciI6IjQzLjI2My42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
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