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

eslint-config-guo

v0.10.0

Published

my own eslint config with ES5 ES6 ES7 Promise Mocha Vue React React-Native

Downloads

15

Readme

eslint-config

安装

$ npm install eslint-config-guo --save-dev

使用方法

配置文件

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

仅包含 ES6 语法时

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

包含 ES7 语法时

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

包含 Promise 语法时

需要先安装 eslint-plugin-promise 插件

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

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

module.exports = {
  extends: 'guo/promise',
};

mocha

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

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

Vue

需要先安装 eslint-plugin-html 插件

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

可能还需要 babel-eslint 插件

$ npm install babel-eslint --save-dev

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

module.exports = {
  extends: 'guo/vue',
};

使用 --ext .vue 添加对 vue 文件的检查:

$ eslint --ext .js,.vue src

React

需要先安装 eslint-plugin-react 插件

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

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

module.exports = {
  extends: 'guo/react',
};

React 规则

React-Native

需要先安装 eslint-plugin-reacteslint-plugin-react-native 插件

$ npm install eslint-plugin-react --save-dev
$ npm install eslint-plugin-react-native --save-dev

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

module.exports = {
  extends: 'guo/react-native',
};

React-Native 规则

AVA

需要先安装 eslint-plugin-ava 插件

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

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

module.exports = {
  extends: 'guo/ava',
};

AVA 规则

使用方法

执行以下命令即可:

$ eslint dir

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

$ eslint dir --fix

常见问题

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

module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    allowImportExportEverywhere: false,
  },
  extends: 'guo',
  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 成对出现将会导致余下的程序不能正常获得检查