eslint-plugin-mobx 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # eslint-plugin-mobx
2
2
 
3
+ ## 0.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`218ebde877712775054e027cfda812210d2aa7d6`](https://github.com/mobxjs/mobx/commit/218ebde877712775054e027cfda812210d2aa7d6) [#3942](https://github.com/mobxjs/mobx/pull/3942) Thanks [@dartess](https://github.com/dartess)! - add eslint@9 support and flat config
8
+
3
9
  ## 0.0.11
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install --save-dev eslint @typescript-eslint/parser eslint-plugin-mobx
10
10
 
11
11
  ## Configuration
12
12
 
13
+ ### Legacy Config
14
+
13
15
  ```javascript
14
16
  // .eslintrc.js
15
17
  module.exports = {
@@ -24,12 +26,37 @@ module.exports = {
24
26
  "mobx/exhaustive-make-observable": "warn",
25
27
  "mobx/unconditional-make-observable": "error",
26
28
  "mobx/missing-make-observable": "error",
27
- "mobx/missing-observer": "warn",
28
- "mobx/no-anonymous-observer": "warn"
29
+ "mobx/missing-observer": "warn"
29
30
  }
30
31
  }
31
32
  ```
32
33
 
34
+ ### Flat Config
35
+
36
+ ```javascript
37
+ // eslint.config.js
38
+ import pluginMobx from "eslint-plugin-mobx"
39
+
40
+ export default [
41
+ // ...
42
+
43
+ // Either extend our recommended configuration:
44
+ pluginMobx.flatConfigs.recommended,
45
+
46
+ // ...or specify and customize individual rules:
47
+ {
48
+ plugins: { mobx: pluginMobx },
49
+ rules: {
50
+ // these values are the same as recommended
51
+ "mobx/exhaustive-make-observable": "warn",
52
+ "mobx/unconditional-make-observable": "error",
53
+ "mobx/missing-make-observable": "error",
54
+ "mobx/missing-observer": "warn"
55
+ }
56
+ }
57
+ ]
58
+ ```
59
+
33
60
  ## Rules
34
61
 
35
62
  ### mobx/exhaustive-make-observable
package/dist/index.js CHANGED
@@ -1,5 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var require$$0 = require('fs');
4
+ var require$$1 = require('path');
5
+
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+
8
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
9
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
10
+
3
11
  function _arrayLikeToArray(r, a) {
4
12
  (null == a || a > r.length) && (a = r.length);
5
13
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -11,6 +19,14 @@ function _arrayWithHoles(r) {
11
19
  function _arrayWithoutHoles(r) {
12
20
  if (Array.isArray(r)) return _arrayLikeToArray(r);
13
21
  }
22
+ function _defineProperty(e, r, t) {
23
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
24
+ value: t,
25
+ enumerable: !0,
26
+ configurable: !0,
27
+ writable: !0
28
+ }) : e[r] = t, e;
29
+ }
14
30
  function _iterableToArray(r) {
15
31
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
16
32
  }
@@ -47,12 +63,47 @@ function _nonIterableRest() {
47
63
  function _nonIterableSpread() {
48
64
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
49
65
  }
66
+ function ownKeys(e, r) {
67
+ var t = Object.keys(e);
68
+ if (Object.getOwnPropertySymbols) {
69
+ var o = Object.getOwnPropertySymbols(e);
70
+ r && (o = o.filter(function (r) {
71
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
72
+ })), t.push.apply(t, o);
73
+ }
74
+ return t;
75
+ }
76
+ function _objectSpread2(e) {
77
+ for (var r = 1; r < arguments.length; r++) {
78
+ var t = null != arguments[r] ? arguments[r] : {};
79
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
80
+ _defineProperty(e, r, t[r]);
81
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
82
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
83
+ });
84
+ }
85
+ return e;
86
+ }
50
87
  function _slicedToArray(r, e) {
51
88
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
52
89
  }
53
90
  function _toConsumableArray(r) {
54
91
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
55
92
  }
