JSPM

eslint-plugin-function-name

2.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15628
  • Score
    100M100P100Q138598F
  • License MIT

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

Package Exports

  • eslint-plugin-function-name
  • eslint-plugin-function-name/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-function-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 conforms to conventions.

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"
  ],
  "rules": {
    "function-name/starts-with-verb": "error"
  }
}

Supported Rules

function-name/starts-with-verb

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

👎 Examples of incorrect code for this rule:

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

👍 Examples of correct code for this rule:

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

options

interface IOptions {
  whitelist: string[];
  blacklist: string[];
}

.eslintrc.js

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

👎 Examples of incorrect code for this rule:

// ..."blacklist": ["init"]...
const foo = {
  init() {},
}

👍 Examples of correct code for this rule:

// ..."whitelist": ["success"]...
const foo = {
  success() {},
}

Develop

  • Use Bun to manage everything for example installing.