btford / write-good

Naive linter for English prose
MIT License
4.95k stars 189 forks source link

Add pre-commit hook for write-good #119

Closed askb closed 4 years ago

askb commented 4 years ago

Signed-off-by: Anil Belur abelur@linuxfoundation.org

RichardLitt commented 4 years ago

Does this solve a need? What is this for?

zxiiro commented 4 years ago

Hi @RichardLitt this file allows folks to use pre-commit (https://pre-commit.com/) to automatically install and run write-good as a git hook and be part of their regular git workflow. The hook after installed will report linting issues automatically when they run git commit in their projects where the hook is installed.

This is handy if you want to allow folks using pre-commit to be able to install write-good as a hook directly and officially from the write-good project. This file should simply exist and does not affect the write-good project other than making it more convenient for folks who want to install the hook.

askb commented 4 years ago

@zxiiro thanks for following up on this, @RichardLitt can we get a review on this please.

RichardLitt commented 4 years ago

Does this file need to be checked into both git and the npm package?

zxiiro commented 4 years ago

This only needs to exist in the Git repo. pre-commit installs hooks directly from Git so you do not need to include it in the npm package.

zxiiro commented 4 years ago

I should mention that you may want to adjust the "files" parameter after merging this PR to include all of the file extensions you want to support.

RichardLitt commented 4 years ago

Thanks, @zxiiro. Can we add the filename to an .npmignore file, then? As well, I don't know what that file extensions parameter should be. @askb Can you do this work?

zxiiro commented 4 years ago

As well, I don't know what that file extensions parameter should be.

Basically the files list is a list of file extensions you want write-good to automatically scan for if someone were to install write-good as a pre-commit hook in their project. It's mainly convenience really because folks using this hook can override the "files" parameter in their project.

The current list looks like it covers common Markdown and ReStructured file extensions so it means this hook will automatically run write-good against those files in projects that install the pre-commit hook.

RichardLitt commented 4 years ago

you want write-good to automatically scan for

I wouldn't be using this functionality. The list of extensions should be up to the contributors who would be. If it needs to be in this PR, it's their responsibility to add them. If the current list works, good.

zxiiro commented 4 years ago

you want write-good to automatically scan for

I wouldn't be using this functionality. The list of extensions should be up to the contributors who would be. If it needs to be in this PR, it's their responsibility to add them. If the current list works, good.

Works for me, let's wait for @askb to update this patch. Thanks!

askb commented 4 years ago

@RichardLitt @zxiiro I've included the .npmignore file as requested. Let me know if anything else needs to be done.

RichardLitt commented 4 years ago

Looks good to me. Patched. Thanks!