Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): refactor schemas that use$ref#6896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
bradzacher wants to merge1 commit intomainfromfix-schemas-20230413

Conversation

bradzacher
Copy link
Member

PR Checklist

Overview

Updates rule schemas that use $ref to use an array-based schema instead of an object-based one and updates the doc gen to match.

ESLint will wrap an array schema in an array object:[schema] -> { type: 'array', items: [schema] }, so we can use that knowledge to reference the$defs with#/items/0/$defs/....

This saves us manually recreating the tuple validation that ESLint already does for us.
It does require us to rewrite the$ref for our doc gen because we reference the schema object directly (eg#/items/0/$defs/... -> #/$defs/...

@bradzacherbradzacher added the bugSomething isn't working labelApr 12, 2023
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@netlify
Copy link

netlifybot commentedApr 12, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitd317fbc
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/64373d93f1349e000831ca57
😎 Deploy Previewhttps://deploy-preview-6896--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site settings.

@nx-cloud
Copy link

nx-cloudbot commentedApr 12, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitd317fbc. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


🟥 Failed Commands
Node 14 - nx test eslint-plugin --coverage=false
✅ Successfully ran 23 targets

Sent with 💌 fromNxCloud.

Comment on lines +70 to 78
arrays: { $ref: '#/items/0/$defs/valueWithIgnore' },
objects: { $ref: '#/items/0/$defs/valueWithIgnore' },
imports: { $ref: '#/items/0/$defs/valueWithIgnore' },
exports: { $ref: '#/items/0/$defs/valueWithIgnore' },
functions: { $ref: '#/items/0/$defs/valueWithIgnore' },
enums: { $ref: '#/items/0/$defs/valueWithIgnore' },
generics: { $ref: '#/items/0/$defs/valueWithIgnore' },
tuples: { $ref: '#/items/0/$defs/valueWithIgnore' },
},
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Suggested change
arrays:{$ref:'#/items/0/$defs/valueWithIgnore'},
objects:{$ref:'#/items/0/$defs/valueWithIgnore'},
imports:{$ref:'#/items/0/$defs/valueWithIgnore'},
exports:{$ref:'#/items/0/$defs/valueWithIgnore'},
functions:{$ref:'#/items/0/$defs/valueWithIgnore'},
enums:{$ref:'#/items/0/$defs/valueWithIgnore'},
generics:{$ref:'#/items/0/$defs/valueWithIgnore'},
tuples:{$ref:'#/items/0/$defs/valueWithIgnore'},
},
arrays:{$ref:'#/$defs/valueWithIgnore'},
objects:{$ref:'#/$defs/valueWithIgnore'},
imports:{$ref:'#/$defs/valueWithIgnore'},
exports:{$ref:'#/$defs/valueWithIgnore'},
functions:{$ref:'#/$defs/valueWithIgnore'},
enums:{$ref:'#/$defs/valueWithIgnore'},
generics:{$ref:'#/$defs/valueWithIgnore'},
tuples:{$ref:'#/$defs/valueWithIgnore'},
},

JoshuaKGoldberg reacted with thumbs up emoji
@domdomegg
Copy link
Contributor

Hey, just wanted to flag that I saw this limitation in ESLint when looking around there to understand how the schema logic worked and was considering contributing to ESLint to remove this limitation altogether: so the $refs are just hoisted to the top level schema.

Not sure if that would be accepted, but given their docs I don't think it would be a breaking change (as consumers are suppoesd to expect that $refs don't work with array types).

In any case, if we're using an undocumented feature of eslint we should probably have contract tests around eslint that it does validate these as expected, in case that logic does change.

JoshuaKGoldberg reacted with heart emoji

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM!

Would normally request changes on using Prettier fordefaultOptions too but I trust you 😄 and think it's fine as a followup.

@@ -34,6 +34,59 @@ function nodeIsParent(node: unist.Node<unist.Data>): node is unist.Parent {
return 'children' in node;
}

const prettierConfig = resolveConfig.sync(__dirname);

Choose a reason for hiding this comment

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

[Nitpick] Now we're mixing our style & the default, heh.

Screenshot of array-type mixing single and double apostrophes

@bradzacher
Copy link
MemberAuthor

closing in favour of#6899 and#6894

@bradzacherbradzacher deleted the fix-schemas-20230413 branchApril 20, 2023 12:00
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsApr 28, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@armano2armano2armano2 left review comments

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

Assignees
No one assigned
Labels
bugSomething isn't working
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug: [array-type] the configsimple-array should be disallowed by the schema
4 participants
@bradzacher@domdomegg@armano2@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp