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

feat: fork json schema types for better compat with ESLint rule validation#6963

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

Merged
JoshuaKGoldberg merged 5 commits intov6fromv6-remove-newer-json-schema-types
Jun 17, 2023

Conversation

bradzacher
Copy link
Member

BREAKING CHANGE:
@typescript-eslint/utils now only exports the v4 JSON schema types - the only version ESLint validates rules with.
Removed the unsafe[string]: any indexer from theJSONSchema4 type to help ensure invalid properties aren't used.


This was something I noticed whilst working on our schema enhancements - we re-exported all these types that were mostly useless for lint rules because ESLint is hard-locked to v4 of the schema. So I decided to remove those newer schema types from the export.

I was going to leave it there, but then I remember that I had added a local patch that strictified the types by removing the unsafe indexer (which helped us catch bugs in our schemas). So I decided we can just fork the types entirely and apply my patch so all consumers get that same benefit.

@bradzacherbradzacher added enhancementNew feature or request breaking changeThis change will require a new major version to be released labelsApr 27, 2023
@bradzacherbradzacher added this to the6.0.0 milestoneApr 27, 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 27, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit96e019c
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/648d1262111e1c000823d6ba
😎 Deploy Previewhttps://deploy-preview-6963--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 27, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit96e019c. 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


✅ Successfully ran 31 targets

Sent with 💌 fromNxCloud.

@bradzacherbradzacher mentioned this pull requestApr 27, 2023
9 tasks
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.

🔥 looks great! I wonder if we could export this as our own types so other ESLint projects (maybe ESLint itself, if they want a devDependency to help with types) could use it? Given that it's already exported by@typescript-eslint/utils I think it's fine to stay as-is.

@bradzacher
Copy link
MemberAuthor

@JoshuaKGoldberg /@armano2 I just pushed a new commit (178cf35) that further strictifies the types to a discriminated union.
This allows us to use types to validate that you don't provide mismatched properties.
This caught a bug in two of our schema defs:

The downside to doing this is that you can be significantly less flexible in how you write schemas. For reference, you now must always define atype for each schema so that it can correctly pick the type, and it restricts some funky combos like addinganyOf +$ref + any concrete type.
Given that we always want to represent schemas as types - I don't think this is necessarily a bad thing though? Across our codebase we didn't end up changing anything aside from addingtype in a few missing places.

If you guys think it's better to just stick to the spec and be loose - more than happy to revert the schema changes.

It's really hard to judge the impact of such a change, given that we don't know how all our consumers define schemas - but I'd think they're not too crazy?

@bradzacherbradzacherforce-pushed thev6-remove-newer-json-schema-types branch from178cf35 to08bceb7CompareApril 28, 2023 01:13
@bradzacherbradzacherforce-pushed thev6-remove-newer-json-schema-types branch from08bceb7 to24a27afCompareApril 28, 2023 01:13
@JoshuaKGoldberg
Copy link
Member

Oof this hurts me though 😞. It seems like it'd be very annoying to have to write out thetype when it can be inferred:

arrayOption:{type:'string',enum:['array','generic','array-simple'],},

Maybe there's a happy medium we can go for? Only requiretype when it's not directly inferable?

@bradzacher
Copy link
MemberAuthor

It seems like it'd be very annoying to have to write out the type when it can be inferred

The flip side is that the explicittype will prevent cases likeenum: [1, 2, "3"] that would otherwise make the 3rd option inaccessible.

JoshuaKGoldberg reacted with thumbs up emoji

@codecov
Copy link

codecovbot commentedJun 17, 2023
edited
Loading

Codecov Report

Merging#6963 (24a27af) intov6 (1366ae1) willincrease coverage by0.10%.
The diff coverage is100.00%.

❗ Current head24a27af differs from pull request most recent head96e019c. Consider uploading reports for the commit96e019c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@##               v6    #6963      +/-   ##==========================================+ Coverage   87.50%   87.61%   +0.10%==========================================  Files         376      375       -1       Lines       12937    12923      -14       Branches     3821     3821              ==========================================+ Hits        11321    11322       +1+ Misses       1231     1216      -15  Partials      385      385
FlagCoverage Δ
unittest87.61% <100.00%> (+0.10%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
packages/eslint-plugin/src/rules/array-type.ts97.14% <ø> (ø)
packages/eslint-plugin/src/rules/ban-ts-comment.ts96.96% <ø> (ø)
...t-plugin/src/rules/class-literal-property-style.ts100.00% <ø> (ø)
packages/eslint-plugin/src/rules/comma-dangle.ts93.33% <ø> (ø)
...lugin/src/rules/consistent-generic-constructors.ts90.69% <ø> (ø)
...lugin/src/rules/consistent-indexed-object-style.ts92.06% <ø> (ø)
...int-plugin/src/rules/consistent-type-assertions.ts92.59% <ø> (ø)
...nt-plugin/src/rules/consistent-type-definitions.ts97.29% <ø> (ø)
...eslint-plugin/src/rules/consistent-type-imports.ts94.50% <ø> (ø)
...-plugin/src/rules/explicit-member-accessibility.ts96.10% <ø> (-0.05%)⬇️
... and33 more

... and7 files with indirect coverage changes

@JoshuaKGoldbergJoshuaKGoldberg deleted the v6-remove-newer-json-schema-types branchJune 17, 2023 02:14
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJun 25, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@armano2armano2armano2 approved these changes

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

Assignees
No one assigned
Labels
breaking changeThis change will require a new major version to be releasedenhancementNew feature or request
Projects
None yet
Milestone
6.0.0
Development

Successfully merging this pull request may close these issues.

3 participants
@bradzacher@JoshuaKGoldberg@armano2

[8]ページ先頭

©2009-2025 Movatter.jp