Skip to content

ESLint plugin defining a single rule for checking ES6 method name conventions

License

Notifications You must be signed in to change notification settings

buildo/eslint-plugin-method-names

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-method-names

Build Status npm

Installation

npm install --save-dev eslint-plugin-method-names

Usage

In your .eslintrc:

{
  "plugins": [
    "method-names"
  ],
  "rules": {
    "method-names/method-names": [2, { regex: '^[a-z].*' }]
  }
}

Rule

Restrict class method names to a regex. It applies to methods and static properties defining a function.

Usage

With the configuration above, the following patterns are considered valid

class Foo {
  bar() {}
}

class Foo {
  bar = () => {}
}

class Foo {
  _bar = 40 + 2
}

whereas the following are considered errors

class Foo {
  _bar() {}
}

class Foo {
  _bar = () => {}
}

Why

This is useful for enforcing conventions like "methods should never start with an underscore".

About

ESLint plugin defining a single rule for checking ES6 method name conventions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published