Skip to content
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

Docs: contributing docs should say how to update rule doc code example snapshots #8997

Open
2 tasks done
kirkwaiblinger opened this issue Apr 26, 2024 · 2 comments
Open
2 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating

Comments

@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Apr 26, 2024

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Since #8382, we have snapshots of the eslint output on the code examples in the rule docs. However, our documentation doesn't say how to update those snapshots; if you change the code examples, the tests just fail locally and in CI.

I've been using yarn test -- -u to get them to update, but I'm not actually sure if that's the recommended way. (or should they just automatically update when running yarn test like our other snapshots do, in which case we should just make a code change?)

Ping @auvred

Affected URL(s)

https://typescript-eslint.io/contributing/local-development#validating-changes

@kirkwaiblinger kirkwaiblinger added triage Waiting for maintainers to take a look documentation Documentation ("docs") that needs adding/updating labels Apr 26, 2024
@auvred
Copy link
Member

auvred commented Apr 26, 2024

I'm +1 on adding some docs about snapshots and how to deal with them! In addition to ESLint output snapshots, we have rule schema snapshots. It would be nice to mention them as well.

https://github.com/typescript-eslint/typescript-eslint/tree/4858afde147a5ff6fa20ac1e73bc1c04692cef7a/packages/eslint-plugin/tests/schema-snapshots


Btw, we can also explain how to work with ast-spec snapshots. This may seem non-trivial!
There is a great explanation from Brad: #7649 (comment) 👍

  • within this folder create a folder called fixtures.

  • within fixtures create a _error_ folder

  • within _error_ create a folder with a name for your case - for example maybe using-initializer?

  • within that folder, create a file called fixture.ts

  • within that file add your test code (eg for(using foo in {});)

  • cd packages/ast-spec && yarn test to run the fixture tests and generate the necessary snapshots.

@JoshuaKGoldberg
Copy link
Member

Yeah I cd eslint-plugin; yarn test schemas -u to update snapshots. +1 to docs

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating
Projects
None yet
Development

No branches or pull requests

3 participants