Support top-level custom linter rules#795
Conversation
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
🤖 Augment PR SummarySummary: This PR adds support for registering custom linter rules that run only at the document root (top-level). Changes:
Technical Notes: Top-level scoping is implemented in Blaze’s 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
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 | `[]` | |
There was a problem hiding this comment.
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>
| | `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 | `[]` | |
There was a problem hiding this comment.
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
| ;; | ||
| 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" |
There was a problem hiding this comment.
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>
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 [@​jviotti](https://github.com/jviotti) in [#​792](sourcemeta/jsonschema#792) - Report a non-zero exit code if a `test` file has no tests by [@​jviotti](https://github.com/jviotti) in [#​794](sourcemeta/jsonschema#794) - Support top-level custom linter rules by [@​jviotti](https://github.com/jviotti) in [#​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=-->
No description provided.