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

inithusky

v1.0.7

Published

Install git hooks automatically.

Downloads

13

Readme

npm_version

initHusky

配置 hushy 和 lint-staged 太繁琐?安装 initHusky 一键帮你搞定。

Feature

  • 可选自动安装 commitlint git hook,向远端 Git 仓库提交代码时,自动进行 commitlint 检测
  • 可选自动安装 eslint git hook,向远端 Git 仓库提交代码时,自动对增量 Javascript 代码进行 Eslint 检测
  • 可选自动安装 stylelint git hook,向远端 Git 仓库提交代码时,自动对增量 Css 代码进行 stylelint 检测

Installation

首先,全局安装 inithusky 指令:

npm install -g inithusky

接着,便可以在任意项目的根目录下创建 Git 钩子。

Use

进入任意项目根目录,执行 inithusky

$ inithusky

选择你要安装的钩子,提供三种钩子:

  1. commitlint(调用 husky 的 commit-msg 钩子)
  2. eslint(调用 husky 的 pre-commit 钩子)
  3. stylelint(调用 husky 的 pre-commit 钩子)
$ inithusky
欢迎使用自动化 Git 钩子安装程序
? 是否需要安装 commitlint Git 钩子? Yes
? 是否需要安装 Eslint Git 钩子?(对 Javascript 代码进行风格规范检测) Yes
? 是否需要安装 Stylelint Git 钩子?(对 CSS 代码进行风格规范检测) Yes

确定你想安装的钩子之后,

  1. 将会自动修改项目根目录下的 package.json,添加相关依赖,添加 husky 与 lint-staged 相关配置
  2. 针对 commitlint 钩子,在根目录下新增配置文件 commitlint.config.js
  3. 针对 eslint 钩子,在根目录下新增配置文件 .eslintrc.js 配置文件
  4. 针对 stylelint 钩子,在根目录下新增配置文件 .stylelint.js 配置文件
  5. 根据所选钩子,自动生成 .huskyrc.js 配置文件,存放 husky 相关配置
  6. 根据所选钩子,自动生成 lint-staged.config.js 配置文件,存放 lint-staged 相关配置
  7. 自动安装依赖

依赖安装完毕,就可以愉快的使用了。

注意

  1. 在项目根目录执行该命令,且确保根目录下已经有了 package.json 文件
  2. Git hooks 生效依赖于前置命令 .git 文件夹,确保使用该命令时,已经在根目录进行了 git init 初始化
  3. commitlint 具体规则请看 commitlint
  4. eslint 默认采用了 eslint-airbnb 的规范,需要修改 eslint 规范可自行修改根目录下的 .eslintrc.js 文件
  5. eslint 规范检测默认针对 /src/*.js 文件,需要修改生效范围,自行修改 package.json 下的 lint-stage 配置
  6. stylelint 默认采用了 stylelint-config-standard 的规范,且兼容 SASS ,需要修改 stylelint 规范可自行修改根目录下的 .stylelint.js 文件
  7. stylelint 规范检测默认针对 /css/*.css 文件,需要修改生效范围,自行修改 package.json 下的 lint-stage 配置
  8. 只要选择了任何一个钩子的安装,将会自动生成 husky 的配置文件 .huskyrc.js,且如果 package.json 下原本存在 husky 相关配置,将会被覆盖删除,对于一些旧项目需要注意
  9. 选择了安装 eslint 及 stylelint,除了自动生成 husky 的配置文件 .huskyrc.js,还好额外生成 lint-staged 的配置文件 lint-staged.config.js,且如果 package.json 下原本存在 lint-staged 相关配置,将会被覆盖删除,对于一些旧项目需要注意

License

MIT