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

@tangbin/fabric

v1.0.23

Published

提供统一的Prettier、Eslint、Typescript、Commit Lint和Babel规则。

Downloads

5

Readme

@tangbin/fabric

提供统一的 Prettier、Eslint、Babel 和 TypeScript 规则以供使用。

Install

#npm
npm install @tangbin/fabric

#pnpm
pnpm add @tangbin/fabric

由于使用 pnpm 安装会导致一些 bin 目录下的命令无法执行,所以请在执行 pnpm install 之前,在根目录下创建 .npmrc 配置文件

shamefully-hoist=true

默认情况下,pnpm 创建一个半严格的 node_modules,这意味着依赖项可以访问未声明的依赖项,但 node_modules 之外的模块不行。 通过这种布局,生态系统中的大多数的包都可以正常工作。 但是,如果某些工具仅在提升的依赖项位于根目录的 node_modules 时才有效,您可以将其设置为 true 来为您提升它们。

Usage

npx tb_fabric --init
# ? 请选择项目类型:(暂时只支持react、vue、util和node) react
# ? 是否需要创建 Editorconfig 配置文件? Yes
# ? 是否需要创建 Prettier 配置文件? Yes
# ? 是否需要创建 Typescript 配置文件? Yes
# ? 是否需要创建 Babel 配置文件? Yes
# ? 是否需要创建 Eslint 配置文件? Yes
# ? 是否需要创建 Browserslist 配置文件? Yes
# ? 是否需要创建 Commit Lint & Changelog 配置文件? Yes

# 配置文件 .editorconfig 创建成功
# 配置文件 .prettierrc.js 创建成功
# 配置文件 .prettierignore 创建成功
# 配置文件 env.d.ts 创建成功
# 配置文件 tsconfig.json 创建成功
# 配置文件 babel.config.js 创建成功
# 配置文件 .eslintrc.js 创建成功
# 配置文件 .eslintignore 创建成功
# 配置文件 .browserslistrc 创建成功
# 配置文件 .cz-config.js 创建成功
# 配置文件 .versionrc.js 创建成功
# 配置文件 commitlint.config.js 创建成功

可以对生成的配置文件进行按需修改。

Prettier

npm set-script prettier "prettier --write src"

npm run prettier

Commit Lint & Changelog

要正常使用 commit lint 和 changelog 的功能,需要进行一些前置工作。

首先需要在 package.json 中设置 script,然后执行一系列命令:

npm set-script prepare "husky install"
npm set-script commit "cz"
npm set-script release "standard-version"

# install husky
npm run prepare

# add hooks
npx husky add .husky/pre-commit "npx lint-staged"
# 最后的 ${1} 可能无法正常生成,需要手动填充。。
npx husky add .husky/commit-msg  'npx --no -- commitlint --edit ${1}'

手动修改 .husky/commit-msg 文件

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}

package.json 文件中添加如下属性:

{
  "config": {
    "commitizen": {
      "path": "node_modules/cz-customizable"
    }
  },
  "lint-staged": {
    "*.{ts,tsx}": "eslint",
    "*.{js,css,less,md,ts,tsx}": "prettier --write"
  }
}

最后可以使用如下命令提交代码和生成 changelog:

# commit
git add .
npm run commit

# create changelog
npm run release