Skip to content

mark snaps with @generated #2026

@maxheld83

Description

@maxheld83

Since snaps from expect_snapshot_*() are automatically generated, they should be treated differently by tooling.

For example, I wouldn't want to run a linter on them.

There's a (somewhat widely?) used "standard", the @generated marker for this purpose: https://generated.at
The @generated marker is specifically for generated files which should be committed to SCM
(so not .gitignored).

For example, GitHub's super-linter can be set up to ignore all files thus marked.

I've so far made do with my own transformer like so:

https://github.com/dataheld/elf/blob/0fbc0fdbac7db70c0751b00819423fd58ce1f39e/R/tests.R#L1-L18

Happy to add a PR to this effect, if people find this useful.
(The transform arguments docs suggest a different use,
so @generated probably shouldn't happen via that argument.

Needs some care as to how this can be wrapped in different file formats, i.e. for markdown "<!--@generated-->" seemed idiomatic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions