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: improve rule schemas, add test to validate schemas, add tooling to generate schema types#6899

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
bradzacher merged 18 commits intov6fromv6-improved-schema-generation-and-validation
Apr 20, 2023

Conversation

bradzacher
Copy link
Member

@bradzacherbradzacher commentedApr 13, 2023
edited
Loading

Overview

@JoshuaKGoldberg I went through with my threat for no reason other than it seemed fun.

Previously we usedjson-schema-to-typescript to generate our types, however we have found that the package has a number of edge-cases that don't do what we want. Attempting to change the package is... difficult because it is built to be super flexible so it can attempt to handle every single permutation and valid state of a JSON schema.

However in reality we don't actually need all that power - just a fraction of it because rule schemas are some degree of sane (usually... at least our are). This means we can easily constrain the transformation code and thus simplify it significantly.

This PR:

  1. introduces a new (currently internal) package that contains tooling to convert a rule's schema to TypeScript types.
  2. introduces snapshot tests for the plugin that snapshots the schema and the generated TS types
    • I realised that running this against our rules is a great way for us to validate our schemas are doing what we think they are - I personally find that seeing the fully resolved schema along side the computed TS types are incredibly helpful in understanding the schemas.
      This has the added benefit that we can validate the types that will get embedded in the website without needing to do a website build - which is a nice, quick sanity check.
  3. introduces a test for the plugin that validates that the schemas don't include invalid properties
    • Whilst building the tool I noticed a lot of invalid states in the schema, so I threw together a test to shout about unknown properties. This in turn helped me find a bunch of incorrect schemas!
  4. updates the website build to use the new package

Note: I purposely haven't written tests for the tool as it's pretty extensively tested by running on our rules already. I didn't see any need in additional tests.

JoshuaKGoldberg reacted with laugh emojiarmano2 reacted with heart emoji
@bradzacherbradzacher added enhancementNew feature or request testsanything to do with testing repo maintenancethings to do with maintenance of the repo, and not with code/docs labelsApr 13, 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 13, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitf113341
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/644094a9ecfed60008f056b0
😎 Deploy Previewhttps://deploy-preview-6899--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 13, 2023
edited
Loading

☁️ Nx Cloud Report

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

Sent with 💌 fromNxCloud.

@codecov
Copy link

codecovbot commentedApr 14, 2023
edited
Loading

Codecov Report

Merging#6899 (f113341) intov6 (4bc7571) willdecrease coverage by0.01%.
The diff coverage is100.00%.

Additional details and impacted files
@@            Coverage Diff             @@##               v6    #6899      +/-   ##==========================================- Coverage   87.51%   87.50%   -0.01%==========================================  Files         376      376                Lines       12940    12936       -4       Branches     3820     3820              ==========================================- Hits        11324    11320       -4  Misses       1231     1231                Partials      385      385
FlagCoverage Δ
unittest87.50% <100.00%> (-0.01%)⬇️

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% <ø> (ø)
...-plugin/src/rules/explicit-member-accessibility.ts96.10% <ø> (-0.05%)⬇️
...es/eslint-plugin/src/rules/lines-around-comment.ts100.00% <ø> (ø)
packages/eslint-plugin/src/rules/no-type-alias.ts100.00% <ø> (ø)
...lugin/src/rules/padding-line-between-statements.ts93.83% <ø> (ø)
...es/eslint-plugin/src/rules/parameter-properties.ts94.11% <ø> (ø)
...ackages/eslint-plugin/src/rules/prefer-readonly.ts99.09% <ø> (ø)
...eslint-plugin/src/rules/type-annotation-spacing.ts81.69% <ø> (-0.26%)⬇️
packages/type-utils/src/isTypeReadonly.ts88.88% <ø> (ø)
... and7 more

@bradzacherbradzacher marked this pull request as ready for reviewApril 14, 2023 03:52
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.

also what armano2 said 😄 - but this looks great so far! I'll take a deeper look upon re-request

@@ -71,6 +71,42 @@ See our docs on [type aware linting](./Typed_Linting.mdx) for more information.
You're using an outdated version of `@typescript-eslint/parser`.
Update to the latest version to see a more informative version of this error message, explained [above](#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file 'backlink to I get errors telling me ESLint was configured to run ...').

## How do I turn on a `@typescript-eslint` rule?

Choose a reason for hiding this comment

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

Meant for another PR?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Intentionally added as part of cleaning up the holistic docs update in this PR.
We've seen this asked a few times and the ESLint team doesn't think their docs are unclear, so as part of improving the rule config docs - this FAQ article to quick-link people to.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelApr 16, 2023
@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelApr 18, 2023
Copy link
Collaborator

@armano2armano2 left a comment

Choose a reason for hiding this comment

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

this looks awesome, thank you for you hard work

@bradzacherbradzacher merged commitacc1a43 intov6Apr 20, 2023
@bradzacherbradzacher deleted the v6-improved-schema-generation-and-validation branchApril 20, 2023 01:57
@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 approved these changes

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

Assignees
No one assigned
Labels
enhancementNew feature or requestrepo maintenancethings to do with maintenance of the repo, and not with code/docstestsanything to do with testing
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@bradzacher@armano2@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp