-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add pre-commit support #95
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contributions!
I first learned about the pre-commit project now 😉
I have a some questions.
.pre-commit-hooks.yaml
Outdated
description: TypeScript code auto-formatter. | ||
entry: tsfmt | ||
args: ['--verify'] | ||
language: system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use system
?
Is node
more appropriate? http://pre-commit.com/#node
My suggestions, We should use project local tsfmt, not system wide tsfmt.
I think you have a two or more project about tsfmt using. There project should be able to update dependencies independently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. I haven't used node
language before, but it seems like tsfmt should be compatible as-is.
.pre-commit-hooks.yaml
Outdated
entry: tsfmt | ||
args: ['--verify'] | ||
language: system | ||
files: \.ts$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the regexp?
I want to use \.tsx?$
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I tried to use pre-commit, but I can't do it.. I have a question. |
Sorry for the error. I thought I understood pre-commit + node but I didn't 🙇 . The solution is to add an - id: tsfmt
name: TypeScript Formatter (tsfmt)
description: TypeScript code auto-formatter.
entry: tsfmt --verify
language: node
files: \.tsx?$
additional_dependencies: ['typescript-formatter', 'typescript'] You can also specify a certain version of dependencies like using npm/yarn: additional_dependencies: ['typescript-formatter', 'typescript@2.2.2'] However, this will mean that there would need to be a new commit for each typescript version that changes typescript-formatter behaviour. Each update to the pre commit file could be recorded for users to use a certain version of typescript with. Example # Use the following SHAs:
# * typescript 1.9: aaaaaaaa
# * typescript 2.0: bbbbbbb
# * typescript 2.2: cccccccc
- repo: git@github.com:vvakame/typescript-formatter.git
sha: <sha>
[...] This is getting a bit complex, sorry. I think you wouldn't like this in your main repo, is that right? What I can do instead is maintain a dedicated pre-commit-tsfmt repository, like jshint. |
One possible additional complication. The |
sorry for late reply.
sounds good! I recommended it. |
This PR adds a file so that tslint can be used natively with pre-commit.
If this PR is accepted, I'll submit a PR to update the documentation on pre-commit's side too!