Skip to content

Scoped node packages produce invalid config #268

Description

@mxr

I'm trying to set up a mirror for @bugron/validate-dependabot-yaml. I'm running:

$ pre-commit-mirror . \
  --language node \
  --package-name '@bugron/validate-dependabot-yaml' \
  --id validate-dependabot-cli \
  --entry validate-dependabot-yaml \
  --files-regex '^(\.github|config)/dependabot\.ya?ml$'

The produced YAML file ends up with name: @bugron/validate-dependabot-yaml (no quotes). The problem is @ (as the first character) is one of YAML's reserved indicators so this produces invalid YAML and the hook can't load.

One fix is to change name: {name} in the all/.pre-commit-hooks.yaml to name: {name!r}. This is what we do for description.

Another is to use pyyaml to dump the file instead of string formatting, but it's more involvd.

With either fix I verified that the same pre-commit-mirror command produces a valid .pre-commit-hooks.yaml file with name: '@bugron/validate-dependabot-yaml' (with quotes) and I verified that the repo runs with pre-commit try-repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions