1.3.12 • Published 1 year ago

eslint-plugin-keywords-immutable v1.3.12

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

eslint-plugin-keywords-immutable

Immutable objects with promised keywords do not allow mutation.

Getting started

Installation

npm i --save-dev eslint-plugin-keywords-immutable

Usage

Add the following to your .eslintrc

Can customize keywords, including regular expressions.

  plugins: [
    "keywords-immutable"
  ],
  rules: {
    "keywords-immutable/no-mutation": [2, ['window', 'event', 'global', /^FINAL_/]]
  }

Second Option

The second option is the check depth option. If true, depths greater than 2 are also considered unchangeable. The default value is false.

  plugins: [
    "keywords-immutable"
  ],
  rules: {
    "keywords-immutable/no-mutation": [2, ['window', 'event', 'global', /^FINAL_/], true]
  }

By default, "event" are disallowed to be mutated.

When used without options, the default option is 'event'.

  plugins: [
    "keywords-immutable"
  ],
  rules: {
    "keywords-immutable/no-mutation": 2
  }

Example

invalid

  • Not allowed because it is part of a keyword.
// "keywords-immutable/no-mutation": [2, ['point', /^FINAL/]]
FINAL_POINT.x = 3;
point.x = 3;
pointParent.point.x = 3;
[point.x, point.y] = [1, 3];
({ a: point.s } = { a: 3 });
Object.assign(point, { v: 3 });

// "keywords-immutable/no-mutation": [2, ['point', /^FINAL/], true]
point.x.y = 3;
pointParent.point.x.y = 3;

valid

  • Allowed because it is not part of a keyword.
// "keywords-immutable/no-mutation": [2, ['point', /^FINAL/]]
FINE_POINT.x = 3;
obj.a = 3;
objParent.obj.x = 3;
[obj.x, obj.b] = [1, 3];
({ a: obj.s } = { a: 3 });

Contributing

Please submit a PR.

1.3.12

1 year ago

1.3.10

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.2.7

1 year ago

1.1.6

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago