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

hkt-cli

v0.0.32

Published

我自己的cli工具,自动生成项目的 eslint、stylelint、commitlint规则和配置文件

Downloads

5

Readme

构建一个自己的 cli 工具

全局安装cli工具

npm install -g hkt-cli

使用说明

检测 hkt-cli 的版本是否最新的

hkt-cli

查看 hkt-cli 命令行说明

hkt-cli -h

init-eslint-js           初始化 JS 项目 eslint
install-eslint-js        安装 JS 项目 eslint 相关依赖
init-prettierrc          初始化项目 prettierrc
init-stylelint           初始化项目 stylelint
init-eslint-ts           初始化 TS 项目 eslint
install-eslint-ts        安装 TS 项目 eslint 相关依赖
init-eslint-react-ts     初始化 typescript react 项目 eslint
install-eslint-react-ts  安装 typescript react 项目的 eslint 相关依赖
init-eslint-react-js     初始化 javascript react 项目 eslint
install-eslint-react-js  安装 javascript react 项目的 eslint 相关依赖
install-stylelint        安装stylelint相关依赖
init-commitlint          初始化项目 commitlint
install-commitlint       安装commitlint相关依赖

配置专属的 eslint 规则

会自动在根目录生成 .eslintrc.js.eslintignore.prettierrc.js 文件

  • eslint for javascript

    1. 初始化 JS 项目 eslint 规则
    hkt-cli init-eslint-js
    1. 安装 JS 项目 eslint 相关依赖
    hkt-cli install-eslint-js
  • eslint for typescript

    1. 初始化 TS 项目 eslint 规则
    hkt-cli init-eslint-ts
    1. 安装 TS 项目 eslint 相关依赖
    hkt-cli install-eslint-ts
  • eslint for React + Typescript

    1. 初始化 React + TS 项目 eslint 规则
    hkt-cli init-eslint-react-ts
    1. 安装 React + TS 项目 eslint 相关依赖
    hkt-cli install-eslint-react-ts
  • eslint for React + javascript

    1. 初始化 React + JS 项目 eslint 规则
    hkt-cli init-eslint-react-js
    1. 安装 React + JS 项目 eslint 相关依赖
    hkt-cli install-eslint-react-js
  • stylelint

    1. 初始化 stylelint
hkt-cli init-stylelint
  1. 安装 stylelint 依赖
hkt-cli install-stylelint
  • prettier
    1. 配置 prettier,配合 esllint 使用
hkt-cli init-prettier
  • commitlint
    1. 初始化 commitlint
hkt-cli init-commitlint
  1. 安装 commitlint 依赖, 其中已经包含 huskylint-staged

在安装 husky 依赖前,请在 package.jsonscript 中新增 "prepare": "husky install",这样在安装 husky 后会自动启动 Git hooks 功能,相当于手动执行 npx husky install

hkt-cli install-commitlint
  1. 手动在项目的 package.json 中配置 commitlintlint-staged
// 具体 lint-staged 要执行什么操作,根据自己的项目而定,下面只是一个实例
"lint-staged": {
    "./src/**/*.{js,ts,tsx,jsx}": [
      "eslint --fix",
      "prettier --write",
      "git add"
    ],
    "./src/**/*.{css,less,scss}": [
      "stylelint --syntax less --fix",
      "git add"
    ]
  }
  1. 配置 huskycommitlintpre-commit
// 自动生成 .husky/commit-msg,执行 commitlint
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'

// 自动生成 .husky/pre-commit 执行 lint-staged
npx husky add .husky/pre-commit "npx lint-staged"

后续更新

  • 生成项目脚手架