1.0.6 • Published 4 years ago

eslint-plugin-mobx-computed-getters v1.0.6

Weekly downloads
26
License
MIT
Repository
github
Last release
4 years ago

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"
  }
}
1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago