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-futu

v2.1.1

Published

富途所有项目共享的ESLint规则,与[JavaScript编码规范](http://gitlab.futunn.com/web/webwiki/wikis/style-guidelines-javascript)对应。

Downloads

5

Readme

富途ESLint规则

富途所有项目共享的ESLint规则,与JavaScript编码规范对应。

预设场景

  • 浏览器 ✅
  • Node.js ✅
  • CommonJS ✅
  • ES6(ES2015) ✅
  • ES2017 ✅
  • Jest ✅
  • Vue.js ✅
  • jQuery ❌
  • AMD ❌

使用方式

1 安装依赖:

npm install eslint eslint-config-futu --save-dev

2 在项目web根目录上层新建.eslintrc.js文件

module.exports = {
    root: true,
    extends: 'eslint-config-futu',
    env: {
    },
    parserOptions: {
    },
    rules:{
        // 如果项目有特殊需求,可在此覆盖
    }
};

在TypeScript项目中使用

  1. 安装依赖
npm install eslint typescript eslint-config-futu --save-dev
  1. 在项目web根目录上层新建.eslintrc.js文件
module.exports = {
    root: true,
    extends: 'eslint-config-futu/typescript',  // 这里要使用'eslint-config-futu/typescript'配置
    env: {
        browser: true,
        node: true,
        amd: true
    },
    parserOptions: {
        ecmaVersion: 7,
        sourceType: 'module',
        // recommend to use another config file like tsconfig.eslint.json and extends tsconfig.json in it.
    		// because you may be need to lint test/**/*.test.ts but no need to emit to js.
    		// @see https://github.com/typescript-eslint/typescript-eslint/issues/890
    		project: './tsconfig.json'
    },
    rules:{
        // 如果项目有特殊需求,可在此覆盖
    }
}

注意事项

  • arrow-parens规则为always,如果项目有使用prettier,需要同样设置该选项为always(prettier 2.0默认为always)。

附:编辑器使用方式

不要全局安装ESLint工具,不要全局安装ESLint工具,不要全局安装ESLint工具。

WebStorm

设置(Preference) - 语言框架(Languages & Frameworks) - JavaScript - 质量工具(Code Quality Tools) - ESLint

勾上 启用(Enable),Node interpreter写 Node 的路径,一般会自动检测到,如果检测不到需要自己选一下。

ESLint package选择项目中的node_modules/eslint,注意是项目中的,不能是全局的。剩下配置保留现状即可。

sublime text

如果没有安装Package Control的可以先安装一下,说明见这里。https://packagecontrol.io/installation

然后安装SublimeLinter和SublimeLinter-contrib-eslint即可。

如果使用Package Control拉不出插件列表,可以设置一下Channel:打开命令输入框,找到Package Control: Add Channel,输入 https://git.oschina.net/mugood/PackageControl/raw/master/channel_v3.json 即可。

VSCode

安装ESLint插件,启用即可。

注:为什么不能使用全局ESLint工具

因为在项目中会通过npm在项目中安装eslint-config-futu,然后基于这个公共规则配置文件来使用ESLint。

然而ESLint有一个“Bug”,全局ESLint无法找到项目中的eslint-config-futu,所以无法应用公共规则配置文件。

所以只能使用项目中安装的eslint依赖。按上方编辑器的配置说明,编辑器均会使用项目中的eslint依赖。

如果不在编辑器中使用,想在命令行使用,可以有两种方法:

  1. 使用./node_modules/.bin/eslint,或者将这个命令写入npm scripts。在npm scripts中可以直接写eslint,会默认从./node_modules/.bin下查找eslint命令。
  2. 全局安装eslint-cli这个第三方库,然后使用eslint命令。

历史记录

2.1.1 2023-11-09

  • 删除一个ts规则:@typescript-eslint/no-inferrable-types

2.1.0-alpha.0 2022-03-25

  • 添加ts规则

2.0.0 2022-01-14

  • 正式发布2.0.0

2.0.0-alpha.2 2021-12-21

  • arrow-parens规则改为always(与prettier保持一致 & 预留向 TS 兼容)

2.0.0-alpha.1 2021-12-21

  • 禁用no-magic-numbers规则

2.0.0-alpha.0 2021-12-17

  • 修订诸多规范

1.1.0 2020-12-24

1.0.3 2017-04-20

  • 修正 tag 1.0.2

1.0.2 2017-04-18

  • 修正 no-use-before-define 规则,只做变量的检查,函数与类不做检查

1.0.1 2017-04-14

1.0.0 2017-03-30

  • 初始化规则