mbrehin / git-precommit-checks Goto Github PK
View Code? Open in Web Editor NEWCustomizable checks on pre-commit (staged) contents
Home Page: https://mbrehin.github.io/git-precommit-checks/
License: MIT License
Customizable checks on pre-commit (staged) contents
Home Page: https://mbrehin.github.io/git-precommit-checks/
License: MIT License
Because asciinema cannot be embed on README.md
a PNG has to be extraced and linked to the asciinema.com recording.
parseContents(…)
regexFromStr(regex)
colorizedLog(logLevel, text)
?colorizedLogTitle(logLevel, hookTitle, text)
?printErrors(severity, errors, hookTitle)
?Because we won't always want to group configuration in package.json
we must provide an alternative.
Instead of expecting a static alternative (ie. git-precommit-checks.rc
), we'd like to use a --config
option that would allow configuration to be loaded from where we want.
Hi
when I am amending a commit, I get the warning
there is no file to check
IMHO it should check all staged files again.
Write default README.md with expected behavior and configuration options.
Hello,
The following rule :
{
"filter": "\.js$",
"message": "You’ve got leftover console.log
",
"regex": "console\.log",
"nonBlocking": "false"
}
Create the commit. I must remove attribut "nonBlocking" to forbid the creation of the commit.
When there is no configuration, the error message should be more explicit than:
Pre-commit checks failed due to unexpected error. TypeError: Cannot destructure property
patterns
of 'undefined' or 'null'.
at run (/home/myuser/path/to/myproject/node_modules/git-precommit-checks/index.js:26:33)
I know configuring is already mentionned in the documentation, but the error message should be clearer.
Why you does not support current node LTS version, which is 8.9.0? I want use your project in enterprise environment and failed with it.
Some people get an error like `fatal: … unknown revision or path not in the working tree'.
Using POSIX double dash to prefix files path when running diff command should prevent this.
Hi,
That would be great if your project could read from other places than package.json.
I'm using Rush and I don't have root package.json file.
Maybe a .precommit-check.json
or something similar would be good ?
Salut Maxime,
Est-il possible d'ignorer le contenu d'un dossier ?
Merci !
Automate releases and npm publishing using semantic-release.
There are files we don’t want to check.
For instance: package-lock.json
or other dependencies trees files (Gemfile.lock
…).
Create CONTRIBUTING.md
describing project expectations:
Files with spaces in their name cannot be processed.
When running checks on large files, an error occurs:
Couldn’t run 'exec' command: RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
This could be (temporarily) be bypassed using upcoming feature for excluded files/patterns #34.
Hello,
The following rule :
{
"filter": "\.js$",
"message": "You’ve got leftover console.log
",
"regex": "console\.log",
"nonBlocking": "false"
}
Create the commit. I must remove attribut "nonBlocking" to forbid the creation of the commit.
Current display only lists files with matched patterns.
We should enhance that display with the targeted/guilty lines.
Remove grep and sed, manage them with JS :
`${gitDiffBase} --unified=0 ${file} | grep -E "^(\\+[^\\+]|@@)" | sed -E "s/^\\+\\s*//"`
Most of the time the patterns we're looking at code chunks that should be removed (or transformed?).
It would be great to have an auto-remove
option per rule (I'm not quiet sure of option’s name).
Here is an example:
"git-precommit-checks": {
"rules": [
{
"filter": "_spec\\.rb$",
"message": "Your RSpec test suite is trimmed down by `focus` tags",
"regex": "(?:,focus: true|:,focus => true)",
"auto-remove": true,
},
{
"filter": "\\.rb$",
"message": "Your Ruby file seems to have an active `binding.pry` call",
"regex": "(^[^#]*\\bbinding\\.pry)",
"auto-remove": true,
}
]
}
…
This should remove matched pattern and auto-stage updates:
it 'has a valid kind', focus: true do
=> it 'has a valid kind' do
Hi there!
I am trying to setup git-precommit-checks
but the rule about FIXME|TODO
does not work because of the filter.
If I remove the filter it works well, if I set it up the rule seems to be ignored.
I followed the docs and copy/pasted the filter but nothing happens.
Can you help me to find where I did it wrong?
My config:
"git-precommit-checks": {
"display": {
"offendingContent": true,
"rulesSummary": true,
"verbose": true,
"shortStats": true
},
"rules": [
{
"nonBlocking": "true",
"message": "You've got leftover `console.log`",
"regex": "^(?!.*//).*console\\.log\\("
},
{
"message": "You've got leftover conflict markers",
"regex": "/^[<>|=]{4,}/m"
},
{
"filter": "^package\\.json$",
"message": "You have unfinished devs",
"nonBlocking": "true",
"regex": "/(?:FIXME|TODO)/i"
}
]
},
Thank you in advance for your help!
Because hooks
is too generic and probably used by many other modules, we'd better load rules from a more specific scope.
This would be also easier to understand and search if it uses its own module name.
git-precommit-checks
package.json
versionManage new notification
configuration option: use system notification to print checks summary to user.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.