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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-config-lei

v0.0.16

Published

my own eslint config

Readme

eslint-config 配置

安装

$ npm install eslint-config-lei eslint-plugin-promise --save-dev

说明:由于本配置使用了promise插件,因此需要同时安装eslint-plugin-promise模块。

使用方法

配置文件

在项目根目录下新建文件.eslintrc.js

仅包含 ES6 语法时:

module.exports = {
  extends: 'lei',
};

包含 ES7 语法时:

module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    allowImportExportEverywhere: false,
  },
  extends: 'lei',
};

在基于mocha框架的单元测试中使用,在test目录下新建文件.eslintrc.js

module.exports = {
  extends: 'lei/mocha',
};

使用

执行以下命令即可:

$ eslint dir/**.js

如果需要自动格式化代码,在执行时添加--fix选项:

$ eslint dir/**.js --fix

配置文件

  • lei - 默认的配置,基于Node.js/ES6
  • lei/mocha - mocha测试环境
  • lei/wechat - 微信小程序环境

常见问题

1、如果在使用babel-eslint时报错,可能是该模块的 Bug,目前可以通过以下方法解决:

module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    allowImportExportEverywhere: false,
  },
  extends: 'lei',
  rules: {
    // 关闭以下规则
    'generator-star-spacing': 'off',
    'require-yield': 'off',
  },
};

2、在使用过程中,可能会遇到一些例外情况,比如需要更改参数对象的属性,可以通过eslint-disable-next来临时关闭对下一行的检查:

// eslint-disable-next-line no-param-reassign
param.xxx = 'ok';

注意:任何时候请勿使用eslint-disable来关闭eslint的检查,如果该备注不能与eslint-enable成对出现将会导致余下的程序不能正常获得检查

3、检查 HTML 文件内的 script 标签:

需要执行以下命令安装eslint-plugin-html插件:

$ npm install eslint-plugin-html --save-dev

并修改文件.eslintrc.js,载入eslint-plugin-html插件:

{
  plugins: [ 'html' ],
}

在 HTML 文件中,<script>标签需要包含type="text/javascript",比如:

<script type="text/javascript">
  var a = 10;
</script>

由于eslint命令默认只会检查.js后缀的文件,所以需要在执行命令时指定.html后缀,比如:

$ eslint --ext .js,.html . --fix

相关链接

License

The MIT License (MIT)

Copyright (c) 2016 Zongmin Lei <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.