Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.24 KB

no-mutable-event-types-payload-in-models.md

File metadata and controls

49 lines (39 loc) · 1.24 KB

No mutable types allowed in eventTypes payload for models (no-mutable-event-types-payload-in-models)

No mutable objects in eventTypes payload defination.

Rule Details

By default, this rule checks for the following object-types within the eventTypes/watchEventTypes definition in createModel:

  • array, arrayOf
  • object, objectOf
  • shape
  • func

Use immutable data in payload definition of eventTypes/watchEventTypes as follows:

  eventTypes: [
    {
      type: 'reload',
      payload: {
        foo: PropTypes.string,
        bar: ImmutablePropTypes.listOf(PropTypes.number)
      }
    }
  ],
  watchEventTypes: [
    {
      type: 'reload',
      payload: {
        foo: PropTypes.string,
        bar: ImmutablePropTypes.listOf(PropTypes.number)
      }
    }
  ]

Options

This can be configured to forbid / warn against any valid eventType/watchEventTypes. You can provide an array of object types you don't want to be allowed within the ModulaJS Model Class in your .eslintrc configuration file.

default value: [ 'func', 'array', 'object', 'arrayOf', 'objectOf', 'shape' ]

{
  "rules": {
    "modulajs/no-mutable-event-types-payload-in-models": ["error", ["object", "array", "arrayOf", "objectOf"]]
  }
}