eslint-plugin-mobx-computed-getters

1.0.6 • Public • Published

eslint-plugin-mobx-computed-getters Build Status code style: prettier

ESLint plugin that ensures MobX's computed methods are always getters.

class UserStore {
  @observable firstName = '';
  @observable lastName = '';
  
  // ESLint error: Computed methods should always be getters. Did you miss 'get' keyword?
  @computed fullName() {
    return `${this.firstName} ${this.lastName}`;
  }
}

Installation

  1. npm i eslint-plugin-mobx-computed-getters
  2. Then in your .eslintrc.json file add the following line:
"plugins"["mobx-computed-getters"]

Now you can add the rule like so:

{
  "rules": {
    "mobx-computed-getters/computed-getters": "error",
  }
}

Usage with Create React App:

  1. Add EXTEND_ESLINT=true to your .env file
  2. Extend your .eslintrc.json file from react-app config:
{
  "extends": ["react-app"],
  "plugins": ["mobx-computed-getters"],
  "rules": {
    "getter-return": "error",
    "mobx-computed-getters/computed-getters": "error"
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-mobx-computed-getters

Weekly Downloads

13

Version

1.0.6

License

MIT

Unpacked Size

5.11 kB

Total Files

9

Last publish

Collaborators

  • kubk