Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/legend80s/eslint-plugin-function-name
This is an eslint rule to enforce method or function name begin with verb.
https://github.com/legend80s/eslint-plugin-function-name
Last synced: about 13 hours ago
JSON representation
This is an eslint rule to enforce method or function name begin with verb.
- Host: GitHub
- URL: https://github.com/legend80s/eslint-plugin-function-name
- Owner: legend80s
- License: mit
- Created: 2021-04-10T08:26:41.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T00:47:20.000Z (6 months ago)
- Last Synced: 2024-04-20T13:56:41.533Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 135 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-function-name
> An eslint plugin to enforce method or function name conforms to conventions.
## Installation
You'll first need to install [ESLint](http://eslint.org):
```sh
npm i eslint --save-dev
```Next, install `eslint-plugin-function-name`:
```sh
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:
```json
{
"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:
```js
function cat(fish) {}
function dog(distance) {}
```👍 Examples of **correct** code for this rule:
```js
function feedCat(fish) {}
function walkDog(distance) {}
```#### options
```typescript
interface IOptions {
whitelist: string[];
blacklist: string[];
}
```.eslintrc.js
```javascript
{
"rules": {
"function-name/starts-with-verb": ["error", {
"whitelist": ["success"],
"blacklist": ["init"]
}]
}
}
```👎 Examples of **incorrect** code for this rule:
```js
// ..."blacklist": ["init"]...
const foo = {
init() {},
}
```👍 Examples of **correct** code for this rule:
```js
// ..."whitelist": ["success"]...
const foo = {
success() {},
}
```## Develop
### npm
yarn → bun