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

selling-lint-cli

v0.0.5

Published

s-lint命令行工具

Downloads

4

Readme

先使用下列任一命令安装脚手架

npm install -g selling-lint-cli
# OR
yarn global add selling-lint-cli

安装之后,你就可以在命令行中访问s-lint命令。你可以通过简单运行s-lint,看看是否展示出了一份所有可用命令的帮助信息,来验证它是否安装成功。

你还可以用这个命令来检查其版本是否正确:

s-lint --version

如需升级全局的selling-lint-cli包,请运行:

npm upgrade -g selling-lint-cli
# OR
yarn global upgrade --latest selling-lint-cli

s-lint提供了三个命令,init、init-git-hooks和upgrade,下面分别介绍这三个命令:

1. init命令

在工程路径下,运行以下命令来为工程加上lint规范

s-lint init

随后命令行会列举可选的规范类型,目前包括eslint、stylelint及commitlint,默认全选,使用上下键切换目标选项,空格键可切换选中态,回车确认。

image.png

如果选择的规范包含eslint,则会继续询问要初始化的eslint类型,如vue、react、taro等,该选项为单选,选择完毕后将开始进行初始化。

image.png

cli将按照所选的规范类型依次进行初始化,单个规范的初始化过程包括

  1. 检查并移除旧包,包括项目内的冗余依赖
  2. 检查并移除旧[xxx]rc.js文件
  3. 安装目标规范的依赖
  4. 添加对应的rc文件,如.eslintrc.js、.stylelintrc.js等

对于commitlint规范,cli还会额外安装husky依赖,并在package.json中增加husky配置。期间命令行将提示当前的大致进度。

init的执行流程图如下: image.png

2. init-git-hooks命令

在工程路径下,运行以下命令可单独初始化commitlint规范

s-lint init-git-hooks

3. upgrade命令

在工程路径下,运行以下命令可升级lint规范,目前暂不支持升级单个lint规范,仅支持升级到规范的最新版本

s-lint upgrade

cli会依次尝试对三个规范进行升级,单个规范的升级过程如下:

  1. 检查是否安装了当前规范以及当前是否为最新版本,如果是则直接跳过后续步骤
  2. 安装最新lint规范
  3. 更新rc文件

更新rc文件时,如果是commitlint或stylelint规范,直接复制最新的模板文件到工程根路径下即可;如果是eslint规范,则先扫描原rc文件,判断eslint类型,再进行模板替换,如果扫描失败,则再次询问要升级的eslint类型。

cli所支持的eslint类型和lint的相关安全依赖分别保存在scripts/eslintType.js和scripts/safeDeps.js中,文件的内容分别由npm run scan-eslint-type和npm run scan-deps命令自动扫描生成,无需手动维护。这两个命令已添加到npm run build操作流中,因此只需执行build命令即可。

upgrade会依次调用核心函数checkAndUpgradeLint三次,尝试对三个规范进行升级,该函数的执行逻辑如下: image.png

以上三个命令整体的执行原理如下图: image.png