93
+ function _toPrimitive(t, r) {
94
+ if ("object" != typeof t || !t) return t;
95
+ var e = t[Symbol.toPrimitive];
96
+ if (void 0 !== e) {
97
+ var i = e.call(t, r || "default");
98
+ if ("object" != typeof i) return i;
99
+ throw new TypeError("@@toPrimitive must return a primitive value.");
100
+ }
101
+ return ("string" === r ? String : Number)(t);
102
+ }
103
+ function _toPropertyKey(t) {
104
+ var i = _toPrimitive(t, "string");
105
+ return "symbol" == typeof i ? i : i + "";
106
+ }
56
107
  function _unsupportedIterableToArray(r, a) {
57
108
  if (r) {
58
109
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
@@ -451,22 +502,18 @@ var noAnonymousObserver$1 = {
451
502
  create: create
452
503
  };
453
504
 
505
+ var fs = require$$0__default["default"];
506
+ var path = require$$1__default["default"];
454
507
  var exhaustiveMakeObservable = exhaustiveMakeObservable$1;
455
508
  var unconditionalMakeObservable = unconditionalMakeObservable$1;
456
509
  var missingMakeObservable = missingMakeObservable$1;
457
510
  var missingObserver = missingObserver$1;
458
511
  var noAnonymousObserver = noAnonymousObserver$1;
459
- var src = {
460
- configs: {
461
- recommended: {
462
- plugins: ["mobx"],
463
- rules: {
464
- "mobx/exhaustive-make-observable": "warn",
465
- "mobx/unconditional-make-observable": "error",
466
- "mobx/missing-make-observable": "error",
467
- "mobx/missing-observer": "warn"
468
- }
469
- }
512
+ var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
513
+ var pluginMobx = {
514
+ meta: {
515
+ name: pkg.name,
516
+ version: pkg.version
470
517
  },
471
518
  rules: {
472
519
  "exhaustive-make-observable": exhaustiveMakeObservable,
@@ -476,5 +523,28 @@ var src = {
476
523
  "no-anonymous-observer": noAnonymousObserver
477
524
  }
478
525
  };
526
+ var recommendedRules = {
527
+ "mobx/exhaustive-make-observable": "warn",
528
+ "mobx/unconditional-make-observable": "error",
529
+ "mobx/missing-make-observable": "error",
530
+ "mobx/missing-observer": "warn"
531
+ };
532
+ var src = _objectSpread2(_objectSpread2({}, pluginMobx), {}, {
533
+ configs: {
534
+ recommended: {
535
+ plugins: ["mobx"],
536
+ rules: recommendedRules
537
+ }
538
+ },
539
+ flatConfigs: {
540
+ recommended: {
541
+ name: "react-hooks/recommended",
542
+ plugins: {
543
+ "mobx": pluginMobx
544
+ },
545
+ rules: recommendedRules
546
+ }
547
+ }
548
+ });
479
549
 
480
550
  module.exports = src;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-mobx",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "ESLint rules for MobX",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -25,18 +25,20 @@
25
25
  ],
26
26
  "homepage": "https://mobx.js.org/",
27
27
  "peerDependencies": {
28
- "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
28
+ "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@typescript-eslint/eslint-plugin": "^5.0.0",
32
- "@typescript-eslint/parser": "^5.0.0",
33
- "eslint": "^7.0.0",
34
31
  "@babel/core": "^7.16.0",
35
32
  "@babel/preset-env": "^7.16.4",
36
- "rollup": "^2.60.2",
37
33
  "@rollup/plugin-babel": "^5.3.0",
38
34
  "@rollup/plugin-commonjs": "^21.0.1",
39
- "@rollup/plugin-node-resolve": "13.0.6"
35
+ "@rollup/plugin-node-resolve": "13.0.6",
36
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
37
+ "@typescript-eslint/parser": "^5.0.0",
38
+ "eslint": "^7.0.0",
39
+ "eslint-7": "npm:eslint@^7.0.0",
40
+ "eslint-9": "npm:eslint@^9.0.0",
41
+ "rollup": "^2.60.2"
40
42
  },
41
43
  "keywords": [
42
44
  "eslint",
@@ -45,7 +47,9 @@
45
47
  "mobx"
46
48
  ],
47
49
  "scripts": {
48
- "test": "jest",
50
+ "test:7": "jest --config jest.config-eslint-7.js",
51
+ "test:9": "jest --config jest.config-eslint-9.js",
52
+ "test": "npm run test:7 && npm run test:9",
49
53
  "build": "yarn rollup --config",
50
54
  "prepublishOnly": "yarn build"
51
55
  }
package/src/index.js CHANGED
@@ -1,22 +1,20 @@
1
1
  "use strict"
2
2
 
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
3
6
  const exhaustiveMakeObservable = require("./exhaustive-make-observable.js")
4
7
  const unconditionalMakeObservable = require("./unconditional-make-observable.js")
5
8
  const missingMakeObservable = require("./missing-make-observable.js")
6
9
  const missingObserver = require("./missing-observer")
7
10
  const noAnonymousObserver = require("./no-anonymous-observer.js")
8
11
 
9
- module.exports = {
10
- configs: {
11
- recommended: {
12
- plugins: ["mobx"],
13
- rules: {
14
- "mobx/exhaustive-make-observable": "warn",
15
- "mobx/unconditional-make-observable": "error",
16
- "mobx/missing-make-observable": "error",
17
- "mobx/missing-observer": "warn"
18
- }
19
- }
12
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
13
+
14
+ const pluginMobx = {
15
+ meta: {
16
+ name: pkg.name,
17
+ version: pkg.version
20
18
  },
21
19
  rules: {
22
20
  "exhaustive-make-observable": exhaustiveMakeObservable,
@@ -25,4 +23,28 @@ module.exports = {
25
23
  "missing-observer": missingObserver,
26
24
  "no-anonymous-observer": noAnonymousObserver
27
25
  }
26
+ };
27
+
28
+ const recommendedRules = {
29
+ "mobx/exhaustive-make-observable": "warn",
30
+ "mobx/unconditional-make-observable": "error",
31
+ "mobx/missing-make-observable": "error",
32
+ "mobx/missing-observer": "warn"
33
+ }
34
+
35
+ module.exports = {
36
+ ...pluginMobx,
37
+ configs: {
38
+ recommended: {
39
+ plugins: ["mobx"],
40
+ rules: recommendedRules,
41
+ }
42
+ },
43
+ flatConfigs: {
44
+ recommended: {
45
+ name: "react-hooks/recommended",
46
+ plugins: { "mobx": pluginMobx },
47
+ rules: recommendedRules
48
+ }
49
+ }
28
50
  }