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

better-code

v3.3.3

Published

cli tool to integrate eslint,stylelint,prettier,jest,browserslit to let you write better code

Downloads

12

Readme

Better-Code

前端 cli 工具实现快速集成 eslint,stylelint,prettier,jest,browserslit,vscode,babel 并解析 js 文件生成单元测试模板

功能

  1. 提供交互,根据用户选项生成 eslint,stylelint,prettier,jest,browserslit,vscode,babel 的配置文件,根据用户选项自动安装 node_module,自动集成 package.json 的 npm 命令.

  2. 读取 js,jsx 文件,并自动生成 jest 单元测试模板.

安装

npm install -g better-code

使用

打开 cmd 或 bash,输入better-code,按照提示输入对应命令.

可用命令

better-code

展示所有可用命令

better-code [operate] [rootdir]

执行 operate 集成在目录 rootdir。

rootdir 默认当前目录。

operate 可根据上一条命令查看。

better-code nodeServer dir

在 dir 生成新的 nodeServer 项目,自动集成测试,目录最佳实践,性能分析、自动安装,直接可用。

better-code unit [dir|file] -d [targetDir] -f -mock

-f 表示生成单元测试文件时候覆盖已经存在的单元测试文件

-d 参数后面的参数作为单元测试模板的输出目录。默认和源代码文件同目录。

-mock 代表自动生成依赖 mock(默认为 false,因为默认 jest 配置是 autoMock)。

[dir|file]可以输入若干个文件,目录,程序会取他们所有包含的文件进行生成。目录会包含所有子目录文件。 。

例子:

better-code unit test.js src -d dist -f

会解析当前目录下 test.js 文件和 src 文件夹下所有.js,.jsx 文件,在当前目录/dist 文件夹下生成.test.js(x)文件。

子命令内部操作

better-code eslint [rootdir]

集成 eslint

新建文件

.eslintrc.js 同名覆盖
.eslintignore

修改文件

package.json 中的
devDependencies和 scripts 字段

better-code stylelint [rootdir]`

集成 stylelint

新建文件

stylelint.config.js 同名覆盖

修改文件

package.json 中的
devDependencies和 scripts 字段

better-code prettier [rootdir]

集成 prettier

新建文件

prettier.config.js 同名覆盖
.prettierignore

修改文件

package.json 中的
devDependencies和 scripts 字段

better-code jest [rootdir]

集成 jest

新建文件

jest.config.js 同名覆盖

修改文件

package.json 中的
devDependencies和 scripts 字段

better-code browsers [rootdir]

集成 browserslit

新建文件

.browserslistrc 同名覆盖

修改文件

package.json 中的scripts 字段

better-code babel [rootdir]

集成 babel

新建文件

babel.config.js 同名覆盖

修改文件

package.json 中的devDependencies和 scripts 字段

better-code vscode [rootdir]

集成 vscode

新建文件

jsconfig.json 同名覆盖
.vscode/settings.json

自动安装插件

['ms-ceintl.vscode-language-pack-zh-hans', '中文语言包'],
['dbaeumer.vscode-eslint', 'eslint'],
['esbenp.prettier-vscode', 'prettier'],
['jasonnutter.search-node-modules', 'node_module搜索'],
['ms-vscode.sublime-keybindings', 'sublime 快捷键映射'],
['msjsdiag.debugger-for-chrome', 'chrom debuger'],
['bengreenier.vscode-node-readme', '模块右键跳转到readme页面'],
['eamodio.gitlens', 'gitlens'],
['shinnn.stylelint', 'stylelint'],
['techer.open-in-browser', '右键打开在浏览器中打开'],
['miramac.vscode-exec-node', 'F8执行选中代码'],