-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… to generate schema types
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 on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Codecov Report
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/eslint-plugin/tests/schema-snapshots/type-annotation-spacing.shot
Show resolved
Hide resolved
packages/eslint-plugin/tests/schema-snapshots/padding-line-between-statements.shot
Show resolved
Hide resolved
packages/website/src/components/editor/createProvideCodeActions.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant for another PR?
There was a problem hiding this comment.
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.
packages/eslint-plugin/tests/schema-snapshots/naming-convention.shot
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
Overview
@JoshuaKGoldberg I went through with my threat for no reason other than it seemed fun.
Previously we used
json-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:
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.
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.