Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnstonbl01/eslint-no-inferred-method-name
A custom rule for ESLint that checks for inferred method names within object literals.
https://github.com/johnstonbl01/eslint-no-inferred-method-name
Last synced: 3 months ago
JSON representation
A custom rule for ESLint that checks for inferred method names within object literals.
- Host: GitHub
- URL: https://github.com/johnstonbl01/eslint-no-inferred-method-name
- Owner: johnstonbl01
- License: mit
- Created: 2015-05-16T03:27:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T16:35:53.000Z (over 2 years ago)
- Last Synced: 2024-07-02T07:01:39.004Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 217 KB
- Stars: 27
- Watchers: 3
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-eslint - no-inferred-method-name - Custom rule for ESLint that checks for inferred method names within object literals. (Plugins / Practices and Specific ES Features)
README
# Disallow Inferred Method Names in Object Literals (no-inferred-method-name)
In ES6, compact methods and unnamed function expression assignments within object literals do not create a lexical identification (name) binding that corresponds to the function name identifier for recursion or event binding. The compact method syntax will not be an appropriate option for these types of solutions, and a named function expression should be used instead. This custom ESLint rule will identify instances where a function name is being called and a lexical identifier is unavailable within a compact object literal.
More information on this can be found:
- [eslint/eslint#2454](https://github.com/eslint/eslint/issues/2454#issuecomment-100285220)
- [babel/babel#1367](https://github.com/babel/babel/issues/1367)
- [ES6 Concise Methods: Lexical or Not?](http://blog.getify.com/es6-concise-methods-lexical-or-not/)**Note** - Tests are provided in the repo, but not necessary for installation or use of the rule.
## Setup
### Prerequisites
Node.js & NPM - For instructions on how to install Node.js, check [here](https://nodejs.org/).
ESLint - More information on ESLint setup & configuration can be found [here](http://eslint.org/).
### Install Plugin via NPM
Install the plugin using NPM:
```
$ npm install eslint-plugin-no-inferred-method-name --save-dev
```_Note_: If ESLint is installed globally, the plugin must also be installed globally.
### Enable Plugin in ESLint Config File
Within the project directory, create or edit the ESLint configuration file to enable the new rule.
```js
{
plugins: ['eslint-plugin-no-inferred-method-name'],
rules: {
// ...
'no-inferred-method-name/no-inferred-method-name': 'error'
}
// ...
}
```### Run ESLint
You can lint files from the command line using: `eslint [filename]`
Additionally, the above setup should enable the rule within your Text Editor or IDE (assuming that you have a Linter enabled).
## Rule Details
Detailed information / examples of the rule can be found [here](/docs/rules/no-inferred-method-name.md).