eslint-plugin-function-name

    1.0.1 • Public • Published

    eslint-plugin-function-name

    npm version npm downloads License: MIT linter by git commit msg linter

    An eslint plugin to enforce method or function name stick to the conventions.

    For example a good function name should begin with a verb.

    Bad:

    function cat(fish) {}
    function dog(distance) {}

    Good:

    function feedCat(fish) {}
    function walkDog(distance) {}

    Installation

    You'll first need to install ESLint:

    $ npm i eslint --save-dev
    

    Next, install eslint-plugin-function-name:

    $ npm install eslint-plugin-function-name --save-dev
    

    Usage

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

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

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

    {
        "rules": {
            "function-name/starts-with-verb": "error"
        }
    }

    Supported Rules

    function-name/starts-with-verb

    Function is always do somethings, so it should start with a verb and to avoid confusion with variables.

    options

    interface IOptions {
      whitelist: string[];
      blacklist: string[];
    }
    example
    {
        "rules": {
            "function-name/starts-with-verb": ["error", {
              "whitelist": ["success"],
              "blacklist": ["init"]
            }]
        }
    }

    code:

    const foo = {
      success() {}, // valid
      init() {}, // invalid
    }

    Install

    npm i eslint-plugin-function-name

    DownloadsWeekly Downloads

    228

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    12.9 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar