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

@ntesmail/shark-eslint

v1.1.6

Published

deploy eslint for your project

Downloads

17

Readme

自动为您的项目部署 eslint

如果您的项目有部署 eslint 的需求,可使用本工具为您的项目自动部署 eslint,使用一次部署生效后,后来的同学就无需其他奇怪的操作,直接 npm install 的时候,自动会加上 git pre commit 的钩子。在 commit 的时候自动检测代码,检测有 error 就终止 commit,并查看 控制台输出,定位错误,修改错误后再次 commit,直到没有 error 后 commit 成功。

如何在项目中部署

  1. 为你的代码编辑器或者 IDE 安装 ESLint(强烈推荐,开发时实时检测报错,第一时间发现错误并及时修改) 和 EditorConfig 插件。
  2. 使用 npm 全局安装 eslint 和 shark-eslint: npm i -g eslint @ntesmail/shark-eslint
  3. 在命令行里切换到您的项目下,运行 shark-eslint, 使用 -t 参数指定 shark-eslint-configs 仓库中的 eslintrc.json 模板,如 shark-eslint -t ng

注意:如果你的项目目录结构和普通的项目不一样,请检查 eslint 和 eslint--fix 脚本中检查 js 文件的目录。

日常开发中建议

由于加入了 git pre commit 的钩子脚本,每次 commit 都会运行 npm run eslint 来检查js文件,所以 commit 失败时,不要惊慌,要淡定,可以参考以下指引:

  1. 使用编辑器 eslint 插件的 fix 功能尝试修复单个文件中,可修复的一些错误。
  2. 运行 npm run eslint--fix 尝试自动修复所有 js 文件中一些可以修复错误。
  3. 如果编辑器配置问题较多,如缩进类型,换行符号等问题,建议尝试配合 .editorconfig 文件,统一编辑器的配置。
  4. 仔细阅读控制台输出,如果某一条检验规则出现次数频繁,且你非常不喜欢这条规则,可以在 .eslintrc.json 文件中找到此条规则,将其注释掉。

运行 shark-eslint 时,发生了什么?

  1. 生成了 .editorconfig、.eslintrc.json、.eslintignore、pre-commit 四个文件。
  2. 为你项目中的 package.json 文件写入了四个 script:eslint、eslint--fix、cp-pre-commit、postinstall。
  3. 执行一次 cp-pre-commit 脚本,拷贝 pre-commit 文件到 .git/hooks/ 目录下,使 git commit 的钩子脚本生效。