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-plugin-function-limit

v1.2.1

Published

Limit the functions count of one file

Downloads

3

Readme

eslint-plugin-function-limit

Limit the functions count of specific files

限制指定文件里函数的数量

Background

背景

Some developers write many helper functions in a index file, causing other developers must link to here and there when debugging the code. It is difficult to distinguish which are helper functions and which are business logic, which increases maintenance costs. Therefore, this plugin can detect whether the developer has written too many functions, and if so, it is recommended to put these helper functions in the "helper" or "lib" folder.

很多开发者在根文件里写了很多帮助函数,致使其他开发者在调试代码时需要跳来跳去,很难分清哪些是帮助函数,哪些是业务逻辑,增加了维护成本。因此,这个插件可以检测开发者是否在一个文件里写了太多的函数,如果是,建议把这些帮助函数放到"helper"或"lib"文件夹里。

Installation

安装

You'll first need to install ESLint:

首先得安装eslint:

yarn add eslint -D

Next, install eslint-plugin-function-limit:

然后安装这个插件:

yarn add eslint-plugin-function-limit -D

Usage

使用

Add function-limit to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

在你的项目的.eslintrc配置文件里的plugins添加如下配置:

{
    "plugins": [
        "function-limit"
    ]
}

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

然后在rules里添加如下配置:

{
    "rules": {
        "function-limit/function-count": ["error", { "limit": 3, "files": ["index.ts"] }]
    }
}

The second parameter { "limit": 3, "files": ["index.ts"] } in the above configuration means: the number of functions in the file whose file name matches index.ts cannot exceed 3.

上述配置的第二个参数{ "limit": 3, "files": ["index.ts"] }的意思是:文件名匹配index.ts的文件中函数的数量不能超过3个。

Rule Option

规则参数

  • limit Type is integer. Default value is 3, it means that the max count of function in one file should not exceed 3.

    类型是整数。默认值是3,意思是一个文件里的函数数量不能超过3。

  • files Type is string array, the string can be a Regexp format, such as [".*"].It means that the rule only be active in the file whose name matches. If not set, the rule will be active for all files. Otherwise, the rule will only be active for the file whose filename matches.

    类型是字符串数组,字符串可以是正则表达式的形式,例如[".*"]。意思是这个规则只会在文件名匹配的文件里才生效。如果没设置,这个规则会对所有文件生效。若设置了,则只对文件名匹配到的文件生效。