npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

githook-code-filter

v1.1.0

Published

在使用git commit命令之前对改动的文件按照配置的规则对代码进行匹配,匹配到之后不允许git提交此次改动

Downloads

1

Readme

在git commit前检测代码

在nodejs项目中的app.js文件中引入:
    const setCommitCheck = require('githook-code-filter');
    setCommitCheck([config]);
其中config为可选参数,代表校验规则。建议传入适用于自己需求的规则。

注意

1、.git/hooks/pre-commit文件不存在时会创建,存在会替换掉旧文件
2、需要先运行一次代码(node app.js),去触发文件的创建,该npm包才能生效
3、config为可选参数,具体格式如下:
    a、是一个对象
    b、对象中key值必须包含有js、css、html三个key
    c、每一个key值对应的均为数组,如不需要对该类文件做校验,仍需定义空数组
    d、数组中每一项为对象,至少包含rule属性,为正则规则,注意:对带有反斜杠的\需要转义
    e、note属性为可选属性,可自定义拦截后的输出提示信息
    f、目前js、css、html三个key分别对应支持检测css|scss|less、js|es、html|hb类型文件
        {
            "js": [{
                "rule": "/console/",
                "note": "请去除js文件中多余的console.log信息"
            }, {
                "rule": "/alert/",
                "note": "请使用其他方式代替alert输出信息"
            }, {
                "rule": "/error/",
                "note": ""
            }],
            "css": [{
                "rule": "/display:\\s*table/",
                "note": "table布局过于耗费性能,请用其他方式代替"
            }],
            "html": [],
        }

历史版本

| 版本 | 说明
| ------------- |:------- | 1.0.0 | feat:初步搭建可供应用的git commit拦截功能(存在关键性bug) | 1.1.0 | fix:修复 git commit 时,符合所有规则也无法正常提交的bug