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-plugin-bf-eslint

v1.0.4

Published

bf es plugin

Downloads

6

Readme

eslint-plugin-bf-eslint-plugin

bf es plugin

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-bf-eslint-plugin:

npm install eslint-plugin-bf-eslint-plugin --save-dev

Usage

In your configuration file, import the plugin eslint-plugin-bf-eslint-plugin and add bf-eslint-plugin to the plugins key:

import bf-eslint-plugin from "eslint-plugin-bf-eslint-plugin";

export default [
    {
        plugins: {
            bf-eslint-plugin
        }
    }
];

Then configure the rules you want to use under the rules key.

import bf-eslint-plugin from "eslint-plugin-bf-eslint-plugin";

export default [
    {
        plugins: {
            bf-eslint-plugin
        },
        rules: {
            "bf-eslint-plugin/rule-name": "warn"
        }
    }
];

Configurations

TODO: Run eslint-doc-generator to generate the configs list (or delete this section if no configs are offered).

可用规则

bf-no-magic-numbers

基于 ESLint 官方 no-magic-numbers 规则改造,禁止使用魔法数字。

新增功能

  • 函数调用豁免: 新增 ignoreFunctionCalls 配置选项,允许对特定函数调用的参数进行魔法数字豁免

配置选项

除了继承原始 no-magic-numbers 规则的所有配置选项外,还新增了:

  • ignoreFunctionCalls (array): 函数名称列表,这些函数的调用参数中的魔法数字将被豁免

使用示例

export default [
  {
    plugins: {
      "bf-eslint-plugin": bfEslintPlugin,
    },
    rules: {
      "bf-eslint-plugin/bf-no-magic-numbers": [
        "error",
        {
          // 基本配置
          ignore: [0, 1, -1],
          ignoreArrayIndexes: true,
          ignoreDefaultValues: true,

          // 新增:函数调用豁免
          ignoreFunctionCalls: [
            "setTimeout", // 豁免 setTimeout(1000)
            "setInterval", // 豁免 setInterval(callback, 500)
            "Math.max", // 豁免 Math.max(100, 200)
            "Math.min", // 豁免 Math.min(10, 20)
            "Array", // 豁免 new Array(10)
            "slice", // 豁免 arr.slice(5, 10)
          ],
        },
      ],
    },
  },
];

支持的函数名称格式

  1. 简单函数名: "setTimeout" - 匹配直接函数调用

    setTimeout(1000); // ✅ 豁免
  2. 方法名: "max" - 匹配任何对象的该方法

    Math.max(100); // ✅ 豁免
    obj.max(200); // ✅ 豁免
  3. 完整方法名: "Math.max" - 精确匹配特定对象的方法

    Math.max(100); // ✅ 豁免
    obj.max(200); // ❌ 不豁免

调试功能

规则会在终端输出豁免的函数调用信息,便于调试:

[bf-no-magic-numbers] 豁免函数调用: setTimeout(1000)
[bf-no-magic-numbers] 豁免方法调用: max(100)
[bf-no-magic-numbers] 豁免完整方法调用: Math.max(200)

Rules

TODO: Run eslint-doc-generator to generate the rules list.