tbroadley / spellchecker-cli

A command-line tool for spellchecking files.
MIT License
119 stars 16 forks source link

Before Release of `pre-commit` Addition #116

Closed mindlessroman closed 4 months ago

mindlessroman commented 11 months ago

I realized that the README will probably need an update about which rev to use.

- repo: https://github.com/tbroadley/spellchecker-cli
  rev: <INSERT RELEASE HERE>
  hooks:
    - id: spellchecker-cli
      name: spellcheck
      types: [markdown]
      stages: # optional: if you want to specify stages to run the hook on
        - '' # see https://pre-commit.com/#confining-hooks-to-run-at-certain-stages

In the mean time, my team will use the commit hash, but just for awareness, @tbroadley.

psychemedia commented 10 months ago

For some reason I am getting an InvalidManifestError for the following pre-commit-config.yaml file. Any hints as to what's wrong (is there a pre-commit-config.yaml validator anywhere?)

repos:
  - repo: https://github.com/tbroadley/spellchecker-cli
    rev: v6.1.1
    hooks:
      - id: spellchecker-cli
        name: spellchecker
        description: A pre-commit implementation for spellchecker-cli
        entry: spellchecker
        language: node
        types: [markdown]
tbroadley commented 10 months ago

Looking at this part of the pre-commit documentation: https://pre-commit.com/#pre-commit-configyaml---hooks

I don't think the hooks object in a .pre-commit-config.yaml can have description, entry, or language properties.

We should adjust the example in this project's README.

psychemedia commented 10 months ago

I'm successfully using:

  - repo: https://github.com/markdownlint/markdownlint
    rev: v0.12.0
    hooks:
      - id: markdownlint
        name: Markdownlint
        description: Run markdownlint on your Markdown files
        entry: mdl
        language: ruby
        files: \.(md|mdown|markdown)$

Are those fields perhaps defined as part of a particular pre-commit action? Is pre-commit forgiving?

I can't find any combination of keys (yet!), or even a minimal combination (yet!) that will run for me with spellchecker-cli.

psychemedia commented 10 months ago

FWIW, I am using pre-commit version: 3.4.0

mindlessroman commented 10 months ago

@psychemedia - I've successfully used it referencing the commit hash. Since the release you picked doesn't have a pre-commit-config.yaml, I don't think it can successfully run.

-   repo: https://github.com/tbroadley/spellchecker-cli
    rev: e4879b5 # TODO: Release tag
    hooks:
      - id: spellchecker-cli
        name: spellcheck
        types: [markdown]
        stages:
          - "pre-commit"

@tbroadley I think at the least, in the mean time having the README.md point to the commit hash until there's a release will probably help with this. I can make a PR for this?

psychemedia commented 10 months ago

@mindlessroman ah - that seems to do the trick... thanks...

psychemedia commented 10 months ago

Is there a way of specifying dictionaries in the hook config?

psychemedia commented 10 months ago

If I try to pass args from my local .pre-commit-config,yaml file, such as the following (or variants thereof):

args: ['--no-suggestions', '--dictionaries', 'dictionary.txt']

I get an error:

spellchecker.............................................................Failed
- hook id: spellchecker-cli
- exit code: 1

A list of files is required.

Could this be something to do with pass_filenames attribute (default: true) in the hook declaration in the repo?

tbroadley commented 10 months ago

Hey, I'm sorry I haven't responded in a couple of weeks. To be honest, I don't expect I'll have time in the next six weeks to work on fixing the bugs that folks have pointed out in this issue. I would definitely accept PRs to fix them! I just don't think I can fix them myself. Thanks again for pointing these things out.

mindlessroman commented 10 months ago

I can try to take a stab at this shortly since I introduced it XD

mindlessroman commented 10 months ago

Is there a way of specifying dictionaries in the hook config?

@psychemedia You can specify the dictionaries in the spellcheckerrc.[*] file (my team's is in a yaml file):

files:
  - "**/*.md"
  - "!SUPPORT.md"
  - "!CODE_OF_CONDUCT.md"
  - "!SECURITY.md"
dictionaries:
  - dictionary.txt

The precommit should pick up these settings? But I can take a peek about making it so it can be handled in the pre-commit hook as well

mindlessroman commented 5 months ago

@tbroadley - did the pre-commit make it into the new release?

tbroadley commented 5 months ago

No, I never cut a new NPM release after #115 merged. I figured that it wasn't necessary because pre-commit would install the repo from GitHub, not NPM. But I can cut a new minor release just in case.

tbroadley commented 5 months ago

Just published 6.2.0.

mindlessroman commented 4 months ago

Just published 6.2.0.

Awesome! I believe it would need to have the version tag that included the .pre-commit-hooks.yaml file.

mindlessroman commented 4 months ago

Should be good to go now!