Skip to content

feat(lint-json): Move the JSON validation code to its own package#4124

Open
JasonVMo wants to merge 4 commits intomainfrom
user/jasonvmo/lint-json
Open

feat(lint-json): Move the JSON validation code to its own package#4124
JasonVMo wants to merge 4 commits intomainfrom
user/jasonvmo/lint-json

Conversation

@JasonVMo
Copy link
Copy Markdown
Collaborator

@JasonVMo JasonVMo commented May 5, 2026

Description

This creates a new package for json linting with the validation code from the tools-packages PR. This should also address the PR feedback in the other PR.

The proto blocking I left as an exception as that is an error in the test code not a random user error and I prefer it to silent failures.

Test plan

Automated tests

Copy link
Copy Markdown
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

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

In a future iteration, we should provide a way to say "one of these fields must be set". This is required to replace our tsconfig.json validator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we not publishing this package yet?

if (!parent) {
context.error(valueMessage(path, value, undefined));
} else {
const currentValue = parent[path[path.length - 1]];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The current index can be stored for reuse further down

Suggested change
const currentValue = parent[path[path.length - 1]];
const index = path[path.length - 1];
const currentValue = parent[index];

Comment on lines +22 to +23
"main": "lib/index.js",
"types": "lib/index.d.ts",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also provide an exports map?

*/
export function createJSONValidator(
jsonPath: string,
json: Record<string, JSONValue> | undefined,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we replace all instances of Record<string, JSONValue>?

Suggested change
json: Record<string, JSONValue> | undefined,
json: JSONObject | undefined,

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.

2 participants