@ngrx/eslint-plugin 19.0.0-beta.0 → 19.0.0-rc.0
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/package.json +10 -1
- package/schematics/ng-add/schema.js.map +1 -1
- package/src/configs/all.js +2 -1
- package/src/configs/all.js.map +1 -1
- package/src/configs/all.json +2 -1
- package/src/configs/component-store.js +1 -0
- package/src/configs/component-store.js.map +1 -1
- package/src/configs/component-store.json +1 -0
- package/src/configs/signals.js +1 -1
- package/src/configs/signals.js.map +1 -1
- package/src/configs/signals.json +1 -1
- package/src/index.d.ts +5 -2
- package/src/rules/component-store/avoid-combining-component-store-selectors.js +1 -2
- package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js +1 -2
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/require-super-ondestroy.d.ts +3 -0
- package/src/rules/component-store/require-super-ondestroy.js +41 -0
- package/src/rules/component-store/require-super-ondestroy.js.map +1 -0
- package/src/rules/component-store/updater-explicit-return-type.js +1 -2
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.js +1 -2
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +1 -2
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/index.d.ts +1 -0
- package/src/rules/index.js +2 -0
- package/src/rules/index.js.map +1 -1
- package/src/rules/operators/prefer-concat-latest-from.js +1 -1
- package/src/rules/operators/prefer-concat-latest-from.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +1 -2
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.js +1 -2
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +1 -2
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/utils/helper-functions/utils.d.ts +1 -0
- package/src/utils/helper-functions/utils.js +6 -1
- package/src/utils/helper-functions/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/eslint-plugin",
|
|
3
|
-
"version": "19.0.0-
|
|
3
|
+
"version": "19.0.0-rc.0",
|
|
4
4
|
"description": "NgRx ESLint Plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,6 +50,15 @@
|
|
|
50
50
|
"typescript-eslint": "^8.0.0",
|
|
51
51
|
"@typescript-eslint/utils": "^8.0.0"
|
|
52
52
|
},
|
|
53
|
+
"exports": {
|
|
54
|
+
"./package.json": "./package.json",
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./src/index.d.ts",
|
|
57
|
+
"default": "./src/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./v9": "./v9/index.js",
|
|
60
|
+
"./v9/index": "./v9/index.js"
|
|
61
|
+
},
|
|
53
62
|
"types": "./src/index.d.ts",
|
|
54
63
|
"main": "./src/index.js",
|
|
55
64
|
"type": "commonjs"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/schema.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/schema.ts"],"names":[],"mappings":"","sourcesContent":["export interface Schema {\n config: 'all' | 'store' | 'effects' | 'component-store' | 'signals';\n}\n"]}
|
package/src/configs/all.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.default = (plugin, parser) => [
|
|
|
28
28
|
rules: {
|
|
29
29
|
'@ngrx/avoid-combining-component-store-selectors': 'error',
|
|
30
30
|
'@ngrx/avoid-mapping-component-store-selectors': 'error',
|
|
31
|
+
'@ngrx/require-super-ondestroy': 'error',
|
|
31
32
|
'@ngrx/updater-explicit-return-type': 'error',
|
|
32
33
|
'@ngrx/avoid-cyclic-effects': 'error',
|
|
33
34
|
'@ngrx/no-dispatch-in-effects': 'error',
|
|
@@ -37,9 +38,9 @@ exports.default = (plugin, parser) => [
|
|
|
37
38
|
'@ngrx/prefer-effect-callback-in-block-statement': 'error',
|
|
38
39
|
'@ngrx/use-effects-lifecycle-interface': 'error',
|
|
39
40
|
'@ngrx/prefer-concat-latest-from': 'error',
|
|
41
|
+
'@ngrx/prefer-protected-state': 'error',
|
|
40
42
|
'@ngrx/signal-state-no-arrays-at-root-level': 'error',
|
|
41
43
|
'@ngrx/signal-store-feature-should-use-generic-type': 'error',
|
|
42
|
-
'@ngrx/prefer-protected-state': 'error',
|
|
43
44
|
'@ngrx/with-state-no-arrays-at-root-level': 'error',
|
|
44
45
|
'@ngrx/avoid-combining-selectors': 'error',
|
|
45
46
|
'@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',
|
package/src/configs/all.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE;YACf,MAAM;YACN,aAAa,EAAE;gBACb,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,iBAAiB;aAC3B;SACF;QACD,KAAK,EAAE;YACL,iDAAiD,EAAE,OAAO;YAC1D,+CAA+C,EAAE,OAAO;YACxD,oCAAoC,EAAE,OAAO;YAC7C,4BAA4B,EAAE,OAAO;YACrC,8BAA8B,EAAE,OAAO;YACvC,+BAA+B,EAAE,OAAO;YACxC,sCAAsC,EAAE,OAAO;YAC/C,wCAAwC,EAAE,OAAO;YACjD,iDAAiD,EAAE,OAAO;YAC1D,uCAAuC,EAAE,OAAO;YAChD,iCAAiC,EAAE,OAAO;YAC1C,
|
|
1
|
+
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE;YACf,MAAM;YACN,aAAa,EAAE;gBACb,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,iBAAiB;aAC3B;SACF;QACD,KAAK,EAAE;YACL,iDAAiD,EAAE,OAAO;YAC1D,+CAA+C,EAAE,OAAO;YACxD,+BAA+B,EAAE,OAAO;YACxC,oCAAoC,EAAE,OAAO;YAC7C,4BAA4B,EAAE,OAAO;YACrC,8BAA8B,EAAE,OAAO;YACvC,+BAA+B,EAAE,OAAO;YACxC,sCAAsC,EAAE,OAAO;YAC/C,wCAAwC,EAAE,OAAO;YACjD,iDAAiD,EAAE,OAAO;YAC1D,uCAAuC,EAAE,OAAO;YAChD,iCAAiC,EAAE,OAAO;YAC1C,8BAA8B,EAAE,OAAO;YACvC,4CAA4C,EAAE,OAAO;YACrD,oDAAoD,EAAE,OAAO;YAC7D,0CAA0C,EAAE,OAAO;YACnD,iCAAiC,EAAE,OAAO;YAC1C,uDAAuD,EAAE,OAAO;YAChE,0CAA0C,EAAE,OAAO;YACnD,+BAA+B,EAAE,OAAO;YACxC,2BAA2B,EAAE,OAAO;YACpC,iCAAiC,EAAE,OAAO;YAC1C,+BAA+B,EAAE,OAAO;YACxC,6BAA6B,EAAE,OAAO;YACtC,6BAA6B,EAAE,OAAO;YACtC,wCAAwC,EAAE,OAAO;YACjD,yCAAyC,EAAE,OAAO;YAClD,6BAA6B,EAAE,OAAO;YACtC,kCAAkC,EAAE,OAAO;YAC3C,yDAAyD,EAAE,OAAO;YAClE,iCAAiC,EAAE,OAAO;YAC1C,oCAAoC,EAAE,OAAO;YAC7C,oBAAoB,EAAE,OAAO;YAC7B,wCAAwC,EAAE,OAAO;SAClD;KACF;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nexport default (\n plugin: TSESLint.FlatConfig.Plugin,\n parser: TSESLint.FlatConfig.Parser\n): TSESLint.FlatConfig.ConfigArray => [\n {\n name: 'ngrx/base',\n languageOptions: {\n parser,\n sourceType: 'module',\n },\n plugins: {\n '@ngrx': plugin,\n },\n },\n {\n name: 'ngrx/all',\n languageOptions: {\n parser,\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n },\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/require-super-ondestroy': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n '@ngrx/avoid-cyclic-effects': 'error',\n '@ngrx/no-dispatch-in-effects': 'error',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'error',\n '@ngrx/prefer-effect-callback-in-block-statement': 'error',\n '@ngrx/use-effects-lifecycle-interface': 'error',\n '@ngrx/prefer-concat-latest-from': 'error',\n '@ngrx/prefer-protected-state': 'error',\n '@ngrx/signal-state-no-arrays-at-root-level': 'error',\n '@ngrx/signal-store-feature-should-use-generic-type': 'error',\n '@ngrx/with-state-no-arrays-at-root-level': 'error',\n '@ngrx/avoid-combining-selectors': 'error',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'error',\n '@ngrx/avoid-mapping-selectors': 'error',\n '@ngrx/good-action-hygiene': 'error',\n '@ngrx/no-multiple-global-stores': 'error',\n '@ngrx/no-reducer-in-key-names': 'error',\n '@ngrx/no-store-subscription': 'error',\n '@ngrx/no-typed-global-store': 'error',\n '@ngrx/on-function-explicit-return-type': 'error',\n '@ngrx/prefer-action-creator-in-dispatch': 'error',\n '@ngrx/prefer-action-creator': 'error',\n '@ngrx/prefer-inline-action-props': 'error',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'error',\n '@ngrx/prefer-selector-in-select': 'error',\n '@ngrx/prefix-selectors-with-select': 'error',\n '@ngrx/select-style': 'error',\n '@ngrx/use-consistent-global-store-name': 'error',\n },\n },\n];\n"]}
|
package/src/configs/all.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"rules": {
|
|
5
5
|
"@ngrx/avoid-combining-component-store-selectors": "error",
|
|
6
6
|
"@ngrx/avoid-mapping-component-store-selectors": "error",
|
|
7
|
+
"@ngrx/require-super-ondestroy": "error",
|
|
7
8
|
"@ngrx/updater-explicit-return-type": "error",
|
|
8
9
|
"@ngrx/avoid-cyclic-effects": "error",
|
|
9
10
|
"@ngrx/no-dispatch-in-effects": "error",
|
|
@@ -13,9 +14,9 @@
|
|
|
13
14
|
"@ngrx/prefer-effect-callback-in-block-statement": "error",
|
|
14
15
|
"@ngrx/use-effects-lifecycle-interface": "error",
|
|
15
16
|
"@ngrx/prefer-concat-latest-from": "error",
|
|
17
|
+
"@ngrx/prefer-protected-state": "error",
|
|
16
18
|
"@ngrx/signal-state-no-arrays-at-root-level": "error",
|
|
17
19
|
"@ngrx/signal-store-feature-should-use-generic-type": "error",
|
|
18
|
-
"@ngrx/prefer-protected-state": "error",
|
|
19
20
|
"@ngrx/with-state-no-arrays-at-root-level": "error",
|
|
20
21
|
"@ngrx/avoid-combining-selectors": "error",
|
|
21
22
|
"@ngrx/avoid-dispatching-multiple-actions-sequentially": "error",
|
|
@@ -23,6 +23,7 @@ exports.default = (plugin, parser) => [
|
|
|
23
23
|
rules: {
|
|
24
24
|
'@ngrx/avoid-combining-component-store-selectors': 'error',
|
|
25
25
|
'@ngrx/avoid-mapping-component-store-selectors': 'error',
|
|
26
|
+
'@ngrx/require-super-ondestroy': 'error',
|
|
26
27
|
'@ngrx/updater-explicit-return-type': 'error',
|
|
27
28
|
},
|
|
28
29
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-store.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,eAAe,EAAE;YACf,MAAM;SACP;QACD,KAAK,EAAE;YACL,iDAAiD,EAAE,OAAO;YAC1D,+CAA+C,EAAE,OAAO;YACxD,oCAAoC,EAAE,OAAO;SAC9C;KACF;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nexport default (\n plugin: TSESLint.FlatConfig.Plugin,\n parser: TSESLint.FlatConfig.Parser\n): TSESLint.FlatConfig.ConfigArray => [\n {\n name: 'ngrx/base',\n languageOptions: {\n parser,\n sourceType: 'module',\n },\n plugins: {\n '@ngrx': plugin,\n },\n },\n {\n name: 'ngrx/component-store',\n languageOptions: {\n parser,\n },\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n },\n },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"component-store.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,eAAe,EAAE;YACf,MAAM;SACP;QACD,KAAK,EAAE;YACL,iDAAiD,EAAE,OAAO;YAC1D,+CAA+C,EAAE,OAAO;YACxD,+BAA+B,EAAE,OAAO;YACxC,oCAAoC,EAAE,OAAO;SAC9C;KACF;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nexport default (\n plugin: TSESLint.FlatConfig.Plugin,\n parser: TSESLint.FlatConfig.Parser\n): TSESLint.FlatConfig.ConfigArray => [\n {\n name: 'ngrx/base',\n languageOptions: {\n parser,\n sourceType: 'module',\n },\n plugins: {\n '@ngrx': plugin,\n },\n },\n {\n name: 'ngrx/component-store',\n languageOptions: {\n parser,\n },\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/require-super-ondestroy': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n },\n },\n];\n"]}
|
package/src/configs/signals.js
CHANGED
|
@@ -26,9 +26,9 @@ exports.default = (plugin, parser) => [
|
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
rules: {
|
|
29
|
+
'@ngrx/prefer-protected-state': 'error',
|
|
29
30
|
'@ngrx/signal-state-no-arrays-at-root-level': 'error',
|
|
30
31
|
'@ngrx/signal-store-feature-should-use-generic-type': 'error',
|
|
31
|
-
'@ngrx/prefer-protected-state': 'error',
|
|
32
32
|
'@ngrx/with-state-no-arrays-at-root-level': 'error',
|
|
33
33
|
},
|
|
34
34
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/signals.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE;YACf,MAAM;YACN,aAAa,EAAE;gBACb,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,iBAAiB;aAC3B;SACF;QACD,KAAK,EAAE;YACL,
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/signals.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH,kBAAe,CACb,MAAkC,EAClC,MAAkC,EACD,EAAE,CAAC;IACpC;QACE,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE;YACf,MAAM;YACN,UAAU,EAAE,QAAQ;SACrB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM;SAChB;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE;YACf,MAAM;YACN,aAAa,EAAE;gBACb,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,iBAAiB;aAC3B;SACF;QACD,KAAK,EAAE;YACL,8BAA8B,EAAE,OAAO;YACvC,4CAA4C,EAAE,OAAO;YACrD,oDAAoD,EAAE,OAAO;YAC7D,0CAA0C,EAAE,OAAO;SACpD;KACF;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nexport default (\n plugin: TSESLint.FlatConfig.Plugin,\n parser: TSESLint.FlatConfig.Parser\n): TSESLint.FlatConfig.ConfigArray => [\n {\n name: 'ngrx/base',\n languageOptions: {\n parser,\n sourceType: 'module',\n },\n plugins: {\n '@ngrx': plugin,\n },\n },\n {\n name: 'ngrx/signals',\n languageOptions: {\n parser,\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n },\n rules: {\n '@ngrx/prefer-protected-state': 'error',\n '@ngrx/signal-state-no-arrays-at-root-level': 'error',\n '@ngrx/signal-store-feature-should-use-generic-type': 'error',\n '@ngrx/with-state-no-arrays-at-root-level': 'error',\n },\n },\n];\n"]}
|
package/src/configs/signals.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"parser": "@typescript-eslint/parser",
|
|
3
3
|
"plugins": ["@ngrx"],
|
|
4
4
|
"rules": {
|
|
5
|
+
"@ngrx/prefer-protected-state": "error",
|
|
5
6
|
"@ngrx/signal-state-no-arrays-at-root-level": "error",
|
|
6
7
|
"@ngrx/signal-store-feature-should-use-generic-type": "error",
|
|
7
|
-
"@ngrx/prefer-protected-state": "error",
|
|
8
8
|
"@ngrx/with-state-no-arrays-at-root-level": "error"
|
|
9
9
|
},
|
|
10
10
|
"parserOptions": {
|
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const _default: {
|
|
|
6
6
|
rules: {
|
|
7
7
|
"@ngrx/avoid-combining-component-store-selectors": string;
|
|
8
8
|
"@ngrx/avoid-mapping-component-store-selectors": string;
|
|
9
|
+
"@ngrx/require-super-ondestroy": string;
|
|
9
10
|
"@ngrx/updater-explicit-return-type": string;
|
|
10
11
|
"@ngrx/avoid-cyclic-effects": string;
|
|
11
12
|
"@ngrx/no-dispatch-in-effects": string;
|
|
@@ -15,9 +16,9 @@ declare const _default: {
|
|
|
15
16
|
"@ngrx/prefer-effect-callback-in-block-statement": string;
|
|
16
17
|
"@ngrx/use-effects-lifecycle-interface": string;
|
|
17
18
|
"@ngrx/prefer-concat-latest-from": string;
|
|
19
|
+
"@ngrx/prefer-protected-state": string;
|
|
18
20
|
"@ngrx/signal-state-no-arrays-at-root-level": string;
|
|
19
21
|
"@ngrx/signal-store-feature-should-use-generic-type": string;
|
|
20
|
-
"@ngrx/prefer-protected-state": string;
|
|
21
22
|
"@ngrx/with-state-no-arrays-at-root-level": string;
|
|
22
23
|
"@ngrx/avoid-combining-selectors": string;
|
|
23
24
|
"@ngrx/avoid-dispatching-multiple-actions-sequentially": string;
|
|
@@ -50,6 +51,7 @@ declare const _default: {
|
|
|
50
51
|
rules: {
|
|
51
52
|
"@ngrx/avoid-combining-component-store-selectors": string;
|
|
52
53
|
"@ngrx/avoid-mapping-component-store-selectors": string;
|
|
54
|
+
"@ngrx/require-super-ondestroy": string;
|
|
53
55
|
"@ngrx/updater-explicit-return-type": string;
|
|
54
56
|
};
|
|
55
57
|
};
|
|
@@ -106,9 +108,9 @@ declare const _default: {
|
|
|
106
108
|
parser: string;
|
|
107
109
|
plugins: string[];
|
|
108
110
|
rules: {
|
|
111
|
+
"@ngrx/prefer-protected-state": string;
|
|
109
112
|
"@ngrx/signal-state-no-arrays-at-root-level": string;
|
|
110
113
|
"@ngrx/signal-store-feature-should-use-generic-type": string;
|
|
111
|
-
"@ngrx/prefer-protected-state": string;
|
|
112
114
|
"@ngrx/with-state-no-arrays-at-root-level": string;
|
|
113
115
|
};
|
|
114
116
|
parserOptions: {
|
|
@@ -122,6 +124,7 @@ declare const _default: {
|
|
|
122
124
|
'avoid-combining-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
123
125
|
'avoid-mapping-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMappingComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
124
126
|
'updater-explicit-return-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"updaterExplicitReturnType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
127
|
+
'require-super-ondestroy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"requireSuperOnDestroy", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
125
128
|
'avoid-cyclic-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCyclicEffects", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
126
129
|
'no-dispatch-in-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDispatchInEffects" | "noDispatchInEffectsSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
127
130
|
'no-effects-in-providers': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noEffectsInProviders", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
@@ -43,8 +43,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
43
43
|
},
|
|
44
44
|
defaultOptions: [],
|
|
45
45
|
create: (context) => {
|
|
46
|
-
const
|
|
47
|
-
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
46
|
+
const storeNames = (0, utils_1.getNgrxComponentStoreNames)(context);
|
|
48
47
|
const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;
|
|
49
48
|
const storeSelects = storeNames ? (0, utils_1.namedExpression)(storeNames) : null;
|
|
50
49
|
const selectsInArray = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA0E;AAC7D,QAAA,SAAS,GAAG,uCAAuC,CAAC;AAIjE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;SACjE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,0CAA0C;SACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,IAAA,kCAA0B,EAAC,OAAO,CAAC,CAAC;QAEvD,MAAM,WAAW,GAAG,oFAAoF,CAAC;QACzG,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAErE,MAAM,cAAc,GAA8B,EAAE,CAAC;QACrD,OAAO;YACL,CAAC,yFAAyF,WAAW,MAAM,WAAW,EAAE,CAAC,CACvH,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,CAAC,+CAA+C,YAAY,MAAM,YAAY,EAAE,CAAC,CAC/E,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,CAAC,kDAAkD,CAAC;gBAClD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;oBAClC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAT,iBAAS;qBACV,CAAC,CAAC;gBACL,CAAC;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgrxComponentStoreNames, namedExpression } from '../../utils';\nexport const messageId = 'avoidCombiningComponentStoreSelectors';\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'component-store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const storeNames = getNgrxComponentStoreNames(context);\n\n const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;\n const storeSelects = storeNames ? namedExpression(storeNames) : null;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ${thisSelects} ~ ${thisSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest'] ${storeSelects} ~ ${storeSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
|
|
@@ -43,8 +43,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
43
43
|
},
|
|
44
44
|
defaultOptions: [],
|
|
45
45
|
create: (context) => {
|
|
46
|
-
const
|
|
47
|
-
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
46
|
+
const storeNames = (0, utils_1.getNgrxComponentStoreNames)(context);
|
|
48
47
|
const mapOperatorSelector = `[callee.property.name=pipe] > CallExpression[callee.name=map]`;
|
|
49
48
|
const selectors = [
|
|
50
49
|
`ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])${mapOperatorSelector}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-mapping-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-mapping-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"avoid-mapping-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-mapping-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAGqB;AAER,QAAA,SAAS,GAAG,qCAAqC,CAAC;AAK/D,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;SAC/D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,0CAA0C;SACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,IAAA,kCAA0B,EAAC,OAAO,CAAC,CAAC;QAEvD,MAAM,mBAAmB,GAAG,+DAA+D,CAAC;QAC5F,MAAM,SAAS,GAAG;YAChB,mJAAmJ,mBAAmB,EAAE;YACxK,UAAU;gBACR,GAAG,IAAA,+BAAuB,EAAC,UAAU,CAAC,GAAG,mBAAmB,EAAE;SACjE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO;YACL,CAAC,SAAS,CAAC,CAAC,IAAsC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgrxComponentStoreNames,\n namedCallableExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMappingComponentStoreSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const storeNames = getNgrxComponentStoreNames(context);\n\n const mapOperatorSelector = `[callee.property.name=pipe] > CallExpression[callee.name=map]`;\n const selectors = [\n `ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])${mapOperatorSelector}`,\n storeNames &&\n `${namedCallableExpression(storeNames)}${mapOperatorSelector}`,\n ]\n .filter(Boolean)\n .join(',');\n\n return {\n [selectors](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.messageId = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
6
|
+
exports.messageId = 'requireSuperOnDestroy';
|
|
7
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
8
|
+
name: path.parse(__filename).name,
|
|
9
|
+
meta: {
|
|
10
|
+
type: 'problem',
|
|
11
|
+
ngrxModule: 'component-store',
|
|
12
|
+
docs: {
|
|
13
|
+
description: 'Overriden ngOnDestroy method in component stores require a call to super.ngOnDestroy().',
|
|
14
|
+
},
|
|
15
|
+
schema: [],
|
|
16
|
+
messages: {
|
|
17
|
+
[exports.messageId]: "Call super.ngOnDestroy() inside a component store's ngOnDestroy method.",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [],
|
|
21
|
+
create: (context) => {
|
|
22
|
+
const ngOnDestroyMethodSelector = `MethodDefinition[key.name='ngOnDestroy']`;
|
|
23
|
+
const componentStoreClassName = 'ComponentStore';
|
|
24
|
+
let hasNgrxComponentStoreImport = false;
|
|
25
|
+
return {
|
|
26
|
+
[`ImportDeclaration[source.value='@ngrx/component-store'] ImportSpecifier[imported.name='${componentStoreClassName}']`](_) {
|
|
27
|
+
hasNgrxComponentStoreImport = true;
|
|
28
|
+
},
|
|
29
|
+
[`ClassDeclaration[superClass.name=${componentStoreClassName}] ${ngOnDestroyMethodSelector}:not(:has(CallExpression[callee.object.type='Super'][callee.property.name='ngOnDestroy'])) > .key`](node) {
|
|
30
|
+
if (!hasNgrxComponentStoreImport) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
context.report({
|
|
34
|
+
node,
|
|
35
|
+
messageId: exports.messageId,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=require-super-ondestroy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-super-ondestroy.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/require-super-ondestroy.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,qDAAgD;AAGnC,QAAA,SAAS,GAAG,uBAAuB,CAAC;AAIjD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EACT,yFAAyF;SAC5F;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,yEAAyE;SAC5E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,yBAAyB,GAAG,0CAA0C,CAAC;QAC7E,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;QAEjD,IAAI,2BAA2B,GAAG,KAAK,CAAC;QAExC,OAAO;YACL,CAAC,0FAA0F,uBAAuB,IAAI,CAAC,CACrH,CAA2B;gBAE3B,2BAA2B,GAAG,IAAI,CAAC;YACrC,CAAC;YACD,CAAC,oCAAoC,uBAAuB,KAAK,yBAAyB,mGAAmG,CAAC,CAC5L,IAAyB;gBAEzB,IAAI,CAAC,2BAA2B,EAAE,CAAC;oBACjC,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import path = require('path');\nimport { createRule } from '../../rule-creator';\nimport { TSESTree } from '@typescript-eslint/types';\n\nexport const messageId = 'requireSuperOnDestroy';\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description:\n 'Overriden ngOnDestroy method in component stores require a call to super.ngOnDestroy().',\n },\n schema: [],\n messages: {\n [messageId]:\n \"Call super.ngOnDestroy() inside a component store's ngOnDestroy method.\",\n },\n },\n defaultOptions: [],\n create: (context) => {\n const ngOnDestroyMethodSelector = `MethodDefinition[key.name='ngOnDestroy']`;\n const componentStoreClassName = 'ComponentStore';\n\n let hasNgrxComponentStoreImport = false;\n\n return {\n [`ImportDeclaration[source.value='@ngrx/component-store'] ImportSpecifier[imported.name='${componentStoreClassName}']`](\n _: TSESTree.ImportSpecifier\n ) {\n hasNgrxComponentStoreImport = true;\n },\n [`ClassDeclaration[superClass.name=${componentStoreClassName}] ${ngOnDestroyMethodSelector}:not(:has(CallExpression[callee.object.type='Super'][callee.property.name='ngOnDestroy'])) > .key`](\n node: TSESTree.Identifier\n ) {\n if (!hasNgrxComponentStoreImport) {\n return;\n }\n\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -43,8 +43,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
43
43
|
},
|
|
44
44
|
defaultOptions: [],
|
|
45
45
|
create: (context) => {
|
|
46
|
-
const
|
|
47
|
-
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
46
|
+
const storeNames = (0, utils_1.getNgrxComponentStoreNames)(context);
|
|
48
47
|
const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;
|
|
49
48
|
const selectors = [
|
|
50
49
|
`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/updater-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"updater-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/updater-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA0E;AAE7D,QAAA,SAAS,GAAG,2BAA2B,CAAC;AAKrD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,gDAAgD;SAC9D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,6HAA6H;SAChI;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,IAAA,kCAA0B,EAAC,OAAO,CAAC,CAAC;QACvD,MAAM,qBAAqB,GAAG,0DAA0D,CAAC;QACzF,MAAM,SAAS,GAAG;YAChB,mIAAmI,qBAAqB,EAAE;YAC1J,UAAU;gBACR,GAAG,IAAA,uBAAe,EAChB,UAAU,CACX,sCAAsC,qBAAqB,EAAE;SACjE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO;YACL,CAAC,SAAS,CAAC,CAAC,IAAsC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgrxComponentStoreNames, namedExpression } from '../../utils';\n\nexport const messageId = 'updaterExplicitReturnType';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description: '`Updater` should have an explicit return type.',\n },\n schema: [],\n messages: {\n [messageId]:\n '`Updater` should have an explicit return type when using arrow functions: `this.store.updater((state, value): State => {}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const storeNames = getNgrxComponentStoreNames(context);\n const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;\n const selectors = [\n `ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,\n storeNames &&\n `${namedExpression(\n storeNames\n )}[callee.property.name='updater'] > ${withoutTypeAnnotation}`,\n ]\n .filter(Boolean)\n .join(',');\n\n return {\n [selectors](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -44,7 +44,6 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
44
44
|
},
|
|
45
45
|
defaultOptions: [],
|
|
46
46
|
create: (context) => {
|
|
47
|
-
const sourceCode = context.getSourceCode();
|
|
48
47
|
const effectsInProviders = new Set();
|
|
49
48
|
const effectsInImports = new Set();
|
|
50
49
|
return {
|
|
@@ -62,7 +61,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
62
61
|
context.report({
|
|
63
62
|
node: effectInProvider,
|
|
64
63
|
messageId: exports.messageId,
|
|
65
|
-
fix: (fixer) => (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, effectInProvider),
|
|
64
|
+
fix: (fixer) => (0, utils_1.getNodeToCommaRemoveFix)(context.sourceCode, fixer, effectInProvider),
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
effectsInImports.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-effects-in-providers.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effects-in-providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,SAAS,GAAG,sBAAsB,CAAC;AAKhD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,oFAAoF;SACvF;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,oFAAoF;SACvF;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"no-effects-in-providers.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effects-in-providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,SAAS,GAAG,sBAAsB,CAAC;AAKhD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,oFAAoF;SACvF;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,oFAAoF;SACvF;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC1D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE3C,OAAO;YACL,CAAC,kCAA0B,CAAC,CAAC,IAAyB;gBACpD,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACD,CAAC,gCAAwB,CAAC,CAAC,EAAE,IAAI,EAAuB;gBACtD,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,CAAC,GAAG,yBAAiB,OAAO,CAAC;gBAC3B,KAAK,MAAM,gBAAgB,IAAI,kBAAkB,EAAE,CAAC;oBAClD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjD,SAAS;oBACX,CAAC;oBAED,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,gBAAgB;wBACtB,SAAS,EAAT,iBAAS;wBACT,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,IAAA,+BAAuB,EACrB,OAAO,CAAC,UAAU,EAClB,KAAK,EACL,gBAAgB,CACjB;qBACJ,CAAC,CAAC;gBACL,CAAC;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBACzB,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n effectsInNgModuleImports,\n effectsInNgModuleProviders,\n getNodeToCommaRemoveFix,\n ngModuleDecorator,\n} from '../../utils';\n\nexport const messageId = 'noEffectsInProviders';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const effectsInProviders = new Set<TSESTree.Identifier>();\n const effectsInImports = new Set<string>();\n\n return {\n [effectsInNgModuleProviders](node: TSESTree.Identifier) {\n effectsInProviders.add(node);\n },\n [effectsInNgModuleImports]({ name }: TSESTree.Identifier) {\n effectsInImports.add(name);\n },\n [`${ngModuleDecorator}:exit`]() {\n for (const effectInProvider of effectsInProviders) {\n if (!effectsInImports.has(effectInProvider.name)) {\n continue;\n }\n\n context.report({\n node: effectInProvider,\n messageId,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(\n context.sourceCode,\n fixer,\n effectInProvider\n ),\n });\n }\n\n effectsInImports.clear();\n effectsInProviders.clear();\n },\n };\n },\n});\n"]}
|
|
@@ -45,7 +45,6 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
45
45
|
},
|
|
46
46
|
defaultOptions: [],
|
|
47
47
|
create: (context) => {
|
|
48
|
-
const sourceCode = context.getSourceCode();
|
|
49
48
|
const nonParametrizedEffect = `${utils_2.createEffectExpression} > ArrowFunctionExpression > .body[type!=/^(ArrowFunctionExpression|BlockStatement)$/]`;
|
|
50
49
|
const parametrizedEffect = `${utils_2.createEffectExpression} > ArrowFunctionExpression > ArrowFunctionExpression > .body[type!='BlockStatement']`;
|
|
51
50
|
const parametrizedEffectWithinBlockStatement = `${utils_2.createEffectExpression} > ArrowFunctionExpression > BlockStatement > ReturnStatement > ArrowFunctionExpression > .body[type!='BlockStatement']`;
|
|
@@ -55,7 +54,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
55
54
|
node,
|
|
56
55
|
messageId: exports.messageId,
|
|
57
56
|
fix: (fixer) => {
|
|
58
|
-
const [previousNode, nextNode] = getSafeNodesToApplyFix(sourceCode, node);
|
|
57
|
+
const [previousNode, nextNode] = getSafeNodesToApplyFix(context.sourceCode, node);
|
|
59
58
|
return [
|
|
60
59
|
fixer.insertTextBefore(previousNode, `{ return `),
|
|
61
60
|
fixer.insertTextAfter(nextNode, ` }`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-effect-callback-in-block-statement.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-effect-callback-in-block-statement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAoD;AACpD,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAqD;AAExC,QAAA,SAAS,GAAG,sCAAsC,CAAC;AAKhE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;SAC5D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,kEAAkE;SACrE;QACD,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"prefer-effect-callback-in-block-statement.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-effect-callback-in-block-statement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAoD;AACpD,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAqD;AAExC,QAAA,SAAS,GAAG,sCAAsC,CAAC;AAKhE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ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;QACT,gBAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACvC,CAAC;QACD,OAAO,CAAC,aAAa,EAAE,SAAS,CAAU,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAC/B,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createEffectExpression } from '../../utils';\n\nexport const messageId = 'preferEffectCallbackInBlockStatement';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n docs: {\n description: 'A block statement is easier to troubleshoot.',\n },\n schema: [],\n messages: {\n [messageId]:\n 'The callback of `Effect` should be wrapped in a block statement.',\n },\n fixable: 'code',\n },\n defaultOptions: [],\n create: (context) => {\n const nonParametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > .body[type!=/^(ArrowFunctionExpression|BlockStatement)$/]` as const;\n const parametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n const parametrizedEffectWithinBlockStatement =\n `${createEffectExpression} > ArrowFunctionExpression > BlockStatement > ReturnStatement > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n\n return {\n [`${nonParametrizedEffect}, ${parametrizedEffect}, ${parametrizedEffectWithinBlockStatement}`](\n node: TSESTree.ArrowFunctionExpression['body']\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => {\n const [previousNode, nextNode] = getSafeNodesToApplyFix(\n context.sourceCode,\n node\n );\n return [\n fixer.insertTextBefore(previousNode, `{ return `),\n fixer.insertTextAfter(nextNode, ` }`),\n ];\n },\n });\n },\n };\n },\n});\n\nfunction getSafeNodesToApplyFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n node: TSESTree.Node\n) {\n const previousToken = sourceCode.getTokenBefore(node);\n const nextToken = sourceCode.getTokenAfter(node);\n\n if (\n previousToken &&\n ASTUtils.isOpeningParenToken(previousToken) &&\n nextToken &&\n ASTUtils.isClosingParenToken(nextToken)\n ) {\n return [previousToken, nextToken] as const;\n }\n\n return [node, node] as const;\n}\n"]}
|
package/src/rules/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const rules: {
|
|
|
2
2
|
'avoid-combining-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
3
|
'avoid-mapping-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMappingComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
4
4
|
'updater-explicit-return-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"updaterExplicitReturnType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
'require-super-ondestroy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"requireSuperOnDestroy", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
6
|
'avoid-cyclic-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCyclicEffects", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
6
7
|
'no-dispatch-in-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDispatchInEffects" | "noDispatchInEffectsSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
7
8
|
'no-effects-in-providers': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noEffectsInProviders", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
package/src/rules/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.rules = void 0;
|
|
|
8
8
|
const avoid_combining_component_store_selectors_1 = __importDefault(require("./component-store/avoid-combining-component-store-selectors"));
|
|
9
9
|
const avoid_mapping_component_store_selectors_1 = __importDefault(require("./component-store/avoid-mapping-component-store-selectors"));
|
|
10
10
|
const updater_explicit_return_type_1 = __importDefault(require("./component-store/updater-explicit-return-type"));
|
|
11
|
+
const require_super_ondestroy_1 = __importDefault(require("./component-store/require-super-ondestroy"));
|
|
11
12
|
// effects
|
|
12
13
|
const avoid_cyclic_effects_1 = __importDefault(require("./effects/avoid-cyclic-effects"));
|
|
13
14
|
const no_dispatch_in_effects_1 = __importDefault(require("./effects/no-dispatch-in-effects"));
|
|
@@ -47,6 +48,7 @@ exports.rules = {
|
|
|
47
48
|
'avoid-combining-component-store-selectors': avoid_combining_component_store_selectors_1.default,
|
|
48
49
|
'avoid-mapping-component-store-selectors': avoid_mapping_component_store_selectors_1.default,
|
|
49
50
|
'updater-explicit-return-type': updater_explicit_return_type_1.default,
|
|
51
|
+
'require-super-ondestroy': require_super_ondestroy_1.default,
|
|
50
52
|
//effects
|
|
51
53
|
'avoid-cyclic-effects': avoid_cyclic_effects_1.default,
|
|
52
54
|
'no-dispatch-in-effects': no_dispatch_in_effects_1.default,
|
package/src/rules/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/rules/index.ts"],"names":[],"mappings":";;;;;;AAAA,kBAAkB;AAClB,4IAAgH;AAChH,wIAA4G;AAC5G,kHAAuF;AACvF,UAAU;AACV,0FAAgE;AAChE,8FAAmE;AACnE,gGAAqE;AACrE,8GAAkF;AAClF,kHAAqF;AACrF,oIAAuG;AACvG,gHAAqF;AACrF,QAAQ;AACR,kGAAwE;AACxE,8IAAkH;AAClH,oHAAwF;AACxF,8FAAoE;AACpE,sFAA4D;AAC5D,kGAAuE;AACvE,8FAAkE;AAClE,0FAAgE;AAChE,0FAA+D;AAC/D,gHAAoF;AACpF,0FAAgE;AAChE,kHA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EAAE,4CAA4B;CACnE,CAAC","sourcesContent":["// component-store\nimport avoidCombiningComponentStoreSelectors from './component-store/avoid-combining-component-store-selectors';\nimport avoidMappingComponentStoreSelectors from './component-store/avoid-mapping-component-store-selectors';\nimport updaterExplicitReturnType from './component-store/updater-explicit-return-type';\n// effects\nimport avoidCyclicEffects from './effects/avoid-cyclic-effects';\nimport noDispatchInEffects from './effects/no-dispatch-in-effects';\nimport noEffectsInProviders from './effects/no-effects-in-providers';\nimport noMultipleActionsInEffects from './effects/no-multiple-actions-in-effects';\nimport preferActionCreatorInOfType from './effects/prefer-action-creator-in-of-type';\nimport preferEffectCallbackInBlockStatement from './effects/prefer-effect-callback-in-block-statement';\nimport useEffectsLifecycleInterface from './effects/use-effects-lifecycle-interface';\n// store\nimport avoidCombiningSelectors from './store/avoid-combining-selectors';\nimport avoidDispatchingMultipleActionsSequentially from './store/avoid-dispatching-multiple-actions-sequentially';\nimport avoidDuplicateActionsInReducer from './store/avoid-duplicate-actions-in-reducer';\nimport avoidMappingSelectors from './store/avoid-mapping-selectors';\nimport goodActionHygiene from './store/good-action-hygiene';\nimport noMultipleGlobalStores from './store/no-multiple-global-stores';\nimport noReducerInKeyNames from './store/no-reducer-in-key-names';\nimport noStoreSubscription from './store/no-store-subscription';\nimport noTypedGlobalStore from './store/no-typed-global-store';\nimport onFunctionExplicitReturnType from './store/on-function-explicit-return-type';\nimport preferActionCreator from './store/prefer-action-creator';\nimport preferActionCreatorInDispatch from './store/prefer-action-creator-in-dispatch';\nimport preferInlineActionProps from './store/prefer-inline-action-props';\nimport preferOneGenericInCreateForFeatureSelector from './store/prefer-one-generic-in-create-for-feature-selector';\nimport preferSelectorInSelect from './store/prefer-selector-in-select';\nimport prefixSelectorsWithSelect from './store/prefix-selectors-with-select';\nimport selectStyle from './store/select-style';\nimport useConsistentGlobalStoreName from './store/use-consistent-global-store-name';\n// operators\nimport preferConcatLatestFrom from './operators/prefer-concat-latest-from';\n// signals\nimport signalStateNoArraysAtRootLevel from './signals/signal-state-no-arrays-at-root-level';\nimport signalStoreFeatureShouldUseGenericType from './signals/signal-store-feature-should-use-generic-type';\nimport withStateNoArraysAtRootLevel from './signals/with-state-no-arrays-at-root-level';\nimport preferProtectedState from './signals/prefer-protected-state';\n\nexport const rules = {\n // component-store\n 'avoid-combining-component-store-selectors':\n avoidCombiningComponentStoreSelectors,\n 'avoid-mapping-component-store-selectors':\n avoidMappingComponentStoreSelectors,\n 'updater-explicit-return-type': updaterExplicitReturnType,\n //effects\n 'avoid-cyclic-effects': avoidCyclicEffects,\n 'no-dispatch-in-effects': noDispatchInEffects,\n 'no-effects-in-providers': noEffectsInProviders,\n 'no-multiple-actions-in-effects': noMultipleActionsInEffects,\n 'prefer-action-creator-in-of-type': preferActionCreatorInOfType,\n 'prefer-effect-callback-in-block-statement':\n preferEffectCallbackInBlockStatement,\n 'use-effects-lifecycle-interface': useEffectsLifecycleInterface,\n // store\n 'avoid-combining-selectors': avoidCombiningSelectors,\n 'avoid-dispatching-multiple-actions-sequentially':\n avoidDispatchingMultipleActionsSequentially,\n 'avoid-duplicate-actions-in-reducer': avoidDuplicateActionsInReducer,\n 'avoid-mapping-selectors': avoidMappingSelectors,\n 'good-action-hygiene': goodActionHygiene,\n 'no-multiple-global-stores': noMultipleGlobalStores,\n 'no-reducer-in-key-names': noReducerInKeyNames,\n 'no-store-subscription': noStoreSubscription,\n 'no-typed-global-store': noTypedGlobalStore,\n 'on-function-explicit-return-type': onFunctionExplicitReturnType,\n 'prefer-action-creator': preferActionCreator,\n 'prefer-action-creator-in-dispatch': preferActionCreatorInDispatch,\n 'prefer-inline-action-props': preferInlineActionProps,\n 'prefer-one-generic-in-create-for-feature-selector':\n preferOneGenericInCreateForFeatureSelector,\n 'prefer-selector-in-select': preferSelectorInSelect,\n 'prefix-selectors-with-select': prefixSelectorsWithSelect,\n 'select-style': selectStyle,\n 'use-consistent-global-store-name': useConsistentGlobalStoreName,\n // operators\n 'prefer-concat-latest-from': preferConcatLatestFrom,\n // signals\n 'signal-state-no-arrays-at-root-level': signalStateNoArraysAtRootLevel,\n 'signal-store-feature-should-use-generic-type':\n signalStoreFeatureShouldUseGenericType,\n 'prefer-protected-state': preferProtectedState,\n 'with-state-no-arrays-at-root-level': withStateNoArraysAtRootLevel,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/rules/index.ts"],"names":[],"mappings":";;;;;;AAAA,kBAAkB;AAClB,4IAAgH;AAChH,wIAA4G;AAC5G,kHAAuF;AACvF,wGAA8E;AAC9E,UAAU;AACV,0FAAgE;AAChE,8FAAmE;AACnE,gGAAqE;AACrE,8GAAkF;AAClF,kHAAqF;AACrF,oIAAuG;AACvG,gHAAqF;AACrF,QAAQ;AACR,kGAAwE;AACxE,8IAAkH;AAClH,oHAAwF;AACxF,8FAAoE;AACpE,sFAA4D;AAC5D,kGAAuE;AACvE,8FAAkE;AAClE,0FAAgE;AAChE,0FAA+D;AAC/D,gHAAoF;AACpF,0FAAgE;AAChE,kHAAsF;AACtF,oGAAyE;AACzE,kJAAmH;AACnH,kGAAuE;AACvE,wGAA6E;AAC7E,wEAA+C;AAC/C,gHAAoF;AACpF,YAAY;AACZ,sGAA2E;AAC3E,UAAU;AACV,0HAA4F;AAC5F,0IAA4G;AAC5G,sHAAwF;AACxF,8FAAoE;AAEvD,QAAA,KAAK,GAAG;IACnB,kBAAkB;IAClB,2CAA2C,EACzC,mDAAqC;IACvC,yCAAyC,EACvC,iDAAmC;IACrC,8BAA8B,EAAE,sCAAyB;IACzD,yBAAyB,EAAE,iCAAqB;IAChD,SAAS;IACT,sBAAsB,EAAE,8BAAkB;IAC1C,wBAAwB,EAAE,gCAAmB;IAC7C,yBAAyB,EAAE,iCAAoB;IAC/C,gCAAgC,EAAE,wCAA0B;IAC5D,kCAAkC,EAAE,0CAA2B;IAC/D,2CAA2C,EACzC,mDAAoC;IACtC,iCAAiC,EAAE,yCAA4B;IAC/D,QAAQ;IACR,2BAA2B,EAAE,mCAAuB;IACpD,iDAAiD,EAC/C,yDAA2C;IAC7C,oCAAoC,EAAE,4CAA8B;IACpE,yBAAyB,EAAE,iCAAqB;IAChD,qBAAqB,EAAE,6BAAiB;IACxC,2BAA2B,EAAE,mCAAsB;IACnD,yBAAyB,EAAE,iCAAmB;IAC9C,uBAAuB,EAAE,+BAAmB;IAC5C,uBAAuB,EAAE,+BAAkB;IAC3C,kCAAkC,EAAE,0CAA4B;IAChE,uBAAuB,EAAE,+BAAmB;IAC5C,mCAAmC,EAAE,2CAA6B;IAClE,4BAA4B,EAAE,oCAAuB;IACrD,mDAAmD,EACjD,2DAA0C;IAC5C,2BAA2B,EAAE,mCAAsB;IACnD,8BAA8B,EAAE,sCAAyB;IACzD,cAAc,EAAE,sBAAW;IAC3B,kCAAkC,EAAE,0CAA4B;IAChE,YAAY;IACZ,2BAA2B,EAAE,mCAAsB;IACnD,UAAU;IACV,sCAAsC,EAAE,8CAA8B;IACtE,8CAA8C,EAC5C,sDAAsC;IACxC,wBAAwB,EAAE,gCAAoB;IAC9C,oCAAoC,EAAE,4CAA4B;CACnE,CAAC","sourcesContent":["// component-store\nimport avoidCombiningComponentStoreSelectors from './component-store/avoid-combining-component-store-selectors';\nimport avoidMappingComponentStoreSelectors from './component-store/avoid-mapping-component-store-selectors';\nimport updaterExplicitReturnType from './component-store/updater-explicit-return-type';\nimport requireSuperOnDestroy from './component-store/require-super-ondestroy';\n// effects\nimport avoidCyclicEffects from './effects/avoid-cyclic-effects';\nimport noDispatchInEffects from './effects/no-dispatch-in-effects';\nimport noEffectsInProviders from './effects/no-effects-in-providers';\nimport noMultipleActionsInEffects from './effects/no-multiple-actions-in-effects';\nimport preferActionCreatorInOfType from './effects/prefer-action-creator-in-of-type';\nimport preferEffectCallbackInBlockStatement from './effects/prefer-effect-callback-in-block-statement';\nimport useEffectsLifecycleInterface from './effects/use-effects-lifecycle-interface';\n// store\nimport avoidCombiningSelectors from './store/avoid-combining-selectors';\nimport avoidDispatchingMultipleActionsSequentially from './store/avoid-dispatching-multiple-actions-sequentially';\nimport avoidDuplicateActionsInReducer from './store/avoid-duplicate-actions-in-reducer';\nimport avoidMappingSelectors from './store/avoid-mapping-selectors';\nimport goodActionHygiene from './store/good-action-hygiene';\nimport noMultipleGlobalStores from './store/no-multiple-global-stores';\nimport noReducerInKeyNames from './store/no-reducer-in-key-names';\nimport noStoreSubscription from './store/no-store-subscription';\nimport noTypedGlobalStore from './store/no-typed-global-store';\nimport onFunctionExplicitReturnType from './store/on-function-explicit-return-type';\nimport preferActionCreator from './store/prefer-action-creator';\nimport preferActionCreatorInDispatch from './store/prefer-action-creator-in-dispatch';\nimport preferInlineActionProps from './store/prefer-inline-action-props';\nimport preferOneGenericInCreateForFeatureSelector from './store/prefer-one-generic-in-create-for-feature-selector';\nimport preferSelectorInSelect from './store/prefer-selector-in-select';\nimport prefixSelectorsWithSelect from './store/prefix-selectors-with-select';\nimport selectStyle from './store/select-style';\nimport useConsistentGlobalStoreName from './store/use-consistent-global-store-name';\n// operators\nimport preferConcatLatestFrom from './operators/prefer-concat-latest-from';\n// signals\nimport signalStateNoArraysAtRootLevel from './signals/signal-state-no-arrays-at-root-level';\nimport signalStoreFeatureShouldUseGenericType from './signals/signal-store-feature-should-use-generic-type';\nimport withStateNoArraysAtRootLevel from './signals/with-state-no-arrays-at-root-level';\nimport preferProtectedState from './signals/prefer-protected-state';\n\nexport const rules = {\n // component-store\n 'avoid-combining-component-store-selectors':\n avoidCombiningComponentStoreSelectors,\n 'avoid-mapping-component-store-selectors':\n avoidMappingComponentStoreSelectors,\n 'updater-explicit-return-type': updaterExplicitReturnType,\n 'require-super-ondestroy': requireSuperOnDestroy,\n //effects\n 'avoid-cyclic-effects': avoidCyclicEffects,\n 'no-dispatch-in-effects': noDispatchInEffects,\n 'no-effects-in-providers': noEffectsInProviders,\n 'no-multiple-actions-in-effects': noMultipleActionsInEffects,\n 'prefer-action-creator-in-of-type': preferActionCreatorInOfType,\n 'prefer-effect-callback-in-block-statement':\n preferEffectCallbackInBlockStatement,\n 'use-effects-lifecycle-interface': useEffectsLifecycleInterface,\n // store\n 'avoid-combining-selectors': avoidCombiningSelectors,\n 'avoid-dispatching-multiple-actions-sequentially':\n avoidDispatchingMultipleActionsSequentially,\n 'avoid-duplicate-actions-in-reducer': avoidDuplicateActionsInReducer,\n 'avoid-mapping-selectors': avoidMappingSelectors,\n 'good-action-hygiene': goodActionHygiene,\n 'no-multiple-global-stores': noMultipleGlobalStores,\n 'no-reducer-in-key-names': noReducerInKeyNames,\n 'no-store-subscription': noStoreSubscription,\n 'no-typed-global-store': noTypedGlobalStore,\n 'on-function-explicit-return-type': onFunctionExplicitReturnType,\n 'prefer-action-creator': preferActionCreator,\n 'prefer-action-creator-in-dispatch': preferActionCreatorInDispatch,\n 'prefer-inline-action-props': preferInlineActionProps,\n 'prefer-one-generic-in-create-for-feature-selector':\n preferOneGenericInCreateForFeatureSelector,\n 'prefer-selector-in-select': preferSelectorInSelect,\n 'prefix-selectors-with-select': prefixSelectorsWithSelect,\n 'select-style': selectStyle,\n 'use-consistent-global-store-name': useConsistentGlobalStoreName,\n // operators\n 'prefer-concat-latest-from': preferConcatLatestFrom,\n // signals\n 'signal-state-no-arrays-at-root-level': signalStateNoArraysAtRootLevel,\n 'signal-store-feature-should-use-generic-type':\n signalStoreFeatureShouldUseGenericType,\n 'prefer-protected-state': preferProtectedState,\n 'with-state-no-arrays-at-root-level': withStateNoArraysAtRootLevel,\n};\n"]}
|
|
@@ -65,7 +65,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
65
65
|
context.report({
|
|
66
66
|
node,
|
|
67
67
|
messageId: exports.messageId,
|
|
68
|
-
fix: (fixer) => getFixes(context.
|
|
68
|
+
fix: (fixer) => getFixes(context.sourceCode, fixer, node),
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-concat-latest-from.js","sour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,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"prefer-concat-latest-from.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/operators/prefer-concat-latest-from.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAIkC;AAClC,2CAA6B;AAC7B,qDAAgD;AAChD,uCAOqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAQlD,MAAM,cAAc,GAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1D,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE;YACJ,WAAW,EAAE,SAAS,uBAAuB,mBAAmB,qBAAqB,oFAAoF;SAC1K;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,cAAc,CAAC,MAAM;qBAC/B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,SAAS,uBAAuB,mBAAmB,qBAAqB,KAAK;SAC3F;KACF;IACD,cAAc,EAAE,CAAC,cAAc,CAAC;IAChC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO;gBACL,CAAC,GAAG,8BAAsB,qDAAqD,CAAC,CAC9E,IAA8B;oBAE9B,OAAO,CAAC,MA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,MAAM,GAAG,CAAC,CAAC;IACvE,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;IACzC,MAAM,SAAS,GACb,kCAAkC;QAClC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,uBAAuB,CAAC;QAChD,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,sBAAc,CAAC,uBAAuB;YAC9D,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;KACvD,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;QACd,KAAK;QACL,UAAU,EAAE,uBAAuB;QACnC,UAAU,EAAE,yBAAiB,CAAC,SAAS;QACvC,IAAI;KACL,CAAC,EACF,GAAG,CAAC,kCAAkC,IAAI,SAAS;QACjD,CAAC,CAAC;YACE,IAAA,uBAAe,EAAC;gBACd,KAAK;gBACL,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI;aACL,CAAC;YACF,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;SACvD;QACH,CAAC,CAAC,EAAE,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n AST_NODE_TYPES,\n type TSESLint,\n type TSESTree,\n} from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getImportAddFix,\n getNgRxEffectActions,\n namedExpression,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'preferConcatLatestFrom';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [{ readonly strict: boolean }];\ntype WithLatestFromIdentifier = TSESTree.Identifier & {\n parent: TSESTree.CallExpression;\n};\n\nconst defaultOptions: Options[number] = { strict: false };\nconst concatLatestFromKeyword = 'concatLatestFrom';\nconst withLatestFromKeyword = 'withLatestFrom';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'operators',\n docs: {\n description: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\` to prevent the selector from firing until the correct \\`Action\\` is dispatched.`,\n },\n fixable: 'code',\n schema: [\n {\n type: 'object',\n properties: {\n strict: {\n type: 'boolean',\n default: defaultOptions.strict,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n [messageId]: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\`.`,\n },\n },\n defaultOptions: [defaultOptions],\n create: (context, [options]) => {\n if (options.strict) {\n return {\n [`${createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(context.sourceCode, fixer, node),\n });\n },\n };\n }\n\n const { identifiers = [], sourceCode } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n return {\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(sourceCode, fixer, node),\n });\n },\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: WithLatestFromIdentifier\n) {\n const { parent } = node;\n const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;\n const [firstArgument] = parent.arguments;\n const nextToken =\n isUsingDeprecatedProjectorArgument &&\n sourceCode.getTokenAfter(firstArgument);\n return [\n fixer.replaceText(node, concatLatestFromKeyword),\n ...(firstArgument.type == AST_NODE_TYPES.ArrowFunctionExpression\n ? []\n : [fixer.insertTextBefore(firstArgument, '() => ')]),\n ].concat(\n getImportAddFix({\n fixer,\n importName: concatLatestFromKeyword,\n moduleName: NGRX_MODULE_PATHS.operators,\n node,\n }),\n ...(isUsingDeprecatedProjectorArgument && nextToken\n ? [\n getImportAddFix({\n fixer,\n importName: 'map',\n moduleName: 'rxjs/operators',\n node,\n }),\n fixer.insertTextAfterRange(nextToken.range, '), map('),\n ]\n : [])\n );\n}\n"]}
|
|
@@ -46,7 +46,6 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
46
46
|
},
|
|
47
47
|
defaultOptions: [],
|
|
48
48
|
create: (context) => {
|
|
49
|
-
const sourceCode = context.getSourceCode();
|
|
50
49
|
const collectedActions = new Map();
|
|
51
50
|
return {
|
|
52
51
|
[`${utils_1.createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({ arguments: [action], }) {
|
|
@@ -68,7 +67,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
68
67
|
suggest: [
|
|
69
68
|
{
|
|
70
69
|
messageId: exports.avoidDuplicateActionsInReducerSuggest,
|
|
71
|
-
fix: (fixer) => (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, node.parent),
|
|
70
|
+
fix: (fixer) => (0, utils_1.getNodeToCommaRemoveFix)(context.sourceCode, fixer, node.parent),
|
|
72
71
|
},
|
|
73
72
|
],
|
|
74
73
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;SAC3D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,sCAA8B,CAAC,EAC9B,gEAAgE;YAClE,CAAC,6CAAqC,CAAC,EAAE,0BAA0B;SACpE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;SAC3D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,sCAA8B,CAAC,EAC9B,gEAAgE;YAClE,CAAC,6CAAqC,CAAC,EAAE,0BAA0B;SACpE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAoB,CAAC;QAErD,OAAO;YACL,CAAC,GAAG,qBAAa,oEAAoE,CAAC,CAAC,EACrF,SAAS,EAAE,CAAC,MAAM,CAAC,GAGpB;gBACC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACxD,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,CAAC,GAAG,qBAAa,OAAO,CAAC;gBACvB,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;oBACzD,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;wBAC5B,MAAM;oBACR,CAAC;oBAED,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;wBAC/B,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,sCAA8B;4BACzC,IAAI,EAAE;gCACJ,UAAU;6BACX;4BACD,OAAO,EAAE;gCACP;oCACE,SAAS,EAAE,6CAAqC;oCAChD,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,IAAA,+BAAuB,EACrB,OAAO,CAAC,UAAU,EAClB,KAAK,EACL,IAAI,CAAC,MAAM,CACZ;iCACJ;6BACF;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(\n context.sourceCode,\n fixer,\n node.parent\n ),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
|
|
@@ -47,7 +47,6 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
47
47
|
},
|
|
48
48
|
defaultOptions: [],
|
|
49
49
|
create: (context) => {
|
|
50
|
-
const sourceCode = context.getSourceCode();
|
|
51
50
|
return {
|
|
52
51
|
[utils_2.onFunctionWithoutType](node) {
|
|
53
52
|
context.report({
|
|
@@ -56,7 +55,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
56
55
|
suggest: [
|
|
57
56
|
{
|
|
58
57
|
messageId: exports.onFunctionExplicitReturnTypeSuggest,
|
|
59
|
-
fix: (fixer) => getFixes(node, sourceCode, fixer),
|
|
58
|
+
fix: (fixer) => getFixes(node, context.sourceCode, fixer),
|
|
60
59
|
},
|
|
61
60
|
],
|
|
62
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAoD;AACpD,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;SAClE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,oCAA4B,CAAC,EAC5B,mHAAmH;YACrH,CAAC,2CAAmC,CAAC,EACnC,iIAAiI;SACpI;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,
|
|
1
|
+
{"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAoD;AACpD,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9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,SAAS,GAAG,IAAA,eAAO,EAAC,MAAM,CAAC,CAAC;IAClC,MAAM,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,eAAe,GACnB,aAAa,IAAI,gBAAQ,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAE/D,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,IAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC;QACvC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;KACpC,CAAC;AACb,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getLast, onFunctionWithoutType } from '../../utils';\n\nexport const onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';\nexport const onFunctionExplicitReturnTypeSuggest =\n 'onFunctionExplicitReturnTypeSuggest';\n\ntype MessageIds =\n | typeof onFunctionExplicitReturnType\n | typeof onFunctionExplicitReturnTypeSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: '`On` function should have an explicit return type.',\n },\n schema: [],\n messages: {\n [onFunctionExplicitReturnType]:\n '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',\n [onFunctionExplicitReturnTypeSuggest]:\n 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [onFunctionWithoutType](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId: onFunctionExplicitReturnType,\n suggest: [\n {\n messageId: onFunctionExplicitReturnTypeSuggest,\n fix: (fixer) => getFixes(node, context.sourceCode, fixer),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getFixes(\n node: TSESTree.ArrowFunctionExpression,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n) {\n const { params } = node;\n\n if (params.length === 0) {\n const [, closingParen] = sourceCode.getTokens(node);\n return fixer.insertTextAfter(closingParen, ': State');\n }\n\n const [firstParam] = params;\n const lastParam = getLast(params);\n const previousToken = sourceCode.getTokenBefore(firstParam);\n const isParenthesized =\n previousToken && ASTUtils.isOpeningParenToken(previousToken);\n\n if (isParenthesized) {\n const nextToken = sourceCode.getTokenAfter(lastParam);\n return fixer.insertTextAfter(nextToken ?? lastParam, ': State');\n }\n\n return [\n fixer.insertTextBefore(firstParam, '('),\n fixer.insertTextAfter(lastParam, '): State'),\n ] as const;\n}\n"]}
|
|
@@ -45,7 +45,6 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
45
45
|
},
|
|
46
46
|
defaultOptions: [],
|
|
47
47
|
create: (context) => {
|
|
48
|
-
const sourceCode = context.getSourceCode();
|
|
49
48
|
return {
|
|
50
49
|
[`CallExpression[callee.name='createFeatureSelector'] > TSTypeParameterInstantiation[params.length>1]`](node) {
|
|
51
50
|
context.report({
|
|
@@ -56,7 +55,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
56
55
|
messageId: exports.preferOneGenericInCreateForFeatureSelectorSuggest,
|
|
57
56
|
fix: (fixer) => {
|
|
58
57
|
const [globalState] = node.params;
|
|
59
|
-
const nextToken = sourceCode.getTokenAfter(globalState);
|
|
58
|
+
const nextToken = context.sourceCode.getTokenAfter(globalState);
|
|
60
59
|
return fixer.removeRange([
|
|
61
60
|
globalState.range[0],
|
|
62
61
|
nextToken?.range[1] ?? globalState.range[1] + 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-one-generic-in-create-for-feature-selector.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-one-generic-in-create-for-feature-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAEnC,QAAA,0CAA0C,GACrD,4CAA4C,CAAC;AAClC,QAAA,iDAAiD,GAC5D,mDAAmD,CAAC;AAOtD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,kDAA0C,CAAC,EAC1C,mDAAmD;YACrD,CAAC,yDAAiD,CAAC,EACjD,kCAAkC;SACrC;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,
|
|
1
|
+
{"version":3,"file":"prefer-one-generic-in-create-for-feature-selector.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-one-generic-in-create-for-feature-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAEnC,QAAA,0CAA0C,GACrD,4CAA4C,CAAC;AAClC,QAAA,iDAAiD,GAC5D,mDAAmD,CAAC;AAOtD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,kDAA0C,CAAC,EAC1C,mDAAmD;YACrD,CAAC,yDAAiD,CAAC,EACjD,kCAAkC;SACrC;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,qGAAqG,CAAC,CACrG,IAA2C;gBAE3C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,kDAA0C;oBACrD,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,yDAAiD;4BAC5D,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gCACb,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;gCAClC,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gCAChE,OAAO,KAAK,CAAC,WAAW,CAAC;oCACvB,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;oCACpB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;iCAChD,CAAC,CAAC;4BACL,CAAC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\n\nexport const preferOneGenericInCreateForFeatureSelector =\n 'preferOneGenericInCreateForFeatureSelector';\nexport const preferOneGenericInCreateForFeatureSelectorSuggest =\n 'preferOneGenericInCreateForFeatureSelectorSuggest';\n\ntype MessageIds =\n | typeof preferOneGenericInCreateForFeatureSelector\n | typeof preferOneGenericInCreateForFeatureSelectorSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'Prefer using a single generic to define the feature state.',\n },\n schema: [],\n messages: {\n [preferOneGenericInCreateForFeatureSelector]:\n 'Use a single generic to define the feature state.',\n [preferOneGenericInCreateForFeatureSelectorSuggest]:\n 'Remove the global state generic.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`CallExpression[callee.name='createFeatureSelector'] > TSTypeParameterInstantiation[params.length>1]`](\n node: TSESTree.TSTypeParameterInstantiation\n ) {\n context.report({\n node,\n messageId: preferOneGenericInCreateForFeatureSelector,\n suggest: [\n {\n messageId: preferOneGenericInCreateForFeatureSelectorSuggest,\n fix: (fixer) => {\n const [globalState] = node.params;\n const nextToken = context.sourceCode.getTokenAfter(globalState);\n return fixer.removeRange([\n globalState.range[0],\n nextToken?.range[1] ?? globalState.range[1] + 1,\n ]);\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
|
|
@@ -45,4 +45,5 @@ export declare function getNgRxComponentStores(context: TSESLint.RuleContext<str
|
|
|
45
45
|
export declare function getNgRxStores(context: TSESLint.RuleContext<string, readonly unknown[]>): InjectedParameterWithSourceCode;
|
|
46
46
|
export declare function escapeText(text: string): string;
|
|
47
47
|
export declare function asPattern(identifiers: readonly InjectedParameter[]): RegExp;
|
|
48
|
+
export declare function getNgrxComponentStoreNames(context: TSESLint.RuleContext<string, readonly unknown[]>): RegExp | null;
|
|
48
49
|
export {};
|
|
@@ -19,6 +19,7 @@ exports.getNgRxComponentStores = getNgRxComponentStores;
|
|
|
19
19
|
exports.getNgRxStores = getNgRxStores;
|
|
20
20
|
exports.escapeText = escapeText;
|
|
21
21
|
exports.asPattern = asPattern;
|
|
22
|
+
exports.getNgrxComponentStoreNames = getNgrxComponentStoreNames;
|
|
22
23
|
const utils_1 = require("@typescript-eslint/utils");
|
|
23
24
|
const guards_1 = require("./guards");
|
|
24
25
|
const ngrx_modules_1 = require("./ngrx-modules");
|
|
@@ -176,7 +177,7 @@ function capitalize(text) {
|
|
|
176
177
|
return `${text[0].toUpperCase()}${text.slice(1)}`;
|
|
177
178
|
}
|
|
178
179
|
function getInjectedParametersWithSourceCode(context, moduleName, importName) {
|
|
179
|
-
const sourceCode = context.
|
|
180
|
+
const sourceCode = context.sourceCode;
|
|
180
181
|
const importDeclarations = getImportDeclarations(sourceCode.ast, moduleName) ?? [];
|
|
181
182
|
const { importSpecifier } = getImportDeclarationSpecifier(importDeclarations, importName) ?? {};
|
|
182
183
|
const injectImportDeclarations = getImportDeclarations(sourceCode.ast, '@angular/core') ?? [];
|
|
@@ -231,4 +232,8 @@ function asPattern(identifiers) {
|
|
|
231
232
|
const escapedNames = identifiers.map(({ name }) => escapeText(name));
|
|
232
233
|
return new RegExp(`^(${escapedNames.join('|')})$`);
|
|
233
234
|
}
|
|
235
|
+
function getNgrxComponentStoreNames(context) {
|
|
236
|
+
const { identifiers = [] } = getNgRxComponentStores(context);
|
|
237
|
+
return identifiers.length > 0 ? asPattern(identifiers) : null;
|
|
238
|
+
}
|
|
234
239
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;AAyCA,0DAaC;AAED,sEAqBC;AAED,sDAaC;AAwBD,0CA0CC;AAED,gDA2CC;AAED,0DAWC;AAED,4CAUC;AAED,sCASC;AAED,oCAOC;AAED,4DAUC;AAED,0BAEC;AAED,4CAUC;AAED,gCA0BC;AAED,gCAEC;AAgED,oDAQC;AAED,wDAQC;AAED,sCAQC;AAGD,gCAEC;AAED,8BAGC;AAzZD,oDAAoD;AACpD,qCAkBkB;AAClB,iDAAmD;AAoBnD,SAAgB,uBAAuB,CACrC,EAAE,MAAM,EAAiB,EACzB,SAAiD;IAEjD,OAAO,MAAM,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,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pC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,iBAAiB,CAAC,EACpC,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAC3B,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,KAAK,EACvB,OAAO,CACR,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,SAAS,CAAC,WAAyC;IACjE,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/utils';\nimport {\n isCallExpression,\n isIdentifier,\n isIdentifierOrMemberExpression,\n isImportDeclaration,\n isImportDefaultSpecifier,\n isImportNamespaceSpecifier,\n isImportSpecifier,\n isLiteral,\n isMethodDefinition,\n isProgram,\n isProperty,\n isPropertyDefinition,\n isTSTypeAnnotation,\n isTSTypeReference,\n isTemplateElement,\n isTemplateLiteral,\n isTSInstantiationExpression,\n} from './guards';\nimport { NGRX_MODULE_PATHS } from './ngrx-modules';\n\ntype ConstructorFunctionExpression = TSESTree.FunctionExpression & {\n parent: TSESTree.MethodDefinition & { kind: 'constructor' };\n};\ntype InjectedParameter =\n | TSESTree.Identifier & {\n typeAnnotation: TSESTree.TSTypeAnnotation;\n parent:\n | ConstructorFunctionExpression\n | (TSESTree.TSParameterProperty & {\n parent: ConstructorFunctionExpression;\n })\n | TSESTree.PropertyDefinition;\n };\ntype InjectedParameterWithSourceCode = Readonly<{\n identifiers?: readonly InjectedParameter[];\n sourceCode: Readonly<TSESLint.SourceCode>;\n}>;\n\nexport function getNearestUpperNodeFrom<T extends TSESTree.Node>(\n { parent }: TSESTree.Node,\n predicate: (parent: TSESTree.Node) => parent is T\n): T | undefined {\n while (parent && !isProgram(parent)) {\n if (predicate(parent)) {\n return parent;\n }\n\n parent = parent.parent;\n }\n\n return undefined;\n}\n\nexport function getImportDeclarationSpecifier(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importName: string\n) {\n for (const importDeclaration of importDeclarations) {\n const importSpecifier = importDeclaration.specifiers.find(\n (importClause): importClause is TSESTree.ImportSpecifier => {\n return (\n isImportSpecifier(importClause) &&\n isIdentifier(importClause.imported) &&\n importClause.imported.name === importName\n );\n }\n );\n\n if (importSpecifier) {\n return { importDeclaration, importSpecifier } as const;\n }\n }\n\n return undefined;\n}\n\nexport function getImportDeclarations(\n node: TSESTree.Node,\n moduleName: string\n): readonly TSESTree.ImportDeclaration[] | undefined {\n let parentNode: TSESTree.Node | undefined = node;\n\n while (parentNode && !isProgram(parentNode)) {\n parentNode = parentNode.parent;\n }\n\n return parentNode?.body.filter((node): node is TSESTree.ImportDeclaration => {\n return isImportDeclaration(node) && node.source.value === moduleName;\n });\n}\n\nfunction getCorrespondentImportClause(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n compatibleWithTypeOnlyImport = false\n) {\n let importClause: TSESTree.ImportClause | undefined;\n\n for (const { importKind, specifiers } of importDeclarations) {\n const lastImportSpecifier = getLast(specifiers);\n\n if (\n (!compatibleWithTypeOnlyImport && importKind === 'type') ||\n isImportNamespaceSpecifier(lastImportSpecifier)\n ) {\n continue;\n }\n\n importClause = lastImportSpecifier;\n }\n\n return importClause;\n}\n\nexport function getImportAddFix({\n compatibleWithTypeOnlyImport = false,\n fixer,\n importName,\n moduleName,\n node,\n}: {\n compatibleWithTypeOnlyImport?: boolean;\n fixer: TSESLint.RuleFixer;\n importName: string;\n moduleName: string;\n node: TSESTree.Node;\n}): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const fullImport = `import { ${importName} } from '${moduleName}';`;\n const importDeclarations = getImportDeclarations(node, moduleName);\n\n if (!importDeclarations?.length) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const importDeclarationSpecifier = getImportDeclarationSpecifier(\n importDeclarations,\n importName\n );\n\n if (importDeclarationSpecifier) {\n return [];\n }\n\n const importClause = getCorrespondentImportClause(\n importDeclarations,\n compatibleWithTypeOnlyImport\n );\n\n if (!importClause) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const replacementText = isImportDefaultSpecifier(importClause)\n ? `, { ${importName} }`\n : `, ${importName}`;\n return fixer.insertTextAfter(importClause, replacementText);\n}\n\nexport function getImportRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importedName: string,\n fixer: TSESLint.RuleFixer\n): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const { importDeclaration, importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importedName) ?? {};\n\n if (!importDeclaration || !importSpecifier) {\n return [];\n }\n\n const isFirstImportSpecifier =\n importDeclaration.specifiers[0] === importSpecifier;\n const isLastImportSpecifier =\n getLast(importDeclaration.specifiers) === importSpecifier;\n const isSingleImportSpecifier =\n isFirstImportSpecifier && isLastImportSpecifier;\n\n if (isSingleImportSpecifier) {\n return fixer.remove(importDeclaration);\n }\n\n const tokenAfterImportSpecifier = sourceCode.getTokenAfter(importSpecifier);\n\n if (isFirstImportSpecifier && tokenAfterImportSpecifier) {\n return fixer.removeRange([\n importSpecifier.range[0],\n tokenAfterImportSpecifier.range[1],\n ]);\n }\n\n const tokenBeforeImportSpecifier = sourceCode.getTokenBefore(importSpecifier);\n\n if (!tokenBeforeImportSpecifier) {\n return [];\n }\n\n return fixer.removeRange([\n tokenBeforeImportSpecifier.range[0],\n importSpecifier.range[1],\n ]);\n}\n\nexport function getNodeToCommaRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const nextToken = sourceCode.getTokenAfter(node);\n const isNextTokenComma = nextToken && ASTUtils.isCommaToken(nextToken);\n return [\n fixer.remove(node),\n ...(isNextTokenComma ? [fixer.remove(nextToken)] : []),\n ] as const;\n}\n\nexport function getInterfaceName(\n interfaceMember: TSESTree.Identifier | TSESTree.MemberExpression\n): string | undefined {\n if (isIdentifier(interfaceMember)) {\n return interfaceMember.name;\n }\n\n return isIdentifier(interfaceMember.property)\n ? interfaceMember.property.name\n : undefined;\n}\n\nexport function getInterfaces({\n implements: classImplements,\n}: TSESTree.ClassDeclaration): readonly (\n | TSESTree.Identifier\n | TSESTree.MemberExpression\n)[] {\n return (classImplements ?? [])\n .map(({ expression }) => expression)\n .filter(isIdentifierOrMemberExpression);\n}\n\nexport function getInterface(\n node: TSESTree.ClassDeclaration,\n interfaceName: string\n): TSESTree.Identifier | TSESTree.MemberExpression | undefined {\n return getInterfaces(node).find(\n (interfaceMember) => getInterfaceName(interfaceMember) === interfaceName\n );\n}\n\nexport function getImplementsSchemaFixer(\n { id, implements: classImplements }: TSESTree.ClassDeclaration,\n interfaceName: string\n) {\n const [implementsNodeReplace, implementsTextReplace] =\n classImplements && classImplements.length\n ? [getLast(classImplements), `, ${interfaceName}`]\n : [id as TSESTree.Identifier, ` implements ${interfaceName}`];\n\n return { implementsNodeReplace, implementsTextReplace } as const;\n}\n\nexport function getLast<T extends readonly unknown[]>(items: T): T[number] {\n return items.slice(-1)[0];\n}\n\nexport function getDecoratorName({\n expression,\n}: TSESTree.Decorator): string | undefined {\n if (isIdentifier(expression)) {\n return expression.name;\n }\n\n return isCallExpression(expression) && isIdentifier(expression.callee)\n ? expression.callee.name\n : undefined;\n}\n\nexport function getRawText(node: TSESTree.Node): string | null {\n if (isIdentifier(node)) {\n return node.name;\n }\n\n if (\n isPropertyDefinition(node) ||\n isMethodDefinition(node) ||\n isProperty(node)\n ) {\n return getRawText(node.key);\n }\n\n if (isLiteral(node)) {\n return node.raw;\n }\n\n if (isTemplateElement(node)) {\n return `\\`${node.value.raw}\\``;\n }\n\n if (isTemplateLiteral(node)) {\n return `\\`${node.quasis[0].value.raw}\\``;\n }\n\n return null;\n}\n\nexport function capitalize<T extends string>(text: T): Capitalize<T> {\n return `${text[0].toUpperCase()}${text.slice(1)}` as Capitalize<T>;\n}\n\nfunction getInjectedParametersWithSourceCode(\n context: TSESLint.RuleContext<string, readonly unknown[]>,\n moduleName: string,\n importName: string\n): InjectedParameterWithSourceCode {\n const sourceCode = context.getSourceCode();\n const importDeclarations =\n getImportDeclarations(sourceCode.ast, moduleName) ?? [];\n const { importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importName) ?? {};\n\n const injectImportDeclarations =\n getImportDeclarations(sourceCode.ast, '@angular/core') ?? [];\n\n const { importSpecifier: injectImportSpecifier } =\n getImportDeclarationSpecifier(injectImportDeclarations, 'inject') ?? {};\n\n if (!importSpecifier) {\n return { sourceCode };\n }\n\n const variables = sourceCode.getDeclaredVariables(importSpecifier);\n const typedVariable = variables.find(({ name }) => name === importName);\n const identifiers = typedVariable?.references?.reduce<\n readonly InjectedParameter[]\n >((identifiers, { identifier: { parent } }) => {\n if (!parent) {\n return identifiers;\n }\n\n if (\n isTSTypeReference(parent) &&\n parent.parent &&\n isTSTypeAnnotation(parent.parent) &&\n parent.parent.parent &&\n isIdentifier(parent.parent.parent)\n ) {\n return identifiers.concat(parent.parent.parent as InjectedParameter);\n }\n\n const parentToCheck = isTSInstantiationExpression(parent)\n ? parent.parent\n : parent;\n\n if (\n parentToCheck &&\n isCallExpression(parentToCheck) &&\n isIdentifier(parentToCheck.callee) &&\n parentToCheck.callee.name == 'inject' &&\n parentToCheck.parent &&\n isPropertyDefinition(parentToCheck.parent) &&\n isIdentifier(parentToCheck.parent.key) &&\n injectImportSpecifier\n ) {\n return identifiers.concat(parentToCheck.parent.key as InjectedParameter);\n }\n\n return identifiers;\n }, []);\n return { identifiers, sourceCode };\n}\n\nexport function getNgRxEffectActions(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.effects,\n 'Actions'\n );\n}\n\nexport function getNgRxComponentStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS['component-store'],\n 'ComponentStore'\n );\n}\n\nexport function getNgRxStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.store,\n 'Store'\n );\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nexport function escapeText(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function asPattern(identifiers: readonly InjectedParameter[]): RegExp {\n const escapedNames = identifiers.map(({ name }) => escapeText(name));\n return new RegExp(`^(${escapedNames.join('|')})$`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;AAyCA,0DAaC;AAED,sEAqBC;AAED,sDAaC;AAwBD,0CA0CC;AAED,gDA2CC;AAED,0DAWC;AAED,4CAUC;AAED,sCASC;AAED,oCAOC;AAED,4DAUC;AAED,0BAEC;AAED,4CAUC;AAED,gCA0BC;AAED,gCAEC;AAgED,oDAQC;AAED,wDAQC;AAED,sCAQC;AAGD,gCAEC;AAED,8BAGC;AAED,gEAKC;AAhaD,oDAAoD;AACpD,qCAkBkB;AAClB,iDAAmD;AAoBnD,SAAgB,uBAAuB,CACrC,EAAE,MAAM,EAAiB,EACzB,SAAiD;IAEjD,OAAO,MAAM,IAAI,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B,CAAC,OAAO,EACzB,SAAS,CACV,CAAC;AACJ,CAAC;AAED,SAAgB,sBAAsB,CACpC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,iBAAiB,CAAC,EACpC,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAC3B,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,KAAK,EACvB,OAAO,CACR,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,SAAS,CAAC,WAAyC;IACjE,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,0BAA0B,CACxC,OAAyD;IAEzD,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/utils';\nimport {\n isCallExpression,\n isIdentifier,\n isIdentifierOrMemberExpression,\n isImportDeclaration,\n isImportDefaultSpecifier,\n isImportNamespaceSpecifier,\n isImportSpecifier,\n isLiteral,\n isMethodDefinition,\n isProgram,\n isProperty,\n isPropertyDefinition,\n isTSTypeAnnotation,\n isTSTypeReference,\n isTemplateElement,\n isTemplateLiteral,\n isTSInstantiationExpression,\n} from './guards';\nimport { NGRX_MODULE_PATHS } from './ngrx-modules';\n\ntype ConstructorFunctionExpression = TSESTree.FunctionExpression & {\n parent: TSESTree.MethodDefinition & { kind: 'constructor' };\n};\ntype InjectedParameter =\n | TSESTree.Identifier & {\n typeAnnotation: TSESTree.TSTypeAnnotation;\n parent:\n | ConstructorFunctionExpression\n | (TSESTree.TSParameterProperty & {\n parent: ConstructorFunctionExpression;\n })\n | TSESTree.PropertyDefinition;\n };\ntype InjectedParameterWithSourceCode = Readonly<{\n identifiers?: readonly InjectedParameter[];\n sourceCode: Readonly<TSESLint.SourceCode>;\n}>;\n\nexport function getNearestUpperNodeFrom<T extends TSESTree.Node>(\n { parent }: TSESTree.Node,\n predicate: (parent: TSESTree.Node) => parent is T\n): T | undefined {\n while (parent && !isProgram(parent)) {\n if (predicate(parent)) {\n return parent;\n }\n\n parent = parent.parent;\n }\n\n return undefined;\n}\n\nexport function getImportDeclarationSpecifier(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importName: string\n) {\n for (const importDeclaration of importDeclarations) {\n const importSpecifier = importDeclaration.specifiers.find(\n (importClause): importClause is TSESTree.ImportSpecifier => {\n return (\n isImportSpecifier(importClause) &&\n isIdentifier(importClause.imported) &&\n importClause.imported.name === importName\n );\n }\n );\n\n if (importSpecifier) {\n return { importDeclaration, importSpecifier } as const;\n }\n }\n\n return undefined;\n}\n\nexport function getImportDeclarations(\n node: TSESTree.Node,\n moduleName: string\n): readonly TSESTree.ImportDeclaration[] | undefined {\n let parentNode: TSESTree.Node | undefined = node;\n\n while (parentNode && !isProgram(parentNode)) {\n parentNode = parentNode.parent;\n }\n\n return parentNode?.body.filter((node): node is TSESTree.ImportDeclaration => {\n return isImportDeclaration(node) && node.source.value === moduleName;\n });\n}\n\nfunction getCorrespondentImportClause(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n compatibleWithTypeOnlyImport = false\n) {\n let importClause: TSESTree.ImportClause | undefined;\n\n for (const { importKind, specifiers } of importDeclarations) {\n const lastImportSpecifier = getLast(specifiers);\n\n if (\n (!compatibleWithTypeOnlyImport && importKind === 'type') ||\n isImportNamespaceSpecifier(lastImportSpecifier)\n ) {\n continue;\n }\n\n importClause = lastImportSpecifier;\n }\n\n return importClause;\n}\n\nexport function getImportAddFix({\n compatibleWithTypeOnlyImport = false,\n fixer,\n importName,\n moduleName,\n node,\n}: {\n compatibleWithTypeOnlyImport?: boolean;\n fixer: TSESLint.RuleFixer;\n importName: string;\n moduleName: string;\n node: TSESTree.Node;\n}): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const fullImport = `import { ${importName} } from '${moduleName}';`;\n const importDeclarations = getImportDeclarations(node, moduleName);\n\n if (!importDeclarations?.length) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const importDeclarationSpecifier = getImportDeclarationSpecifier(\n importDeclarations,\n importName\n );\n\n if (importDeclarationSpecifier) {\n return [];\n }\n\n const importClause = getCorrespondentImportClause(\n importDeclarations,\n compatibleWithTypeOnlyImport\n );\n\n if (!importClause) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const replacementText = isImportDefaultSpecifier(importClause)\n ? `, { ${importName} }`\n : `, ${importName}`;\n return fixer.insertTextAfter(importClause, replacementText);\n}\n\nexport function getImportRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importedName: string,\n fixer: TSESLint.RuleFixer\n): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const { importDeclaration, importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importedName) ?? {};\n\n if (!importDeclaration || !importSpecifier) {\n return [];\n }\n\n const isFirstImportSpecifier =\n importDeclaration.specifiers[0] === importSpecifier;\n const isLastImportSpecifier =\n getLast(importDeclaration.specifiers) === importSpecifier;\n const isSingleImportSpecifier =\n isFirstImportSpecifier && isLastImportSpecifier;\n\n if (isSingleImportSpecifier) {\n return fixer.remove(importDeclaration);\n }\n\n const tokenAfterImportSpecifier = sourceCode.getTokenAfter(importSpecifier);\n\n if (isFirstImportSpecifier && tokenAfterImportSpecifier) {\n return fixer.removeRange([\n importSpecifier.range[0],\n tokenAfterImportSpecifier.range[1],\n ]);\n }\n\n const tokenBeforeImportSpecifier = sourceCode.getTokenBefore(importSpecifier);\n\n if (!tokenBeforeImportSpecifier) {\n return [];\n }\n\n return fixer.removeRange([\n tokenBeforeImportSpecifier.range[0],\n importSpecifier.range[1],\n ]);\n}\n\nexport function getNodeToCommaRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const nextToken = sourceCode.getTokenAfter(node);\n const isNextTokenComma = nextToken && ASTUtils.isCommaToken(nextToken);\n return [\n fixer.remove(node),\n ...(isNextTokenComma ? [fixer.remove(nextToken)] : []),\n ] as const;\n}\n\nexport function getInterfaceName(\n interfaceMember: TSESTree.Identifier | TSESTree.MemberExpression\n): string | undefined {\n if (isIdentifier(interfaceMember)) {\n return interfaceMember.name;\n }\n\n return isIdentifier(interfaceMember.property)\n ? interfaceMember.property.name\n : undefined;\n}\n\nexport function getInterfaces({\n implements: classImplements,\n}: TSESTree.ClassDeclaration): readonly (\n | TSESTree.Identifier\n | TSESTree.MemberExpression\n)[] {\n return (classImplements ?? [])\n .map(({ expression }) => expression)\n .filter(isIdentifierOrMemberExpression);\n}\n\nexport function getInterface(\n node: TSESTree.ClassDeclaration,\n interfaceName: string\n): TSESTree.Identifier | TSESTree.MemberExpression | undefined {\n return getInterfaces(node).find(\n (interfaceMember) => getInterfaceName(interfaceMember) === interfaceName\n );\n}\n\nexport function getImplementsSchemaFixer(\n { id, implements: classImplements }: TSESTree.ClassDeclaration,\n interfaceName: string\n) {\n const [implementsNodeReplace, implementsTextReplace] =\n classImplements && classImplements.length\n ? [getLast(classImplements), `, ${interfaceName}`]\n : [id as TSESTree.Identifier, ` implements ${interfaceName}`];\n\n return { implementsNodeReplace, implementsTextReplace } as const;\n}\n\nexport function getLast<T extends readonly unknown[]>(items: T): T[number] {\n return items.slice(-1)[0];\n}\n\nexport function getDecoratorName({\n expression,\n}: TSESTree.Decorator): string | undefined {\n if (isIdentifier(expression)) {\n return expression.name;\n }\n\n return isCallExpression(expression) && isIdentifier(expression.callee)\n ? expression.callee.name\n : undefined;\n}\n\nexport function getRawText(node: TSESTree.Node): string | null {\n if (isIdentifier(node)) {\n return node.name;\n }\n\n if (\n isPropertyDefinition(node) ||\n isMethodDefinition(node) ||\n isProperty(node)\n ) {\n return getRawText(node.key);\n }\n\n if (isLiteral(node)) {\n return node.raw;\n }\n\n if (isTemplateElement(node)) {\n return `\\`${node.value.raw}\\``;\n }\n\n if (isTemplateLiteral(node)) {\n return `\\`${node.quasis[0].value.raw}\\``;\n }\n\n return null;\n}\n\nexport function capitalize<T extends string>(text: T): Capitalize<T> {\n return `${text[0].toUpperCase()}${text.slice(1)}` as Capitalize<T>;\n}\n\nfunction getInjectedParametersWithSourceCode(\n context: TSESLint.RuleContext<string, readonly unknown[]>,\n moduleName: string,\n importName: string\n): InjectedParameterWithSourceCode {\n const sourceCode = context.sourceCode;\n const importDeclarations =\n getImportDeclarations(sourceCode.ast, moduleName) ?? [];\n const { importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importName) ?? {};\n\n const injectImportDeclarations =\n getImportDeclarations(sourceCode.ast, '@angular/core') ?? [];\n\n const { importSpecifier: injectImportSpecifier } =\n getImportDeclarationSpecifier(injectImportDeclarations, 'inject') ?? {};\n\n if (!importSpecifier) {\n return { sourceCode };\n }\n\n const variables = sourceCode.getDeclaredVariables(importSpecifier);\n const typedVariable = variables.find(({ name }) => name === importName);\n const identifiers = typedVariable?.references?.reduce<\n readonly InjectedParameter[]\n >((identifiers, { identifier: { parent } }) => {\n if (!parent) {\n return identifiers;\n }\n\n if (\n isTSTypeReference(parent) &&\n parent.parent &&\n isTSTypeAnnotation(parent.parent) &&\n parent.parent.parent &&\n isIdentifier(parent.parent.parent)\n ) {\n return identifiers.concat(parent.parent.parent as InjectedParameter);\n }\n\n const parentToCheck = isTSInstantiationExpression(parent)\n ? parent.parent\n : parent;\n\n if (\n parentToCheck &&\n isCallExpression(parentToCheck) &&\n isIdentifier(parentToCheck.callee) &&\n parentToCheck.callee.name == 'inject' &&\n parentToCheck.parent &&\n isPropertyDefinition(parentToCheck.parent) &&\n isIdentifier(parentToCheck.parent.key) &&\n injectImportSpecifier\n ) {\n return identifiers.concat(parentToCheck.parent.key as InjectedParameter);\n }\n\n return identifiers;\n }, []);\n return { identifiers, sourceCode };\n}\n\nexport function getNgRxEffectActions(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.effects,\n 'Actions'\n );\n}\n\nexport function getNgRxComponentStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS['component-store'],\n 'ComponentStore'\n );\n}\n\nexport function getNgRxStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.store,\n 'Store'\n );\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nexport function escapeText(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function asPattern(identifiers: readonly InjectedParameter[]): RegExp {\n const escapedNames = identifiers.map(({ name }) => escapeText(name));\n return new RegExp(`^(${escapedNames.join('|')})$`);\n}\n\nexport function getNgrxComponentStoreNames(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): RegExp | null {\n const { identifiers = [] } = getNgRxComponentStores(context);\n return identifiers.length > 0 ? asPattern(identifiers) : null;\n}\n"]}
|