@ngrx/eslint-plugin 18.0.2 → 18.1.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 +3 -2
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.js.map +1 -1
- package/spec/utils/from-fixture.js +1 -2
- package/spec/utils/from-fixture.js.map +1 -1
- package/spec/utils/rule-tester.js +1 -2
- package/spec/utils/rule-tester.js.map +1 -1
- package/src/configs/all.js +1 -0
- package/src/configs/all.js.map +1 -1
- package/src/configs/all.json +1 -0
- package/src/configs/signals.js +1 -0
- package/src/configs/signals.js.map +1 -1
- package/src/configs/signals.json +1 -0
- package/src/index.d.ts +3 -0
- package/src/rule-creator.js +1 -2
- package/src/rule-creator.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/signals/prefer-protected-state.d.ts +5 -0
- package/src/rules/signals/prefer-protected-state.js +88 -0
- package/src/rules/signals/prefer-protected-state.js.map +1 -0
- package/src/utils/helper-functions/folder.js +1 -2
- package/src/utils/helper-functions/folder.js.map +1 -1
- package/src/utils/helper-functions/guards.d.ts +33 -55
- package/src/utils/helper-functions/guards.js +4 -4
- package/src/utils/helper-functions/guards.js.map +1 -1
- package/src/utils/helper-functions/utils.js +19 -20
- package/src/utils/helper-functions/utils.js.map +1 -1
- package/src/utils/helper-functions/versions.js +3 -4
- package/src/utils/helper-functions/versions.js.map +1 -1
- package/src/utils/selectors/index.js +2 -2
- package/src/utils/selectors/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/eslint-plugin",
|
|
3
|
-
"version": "18.0
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"description": "NgRx ESLint Plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,5 +50,6 @@
|
|
|
50
50
|
"typescript": "*"
|
|
51
51
|
},
|
|
52
52
|
"main": "./src/index.js",
|
|
53
|
-
"type": "commonjs"
|
|
53
|
+
"type": "commonjs",
|
|
54
|
+
"types": "./src/index.d.ts"
|
|
54
55
|
}
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = addNgRxESLintPlugin;
|
|
6
7
|
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
7
8
|
function addNgRxESLintPlugin(schema) {
|
|
8
9
|
return (host, context) => {
|
|
@@ -59,5 +60,4 @@ ${detailsContent}
|
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
exports.default = addNgRxESLintPlugin;
|
|
63
63
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AAIA,sCAiEC;AApED,8EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,MAAM,IAAI,GAAG,qCAAqC,CAAC;QAEnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;wCACc,gBAAgB;;;aAG3C,IAAI;CAChB,CAAC,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AC;QACC,CAAC;IACH,CAAC,CAAC;IACF,SAAS,eAAe,CAAC,MAAwB;QAC/C,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,OAAO,EAAE,CAAC,gBAAgB,MAAM,EAAE,CAAC;SACpC,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport stripJsonComments from 'strip-json-comments';\nimport type { Schema } from './schema';\n\nexport default function addNgRxESLintPlugin(schema: Schema): Rule {\n return (host: Tree, context: SchematicContext) => {\n const eslintConfigPath = '.eslintrc.json';\n const docs = 'https://ngrx.io/guide/eslint-plugin';\n\n const eslint = host.read(eslintConfigPath)?.toString('utf-8');\n if (!eslint) {\n context.logger.warn(`\nCould not find the ESLint config at \\`${eslintConfigPath}\\`.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n`);\n return host;\n }\n\n try {\n const json = JSON.parse(stripJsonComments(eslint));\n if (json.overrides) {\n if (\n !json.overrides.some((override: any) =>\n override.extends?.some((extend: any) =>\n extend.startsWith('plugin:@ngrx')\n )\n )\n ) {\n json.overrides.push(configurePlugin(schema.config));\n }\n } else if (\n !json.extends?.some((extend: any) => extend.startsWith('plugin:@ngrx'))\n ) {\n json.overrides = [configurePlugin(schema.config)];\n }\n\n host.overwrite(eslintConfigPath, JSON.stringify(json, null, 2));\n\n context.logger.info(`\n The NgRx ESLint Plugin is installed and configured with the '${schema.config}' config.\n\n Take a look at the docs at ${docs} if you want to change the default configuration.\n `);\n return host;\n } catch (err) {\n const detailsContent =\n err instanceof Error\n ? `\nDetails:\n${err.message}\n`\n : '';\n context.logger.warn(`\nSomething went wrong while adding the NgRx ESLint Plugin.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n${detailsContent}\n`);\n }\n };\n function configurePlugin(config: Schema['config']): Record<string, unknown> {\n return {\n files: ['*.ts'],\n extends: [`plugin:@ngrx/${config}`],\n };\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fromFixture =
|
|
3
|
+
exports.fromFixture = fromFixture;
|
|
4
4
|
function fromFixture(fixture, invalidTestCase = {}) {
|
|
5
5
|
const { suggestions, ...rest } = invalidTestCase;
|
|
6
6
|
return {
|
|
@@ -8,7 +8,6 @@ function fromFixture(fixture, invalidTestCase = {}) {
|
|
|
8
8
|
...parseFixture(fixture, suggestions),
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
exports.fromFixture = fromFixture;
|
|
12
11
|
function getSuggestions(suggestions, suggest, indices) {
|
|
13
12
|
if (!suggestions || !suggest) {
|
|
14
13
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-fixture.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/from-fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"from-fixture.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/from-fixture.ts"],"names":[],"mappings":";;AAuBA,kCAiBC;AAjBD,SAAgB,WAAW,CAIzB,OAAe,EACf,kBAKI,EAAE;IAEN,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,eAAe,CAAC;IACjD,OAAO;QACL,GAAG,IAAI;QACP,GAAG,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,WAGa,EACb,OAAgB,EAChB,OAA2B;IAE3B,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,WAAW,EAAW,CAAC;IAClC,CAAC;IACD,OAAO;QACL,WAAW,EAAE,OA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CAAC,OAAO,EAAE,CAAC;gBACzB,YAAY,GAAG,IAAI,CAAC;YACtB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,WAAW,IAAI,CAAC,YAAY,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { TSESLint as eslint } from '@typescript-eslint/utils';\n\nexport function fromFixture<TMessageIds extends string>(\n fixture: string,\n invalidTestCase?: {\n output?: string;\n suggestions?: readonly eslint.SuggestionOutput<TMessageIds>[] | null;\n }\n): eslint.InvalidTestCase<TMessageIds, never>;\n\nexport function fromFixture<\n TMessageIds extends string,\n TOptions extends readonly unknown[]\n>(\n fixture: string,\n invalidTestCase: Omit<\n eslint.InvalidTestCase<TMessageIds, TOptions>,\n 'code' | 'errors'\n > & {\n suggestions?: readonly eslint.SuggestionOutput<TMessageIds>[] | null;\n }\n): eslint.InvalidTestCase<TMessageIds, TOptions>;\n\nexport function fromFixture<\n TMessageIds extends string,\n TOptions extends readonly unknown[]\n>(\n fixture: string,\n invalidTestCase: Omit<\n eslint.InvalidTestCase<TMessageIds, TOptions>,\n 'code' | 'errors'\n > & {\n suggestions?: readonly eslint.SuggestionOutput<TMessageIds>[] | null;\n } = {}\n): eslint.InvalidTestCase<TMessageIds, TOptions> {\n const { suggestions, ...rest } = invalidTestCase;\n return {\n ...rest,\n ...parseFixture(fixture, suggestions),\n };\n}\n\nfunction getSuggestions<TMessageIds extends string>(\n suggestions:\n | readonly eslint.SuggestionOutput<TMessageIds>[]\n | null\n | undefined,\n suggest: boolean,\n indices: string | undefined\n) {\n if (!suggestions || !suggest) {\n return {};\n }\n if (!indices) {\n return { suggestions } as const;\n }\n return {\n suggestions: indices\n .split(/\\s+/)\n .map((index) => suggestions[Number.parseInt(index, 10)]),\n } as const;\n}\n\nfunction parseFixture<TMessageIds extends string>(\n fixture: string,\n suggestions?: readonly eslint.SuggestionOutput<TMessageIds>[] | null\n) {\n const errorRegExp =\n /^(?<indent>\\s*)(?<error>~+)\\s*\\[(?<id>\\w+)\\s*(?<data>.*?)(?:\\s*(?<suggest>suggest)\\s*(?<indices>[\\d\\s]*))?\\]\\s*$/;\n const lines: string[] = [];\n const errors: eslint.TestCaseError<TMessageIds>[] = [];\n let suggestFound = false;\n fixture.split('\\n').forEach((line) => {\n const match = line.match(errorRegExp);\n if (match?.groups) {\n const column = match.groups.indent.length + 1;\n const endColumn = column + match.groups.error.length;\n const { length } = lines;\n errors.push({\n column,\n data: JSON.parse(match.groups.data || '{}'),\n endColumn,\n endLine: length,\n line: length,\n messageId: match.groups.id as TMessageIds,\n // TODO: Remove type assertion once https://github.com/typescript-eslint/typescript-eslint/pull/3844 is available.\n ...(getSuggestions(\n suggestions,\n Boolean(match.groups.suggest),\n match.groups.indices?.trim()\n ) as eslint.TestCaseError<TMessageIds>['suggestions']),\n });\n if (match.groups.suggest) {\n suggestFound = true;\n }\n } else {\n lines.push(line);\n }\n });\n if (suggestions && !suggestFound) {\n throw new Error(\"Suggestions specified but no 'suggest' annotation found.\");\n }\n return {\n code: lines.join('\\n'),\n errors,\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ruleTester =
|
|
3
|
+
exports.ruleTester = ruleTester;
|
|
4
4
|
const utils_1 = require("../../src/utils");
|
|
5
5
|
const test_utils_1 = require("@angular-eslint/test-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -19,5 +19,4 @@ function ruleTester(environment) {
|
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
exports.ruleTester = ruleTester;
|
|
23
22
|
//# sourceMappingURL=rule-tester.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-tester.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/rule-tester.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-tester.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/rule-tester.ts"],"names":[],"mappings":";;AAIA,gCAmBC;AAvBD,2CAA6D;AAC7D,2DAAwD;AACxD,+BAA+B;AAE/B,SAAgB,UAAU,CAAC,WAG1B;IACC,IAAA,kBAAU,GAAE,CAAC;IAEb,IAAI,WAAW,EAAE,CAAC;QAChB,IAAA,sBAAc,EAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,uBAAU,CAAC;QACpB,MAAM,EAAE,2BAA2B;QACnC,aAAa,EAAE;YACb,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,IAAA,cAAO,EAAC,uCAAuC,CAAC;YACjE,OAAO,EAAE,iBAAiB;SAC3B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { clearCache, setNgrxVersion } from '../../src/utils';\nimport { RuleTester } from '@angular-eslint/test-utils';\nimport { resolve } from 'path';\n\nexport function ruleTester(environment?: {\n ngrxModule: string;\n version: string;\n}) {\n clearCache();\n\n if (environment) {\n setNgrxVersion(environment.ngrxModule, environment.version);\n }\n\n return new RuleTester({\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n tsconfigRootDir: resolve('./modules/eslint-plugin/spec/fixtures'),\n project: './tsconfig.json',\n },\n });\n}\n"]}
|
package/src/configs/all.js
CHANGED
|
@@ -39,6 +39,7 @@ exports.default = (plugin, parser) => [
|
|
|
39
39
|
'@ngrx/prefer-concat-latest-from': 'error',
|
|
40
40
|
'@ngrx/signal-state-no-arrays-at-root-level': 'error',
|
|
41
41
|
'@ngrx/signal-store-feature-should-use-generic-type': 'error',
|
|
42
|
+
'@ngrx/prefer-protected-state': 'error',
|
|
42
43
|
'@ngrx/with-state-no-arrays-at-root-level': 'error',
|
|
43
44
|
'@ngrx/avoid-combining-selectors': 'error',
|
|
44
45
|
'@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,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/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/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"]}
|
|
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,4CAA4C,EAAE,OAAO;YACrD,oDAAoD,EAAE,OAAO;YAC7D,8BAA8B,EAAE,OAAO;YACvC,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/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/signal-state-no-arrays-at-root-level': 'error',\n '@ngrx/signal-store-feature-should-use-generic-type': 'error',\n '@ngrx/prefer-protected-state': '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
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"@ngrx/prefer-concat-latest-from": "error",
|
|
16
16
|
"@ngrx/signal-state-no-arrays-at-root-level": "error",
|
|
17
17
|
"@ngrx/signal-store-feature-should-use-generic-type": "error",
|
|
18
|
+
"@ngrx/prefer-protected-state": "error",
|
|
18
19
|
"@ngrx/with-state-no-arrays-at-root-level": "error",
|
|
19
20
|
"@ngrx/avoid-combining-selectors": "error",
|
|
20
21
|
"@ngrx/avoid-dispatching-multiple-actions-sequentially": "error",
|
package/src/configs/signals.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.default = (plugin, parser) => [
|
|
|
28
28
|
rules: {
|
|
29
29
|
'@ngrx/signal-state-no-arrays-at-root-level': 'error',
|
|
30
30
|
'@ngrx/signal-store-feature-should-use-generic-type': 'error',
|
|
31
|
+
'@ngrx/prefer-protected-state': 'error',
|
|
31
32
|
'@ngrx/with-state-no-arrays-at-root-level': 'error',
|
|
32
33
|
},
|
|
33
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,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/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"]}
|
|
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,4CAA4C,EAAE,OAAO;YACrD,oDAAoD,EAAE,OAAO;YAC7D,8BAA8B,EAAE,OAAO;YACvC,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/signal-state-no-arrays-at-root-level': 'error',\n '@ngrx/signal-store-feature-should-use-generic-type': 'error',\n '@ngrx/prefer-protected-state': 'error',\n '@ngrx/with-state-no-arrays-at-root-level': 'error',\n },\n },\n];\n"]}
|
package/src/configs/signals.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const _default: {
|
|
|
17
17
|
"@ngrx/prefer-concat-latest-from": string;
|
|
18
18
|
"@ngrx/signal-state-no-arrays-at-root-level": string;
|
|
19
19
|
"@ngrx/signal-store-feature-should-use-generic-type": string;
|
|
20
|
+
"@ngrx/prefer-protected-state": string;
|
|
20
21
|
"@ngrx/with-state-no-arrays-at-root-level": string;
|
|
21
22
|
"@ngrx/avoid-combining-selectors": string;
|
|
22
23
|
"@ngrx/avoid-dispatching-multiple-actions-sequentially": string;
|
|
@@ -107,6 +108,7 @@ declare const _default: {
|
|
|
107
108
|
rules: {
|
|
108
109
|
"@ngrx/signal-state-no-arrays-at-root-level": string;
|
|
109
110
|
"@ngrx/signal-store-feature-should-use-generic-type": string;
|
|
111
|
+
"@ngrx/prefer-protected-state": string;
|
|
110
112
|
"@ngrx/with-state-no-arrays-at-root-level": string;
|
|
111
113
|
};
|
|
112
114
|
parserOptions: {
|
|
@@ -150,6 +152,7 @@ declare const _default: {
|
|
|
150
152
|
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
151
153
|
'signal-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
152
154
|
'signal-store-feature-should-use-generic-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStoreFeatureShouldUseGenericType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
155
|
+
'prefer-protected-state': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferProtectedState" | "preferProtectedStateSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
153
156
|
'with-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"withStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
154
157
|
};
|
|
155
158
|
};
|
package/src/rule-creator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRule =
|
|
3
|
+
exports.createRule = createRule;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
5
|
const utils_2 = require("./utils");
|
|
6
6
|
function createRule(config) {
|
|
@@ -20,5 +20,4 @@ function createRule(config) {
|
|
|
20
20
|
}
|
|
21
21
|
return utils_1.ESLintUtils.RuleCreator(utils_2.docsUrl)(configOverwrite);
|
|
22
22
|
}
|
|
23
|
-
exports.createRule = createRule;
|
|
24
23
|
//# sourceMappingURL=rule-creator.js.map
|
package/src/rule-creator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":";;AA2BA,gCAyCC;AAnED,oDAAuD;AAEvD,mCAA2E;AAwB3E,SAAgB,UAAU,CAIxB,MAQE;IAEF,MAAM,eAAe,GAAG;QACtB,GAAG,MAAM;QACT,MAAM,EAAE,CACN,OAA8D,EAC9D,kBAAsC,EACtC,EAAE;YACF,MAAM,EACJ,IAAI,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAC9B,GAAG,MAAM,CAAC;YACX,IACE,OAAO,KAAK,SAAS;gBACrB,CAAC,IAAA,4BAAoB,EAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,EAC7D,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1E,eAAe,CAAC,IAAI,CAAC,QAAgB,CAAC,GAAG,CAAC,GAAG,GAAG,OAAO,KAAK,IAAA,eAAO,EAClE,MAAM,CAAC,IAAI,CACZ,GAAG,CAAC;IACP,CAAC;IAED,OAAO,mBAAW,CAAC,WAAW,CAAC,eAAO,CAAC,CAAC,eAAe,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\nimport { ESLintUtils } from '@typescript-eslint/utils';\nimport type { NGRX_MODULE } from './utils';\nimport { docsUrl, ngrxVersionSatisfies, NGRX_MODULE_PATHS } from './utils';\n\ntype Meta<TMessageIds extends string, TOptions extends readonly unknown[]> =\n | TSESLint.RuleMetaData<TMessageIds, TOptions> & {\n ngrxModule: NGRX_MODULE;\n version?: string;\n docs: { requiresTypeChecking?: boolean };\n };\n\ntype CreateRuleMeta<\n TMessageIds extends string,\n TOptions extends readonly unknown[]\n> = {\n docs: Omit<TSESLint.RuleMetaDataDocs, 'url'> & {\n requiresTypeChecking?: boolean;\n };\n} & Omit<Meta<TMessageIds, TOptions>, 'docs'>;\nexport type NgRxRuleModule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n> = Omit<TSESLint.RuleModule<TMessageIds, TOptions>, 'meta'> & {\n meta: Meta<TMessageIds, TOptions>;\n};\n\nexport function createRule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n>(\n config: Readonly<{\n name: string;\n meta: CreateRuleMeta<TMessageIds, TOptions>;\n defaultOptions: Readonly<TOptions>;\n create: (\n context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>,\n optionsWithDefault: Readonly<TOptions>\n ) => TSESLint.RuleListener;\n }>\n): TSESLint.RuleModule<TMessageIds, TOptions> {\n const configOverwrite = {\n ...config,\n create: (\n context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>,\n optionsWithDefault: Readonly<TOptions>\n ) => {\n const {\n meta: { ngrxModule, version },\n } = config;\n if (\n version !== undefined &&\n !ngrxVersionSatisfies(NGRX_MODULE_PATHS[ngrxModule], version)\n ) {\n return {};\n }\n\n return config.create(context, optionsWithDefault);\n },\n };\n\n for (const [key, message] of Object.entries(configOverwrite.meta.messages)) {\n (configOverwrite.meta.messages as any)[key] = `${message} (${docsUrl(\n config.name\n )})`;\n }\n\n return ESLintUtils.RuleCreator(docsUrl)(configOverwrite);\n}\n"]}
|
package/src/rules/index.d.ts
CHANGED
|
@@ -32,5 +32,6 @@ export declare const rules: {
|
|
|
32
32
|
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
33
33
|
'signal-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
34
34
|
'signal-store-feature-should-use-generic-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStoreFeatureShouldUseGenericType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
35
|
+
'prefer-protected-state': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferProtectedState" | "preferProtectedStateSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
35
36
|
'with-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"withStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
36
37
|
};
|
package/src/rules/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const prefer_concat_latest_from_1 = __importDefault(require("./operators/prefer-
|
|
|
41
41
|
const signal_state_no_arrays_at_root_level_1 = __importDefault(require("./signals/signal-state-no-arrays-at-root-level"));
|
|
42
42
|
const signal_store_feature_should_use_generic_type_1 = __importDefault(require("./signals/signal-store-feature-should-use-generic-type"));
|
|
43
43
|
const with_state_no_arrays_at_root_level_1 = __importDefault(require("./signals/with-state-no-arrays-at-root-level"));
|
|
44
|
+
const prefer_protected_state_1 = __importDefault(require("./signals/prefer-protected-state"));
|
|
44
45
|
exports.rules = {
|
|
45
46
|
// component-store
|
|
46
47
|
'avoid-combining-component-store-selectors': avoid_combining_component_store_selectors_1.default,
|
|
@@ -78,6 +79,7 @@ exports.rules = {
|
|
|
78
79
|
// signals
|
|
79
80
|
'signal-state-no-arrays-at-root-level': signal_state_no_arrays_at_root_level_1.default,
|
|
80
81
|
'signal-store-feature-should-use-generic-type': signal_store_feature_should_use_generic_type_1.default,
|
|
82
|
+
'prefer-protected-state': prefer_protected_state_1.default,
|
|
81
83
|
'with-state-no-arrays-at-root-level': with_state_no_arrays_at_root_level_1.default,
|
|
82
84
|
};
|
|
83
85
|
//# sourceMappingURL=index.js.map
|
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,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;
|
|
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,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,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';\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"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const preferProtectedState = "preferProtectedState";
|
|
2
|
+
export declare const preferProtectedStateSuggest = "preferProtectedStateSuggest";
|
|
3
|
+
type MessageIds = typeof preferProtectedState | typeof preferProtectedStateSuggest;
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.preferProtectedStateSuggest = exports.preferProtectedState = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
exports.preferProtectedState = 'preferProtectedState';
|
|
30
|
+
exports.preferProtectedStateSuggest = 'preferProtectedStateSuggest';
|
|
31
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
32
|
+
name: path.parse(__filename).name,
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'suggestion',
|
|
35
|
+
hasSuggestions: true,
|
|
36
|
+
ngrxModule: 'signals',
|
|
37
|
+
docs: {
|
|
38
|
+
description: `A Signal Store prefers protected state`,
|
|
39
|
+
},
|
|
40
|
+
schema: [],
|
|
41
|
+
messages: {
|
|
42
|
+
[exports.preferProtectedState]: '{ protectedState: false } should be removed to prevent external state mutations.',
|
|
43
|
+
[exports.preferProtectedStateSuggest]: 'Remove `{protectedState: false}`.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
defaultOptions: [],
|
|
47
|
+
create: (context) => {
|
|
48
|
+
return {
|
|
49
|
+
[`CallExpression[callee.name=signalStore][arguments.length>0] > ObjectExpression[properties.length>0] > Property[key.name=protectedState][value.value=false]`](node) {
|
|
50
|
+
context.report({
|
|
51
|
+
node,
|
|
52
|
+
messageId: exports.preferProtectedState,
|
|
53
|
+
suggest: [
|
|
54
|
+
{
|
|
55
|
+
messageId: exports.preferProtectedStateSuggest,
|
|
56
|
+
fix: (fixer) => {
|
|
57
|
+
const getRangeToBeRemoved = () => {
|
|
58
|
+
const parentObject = node.parent;
|
|
59
|
+
const parentObjectHasOnlyOneProperty = parentObject.properties.length === 1;
|
|
60
|
+
if (parentObjectHasOnlyOneProperty) {
|
|
61
|
+
/**
|
|
62
|
+
* Remove the entire object if it contains only one property - the relevant one
|
|
63
|
+
*/
|
|
64
|
+
return parentObject.range;
|
|
65
|
+
}
|
|
66
|
+
const tokenAfter = context.sourceCode.getTokenAfter(node);
|
|
67
|
+
const tokenAfterIsComma = tokenAfter?.value?.trim() === ',';
|
|
68
|
+
/**
|
|
69
|
+
* Remove the specific property if there is more than one property in the parent
|
|
70
|
+
*/
|
|
71
|
+
return [
|
|
72
|
+
node.range[0],
|
|
73
|
+
/**
|
|
74
|
+
* remove trailing comma as well
|
|
75
|
+
*/
|
|
76
|
+
tokenAfterIsComma ? tokenAfter.range[1] : node.range[1],
|
|
77
|
+
];
|
|
78
|
+
};
|
|
79
|
+
return fixer.removeRange(getRangeToBeRemoved());
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=prefer-protected-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-protected-state.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/signals/prefer-prot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AAE,KAAK,GAAG,CAAC;oCAC5D;;uCAEG;oCACH,OAAO;wCACL,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;wCACb;;2CAEG;wCACH,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;qCACxD,CAAC;gCACJ,CAAC,CAAC;gCAEF,OAAO,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,CAAC;4BAClD,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 preferProtectedState = 'preferProtectedState';\nexport const preferProtectedStateSuggest = 'preferProtectedStateSuggest';\n\ntype MessageIds =\n | typeof preferProtectedState\n | typeof preferProtectedStateSuggest;\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: 'signals',\n docs: {\n description: `A Signal Store prefers protected state`,\n },\n schema: [],\n messages: {\n [preferProtectedState]:\n '{ protectedState: false } should be removed to prevent external state mutations.',\n [preferProtectedStateSuggest]: 'Remove `{protectedState: false}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`CallExpression[callee.name=signalStore][arguments.length>0] > ObjectExpression[properties.length>0] > Property[key.name=protectedState][value.value=false]`](\n node: TSESTree.Property\n ) {\n context.report({\n node,\n messageId: preferProtectedState,\n suggest: [\n {\n messageId: preferProtectedStateSuggest,\n fix: (fixer) => {\n const getRangeToBeRemoved = (): Parameters<\n typeof fixer.removeRange\n >[0] => {\n const parentObject = node.parent as TSESTree.ObjectExpression;\n const parentObjectHasOnlyOneProperty =\n parentObject.properties.length === 1;\n\n if (parentObjectHasOnlyOneProperty) {\n /**\n * Remove the entire object if it contains only one property - the relevant one\n */\n return parentObject.range;\n }\n\n const tokenAfter = context.sourceCode.getTokenAfter(node);\n const tokenAfterIsComma = tokenAfter?.value?.trim() === ',';\n /**\n * Remove the specific property if there is more than one property in the parent\n */\n return [\n node.range[0],\n /**\n * remove trailing comma as well\n */\n tokenAfterIsComma ? tokenAfter.range[1] : node.range[1],\n ];\n };\n\n return fixer.removeRange(getRangeToBeRemoved());\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.traverseFolder =
|
|
26
|
+
exports.traverseFolder = traverseFolder;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
function* traverseFolder(folder, extensions) {
|
|
@@ -42,5 +42,4 @@ function* traverseFolder(folder, extensions) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
exports.traverseFolder = traverseFolder;
|
|
46
45
|
//# sourceMappingURL=folder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/folder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/folder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCAiBC;AApBD,uCAAyB;AACzB,2CAA6B;AAE7B,QAAe,CAAC,CAAC,cAAc,CAC7B,MAAc,EACd,UAAoB;IAEpB,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9B,KAAK,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YACxD,MAAM;gBACJ,MAAM;gBACN,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI;gBACvC,IAAI,EAAE,SAAS;aAChB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nexport function* traverseFolder(\n folder: string,\n extensions: string[]\n): Generator<{ folder: string; file: string; path: string }> {\n const folders = fs.readdirSync(folder, { withFileTypes: true });\n for (const folderEntry of folders) {\n const entryPath = path.resolve(folder, folderEntry.name);\n if (folderEntry.isDirectory()) {\n yield* traverseFolder(entryPath, extensions);\n } else if (extensions.includes(path.extname(entryPath))) {\n yield {\n folder,\n file: path.parse(folderEntry.name).name,\n path: entryPath,\n };\n }\n }\n}\n"]}
|
|
@@ -1,103 +1,81 @@
|
|
|
1
1
|
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
export declare const isArrowFunctionExpression: (node: TSESTree.Node) => node is TSESTree.
|
|
3
|
+
export declare const isArrowFunctionExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
4
4
|
type: TSESTree.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
5
5
|
};
|
|
6
|
-
export declare const isReturnStatement: (node: TSESTree.Node) => node is TSESTree.
|
|
6
|
+
export declare const isReturnStatement: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
7
7
|
type: TSESTree.AST_NODE_TYPES.ReturnStatement;
|
|
8
8
|
};
|
|
9
|
-
export declare const isMethodDefinition: (node: TSESTree.Node) => node is
|
|
9
|
+
export declare const isMethodDefinition: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
10
10
|
type: TSESTree.AST_NODE_TYPES.MethodDefinition;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
export declare const isCallExpression: (node: TSESTree.Node) => node is TSESTree.CallExpression & {
|
|
11
|
+
};
|
|
12
|
+
export declare const isCallExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
15
13
|
type: TSESTree.AST_NODE_TYPES.CallExpression;
|
|
16
14
|
};
|
|
17
|
-
export declare const isClassDeclaration: (node: TSESTree.Node) => node is
|
|
18
|
-
type: TSESTree.AST_NODE_TYPES.ClassDeclaration;
|
|
19
|
-
}) | (TSESTree.ClassDeclarationWithOptionalName & {
|
|
15
|
+
export declare const isClassDeclaration: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
20
16
|
type: TSESTree.AST_NODE_TYPES.ClassDeclaration;
|
|
21
|
-
}
|
|
22
|
-
export declare const isPropertyDefinition: (node: TSESTree.Node) => node is
|
|
23
|
-
type: TSESTree.AST_NODE_TYPES.PropertyDefinition;
|
|
24
|
-
}) | (TSESTree.PropertyDefinitionNonComputedName & {
|
|
17
|
+
};
|
|
18
|
+
export declare const isPropertyDefinition: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
25
19
|
type: TSESTree.AST_NODE_TYPES.PropertyDefinition;
|
|
26
|
-
}
|
|
27
|
-
export declare const isFunctionExpression: (node: TSESTree.Node) => node is TSESTree.
|
|
20
|
+
};
|
|
21
|
+
export declare const isFunctionExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
28
22
|
type: TSESTree.AST_NODE_TYPES.FunctionExpression;
|
|
29
23
|
};
|
|
30
|
-
export declare const isFunctionDeclaration: (node: TSESTree.Node) => node is
|
|
31
|
-
type: TSESTree.AST_NODE_TYPES.FunctionDeclaration;
|
|
32
|
-
}) | (TSESTree.FunctionDeclarationWithOptionalName & {
|
|
24
|
+
export declare const isFunctionDeclaration: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
33
25
|
type: TSESTree.AST_NODE_TYPES.FunctionDeclaration;
|
|
34
|
-
}
|
|
35
|
-
export declare const isIdentifier: (node: TSESTree.Node) => node is TSESTree.
|
|
26
|
+
};
|
|
27
|
+
export declare const isIdentifier: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
36
28
|
type: TSESTree.AST_NODE_TYPES.Identifier;
|
|
37
29
|
};
|
|
38
|
-
export declare const isImportDeclaration: (node: TSESTree.Node) => node is TSESTree.
|
|
30
|
+
export declare const isImportDeclaration: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
39
31
|
type: TSESTree.AST_NODE_TYPES.ImportDeclaration;
|
|
40
32
|
};
|
|
41
|
-
export declare const isImportDefaultSpecifier: (node: TSESTree.Node) => node is TSESTree.
|
|
33
|
+
export declare const isImportDefaultSpecifier: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
42
34
|
type: TSESTree.AST_NODE_TYPES.ImportDefaultSpecifier;
|
|
43
35
|
};
|
|
44
|
-
export declare const isImportNamespaceSpecifier: (node: TSESTree.Node) => node is TSESTree.
|
|
36
|
+
export declare const isImportNamespaceSpecifier: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
45
37
|
type: TSESTree.AST_NODE_TYPES.ImportNamespaceSpecifier;
|
|
46
38
|
};
|
|
47
|
-
export declare const isImportSpecifier: (node: TSESTree.Node) => node is TSESTree.
|
|
39
|
+
export declare const isImportSpecifier: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
48
40
|
type: TSESTree.AST_NODE_TYPES.ImportSpecifier;
|
|
49
41
|
};
|
|
50
|
-
export declare const isLiteral: (node: TSESTree.Node) => node is
|
|
51
|
-
type: TSESTree.AST_NODE_TYPES.Literal;
|
|
52
|
-
}) | (TSESTree.BooleanLiteral & {
|
|
42
|
+
export declare const isLiteral: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
53
43
|
type: TSESTree.AST_NODE_TYPES.Literal;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}) | (TSESTree.NumberLiteral & {
|
|
57
|
-
type: TSESTree.AST_NODE_TYPES.Literal;
|
|
58
|
-
}) | (TSESTree.RegExpLiteral & {
|
|
59
|
-
type: TSESTree.AST_NODE_TYPES.Literal;
|
|
60
|
-
}) | (TSESTree.StringLiteral & {
|
|
61
|
-
type: TSESTree.AST_NODE_TYPES.Literal;
|
|
62
|
-
});
|
|
63
|
-
export declare const isTemplateElement: (node: TSESTree.Node) => node is TSESTree.TemplateElement & {
|
|
44
|
+
};
|
|
45
|
+
export declare const isTemplateElement: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
64
46
|
type: TSESTree.AST_NODE_TYPES.TemplateElement;
|
|
65
47
|
};
|
|
66
|
-
export declare const isTemplateLiteral: (node: TSESTree.Node) => node is TSESTree.
|
|
48
|
+
export declare const isTemplateLiteral: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
67
49
|
type: TSESTree.AST_NODE_TYPES.TemplateLiteral;
|
|
68
50
|
};
|
|
69
|
-
export declare const isMemberExpression: (node: TSESTree.Node) => node is
|
|
51
|
+
export declare const isMemberExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
70
52
|
type: TSESTree.AST_NODE_TYPES.MemberExpression;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
export declare const isProgram: (node: TSESTree.Node) => node is TSESTree.Program & {
|
|
53
|
+
};
|
|
54
|
+
export declare const isProgram: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
75
55
|
type: TSESTree.AST_NODE_TYPES.Program;
|
|
76
56
|
};
|
|
77
|
-
export declare const isThisExpression: (node: TSESTree.Node) => node is TSESTree.
|
|
57
|
+
export declare const isThisExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
78
58
|
type: TSESTree.AST_NODE_TYPES.ThisExpression;
|
|
79
59
|
};
|
|
80
|
-
export declare const isTSParameterProperty: (node: TSESTree.Node) => node is TSESTree.
|
|
60
|
+
export declare const isTSParameterProperty: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
81
61
|
type: TSESTree.AST_NODE_TYPES.TSParameterProperty;
|
|
82
62
|
};
|
|
83
|
-
export declare const isTSTypeAnnotation: (node: TSESTree.Node) => node is TSESTree.
|
|
63
|
+
export declare const isTSTypeAnnotation: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
84
64
|
type: TSESTree.AST_NODE_TYPES.TSTypeAnnotation;
|
|
85
65
|
};
|
|
86
|
-
export declare const isTSTypeReference: (node: TSESTree.Node) => node is TSESTree.
|
|
66
|
+
export declare const isTSTypeReference: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
87
67
|
type: TSESTree.AST_NODE_TYPES.TSTypeReference;
|
|
88
68
|
};
|
|
89
|
-
export declare const isTSInstantiationExpression: (node: TSESTree.Node) => node is TSESTree.
|
|
69
|
+
export declare const isTSInstantiationExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
90
70
|
type: TSESTree.AST_NODE_TYPES.TSInstantiationExpression;
|
|
91
71
|
};
|
|
92
|
-
export declare const isProperty: (node: TSESTree.Node) => node is
|
|
72
|
+
export declare const isProperty: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
93
73
|
type: TSESTree.AST_NODE_TYPES.Property;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
export declare const isArrayExpression: (node: TSESTree.Node) => node is TSESTree.ArrayExpression & {
|
|
74
|
+
};
|
|
75
|
+
export declare const isArrayExpression: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
98
76
|
type: TSESTree.AST_NODE_TYPES.ArrayExpression;
|
|
99
77
|
};
|
|
100
|
-
export declare const isBlockStatement: (node: TSESTree.Node) => node is TSESTree.
|
|
78
|
+
export declare const isBlockStatement: (node: TSESTree.Node) => node is TSESTree.Node & {
|
|
101
79
|
type: TSESTree.AST_NODE_TYPES.BlockStatement;
|
|
102
80
|
};
|
|
103
81
|
export declare function isIdentifierOrMemberExpression(node: TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isBlockStatement = exports.isArrayExpression = exports.isProperty = exports.isTSInstantiationExpression = exports.isTSTypeReference = exports.isTSTypeAnnotation = exports.isTSParameterProperty = exports.isThisExpression = exports.isProgram = exports.isMemberExpression = exports.isTemplateLiteral = exports.isTemplateElement = exports.isLiteral = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isIdentifier = exports.isFunctionDeclaration = exports.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
4
|
+
exports.isIdentifierOrMemberExpression = isIdentifierOrMemberExpression;
|
|
5
|
+
exports.isTypeReference = isTypeReference;
|
|
6
|
+
exports.isCallExpressionWith = isCallExpressionWith;
|
|
4
7
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
8
|
const isNodeOfType = (nodeType) => (node) => node.type === nodeType;
|
|
6
9
|
exports.isArrowFunctionExpression = isNodeOfType(utils_1.AST_NODE_TYPES.ArrowFunctionExpression);
|
|
@@ -32,11 +35,9 @@ exports.isBlockStatement = isNodeOfType(utils_1.AST_NODE_TYPES.BlockStatement);
|
|
|
32
35
|
function isIdentifierOrMemberExpression(node) {
|
|
33
36
|
return (0, exports.isIdentifier)(node) || (0, exports.isMemberExpression)(node);
|
|
34
37
|
}
|
|
35
|
-
exports.isIdentifierOrMemberExpression = isIdentifierOrMemberExpression;
|
|
36
38
|
function isTypeReference(type) {
|
|
37
39
|
return type.hasOwnProperty('target');
|
|
38
40
|
}
|
|
39
|
-
exports.isTypeReference = isTypeReference;
|
|
40
41
|
function equalTo(one, other) {
|
|
41
42
|
return typeof one === 'string' ? one === other : one.test(other);
|
|
42
43
|
}
|
|
@@ -51,5 +52,4 @@ function isCallExpressionWith(node, objectName, propertyName) {
|
|
|
51
52
|
(0, exports.isIdentifier)(node.callee.object.property) &&
|
|
52
53
|
equalTo(objectName, node.callee.object.property.name))));
|
|
53
54
|
}
|
|
54
|
-
exports.isCallExpressionWith = isCallExpressionWith;
|
|
55
55
|
//# sourceMappingURL=guards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AAqDA,wEAIC;AAED,0CAEC;AAMD,oDAgBC;AAlFD,oDAA0D;AAG1D,MAAM,YAAY,GAChB,CAAkC,QAAkB,EAAE,EAAE,CACxD,CAAC,IAAmB,EAA8C,EAAE,CAClE,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAEd,QAAA,yBAAyB,GAAG,YAAY,CACnD,sBAAc,CAAC,uBAAuB,CACvC,CAAC;AACW,QAAA,iBAAiB,GAAG,YAAY,CAAC,sBAAc,CAAC,eAAe,CAAC,CAAC;AACjE,QAAA,kBAAkB,GAAG,YAAY,CAAC,sBAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,gBAAgB,GAAG,YAAY,CAAC,sBAAc,CAAC,cAAc,CAAC,CAAC;AAC/D,QAAA,kBAAkB,GAAG,YAAY,CAAC,sBAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,oBAAoB,GAAG,YAAY,CAC9C,sBAAc,CAAC,kBAAkB,CACl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CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\nimport type * as ts from 'typescript';\n\nconst isNodeOfType =\n <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) =>\n (node: TSESTree.Node): node is TSESTree.Node & { type: NodeType } =>\n node.type === nodeType;\n\nexport const isArrowFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.ArrowFunctionExpression\n);\nexport const isReturnStatement = isNodeOfType(AST_NODE_TYPES.ReturnStatement);\nexport const isMethodDefinition = isNodeOfType(AST_NODE_TYPES.MethodDefinition);\nexport const isCallExpression = isNodeOfType(AST_NODE_TYPES.CallExpression);\nexport const isClassDeclaration = isNodeOfType(AST_NODE_TYPES.ClassDeclaration);\nexport const isPropertyDefinition = isNodeOfType(\n AST_NODE_TYPES.PropertyDefinition\n);\nexport const isFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.FunctionExpression\n);\nexport const isFunctionDeclaration = isNodeOfType(\n AST_NODE_TYPES.FunctionDeclaration\n);\nexport const isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);\nexport const isImportDeclaration = isNodeOfType(\n AST_NODE_TYPES.ImportDeclaration\n);\nexport const isImportDefaultSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportDefaultSpecifier\n);\nexport const isImportNamespaceSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportNamespaceSpecifier\n);\nexport const isImportSpecifier = isNodeOfType(AST_NODE_TYPES.ImportSpecifier);\nexport const isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);\nexport const isTemplateElement = isNodeOfType(AST_NODE_TYPES.TemplateElement);\nexport const isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);\nexport const isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);\nexport const isProgram = isNodeOfType(AST_NODE_TYPES.Program);\nexport const isThisExpression = isNodeOfType(AST_NODE_TYPES.ThisExpression);\nexport const isTSParameterProperty = isNodeOfType(\n AST_NODE_TYPES.TSParameterProperty\n);\nexport const isTSTypeAnnotation = isNodeOfType(AST_NODE_TYPES.TSTypeAnnotation);\nexport const isTSTypeReference = isNodeOfType(AST_NODE_TYPES.TSTypeReference);\nexport const isTSInstantiationExpression = isNodeOfType(\n AST_NODE_TYPES.TSInstantiationExpression\n);\nexport const isProperty = isNodeOfType(AST_NODE_TYPES.Property);\nexport const isArrayExpression = isNodeOfType(AST_NODE_TYPES.ArrayExpression);\nexport const isBlockStatement = isNodeOfType(AST_NODE_TYPES.BlockStatement);\nexport function isIdentifierOrMemberExpression(\n node: TSESTree.Node\n): node is TSESTree.Identifier | TSESTree.MemberExpression {\n return isIdentifier(node) || isMemberExpression(node);\n}\n\nexport function isTypeReference(type: ts.Type): type is ts.TypeReference {\n return type.hasOwnProperty('target');\n}\n\nfunction equalTo(one: RegExp | string, other: string) {\n return typeof one === 'string' ? one === other : one.test(other);\n}\n\nexport function isCallExpressionWith(\n node: TSESTree.CallExpression,\n objectName: RegExp | string,\n propertyName: string\n) {\n return (\n isMemberExpression(node.callee) &&\n !node.callee.computed &&\n node.callee.property.name === propertyName &&\n ((isIdentifier(node.callee.object) &&\n equalTo(objectName, node.callee.object.name)) ||\n (isMemberExpression(node.callee.object) &&\n isThisExpression(node.callee.object.object) &&\n isIdentifier(node.callee.object.property) &&\n equalTo(objectName, node.callee.object.property.name)))\n );\n}\n"]}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getNearestUpperNodeFrom = getNearestUpperNodeFrom;
|
|
4
|
+
exports.getImportDeclarationSpecifier = getImportDeclarationSpecifier;
|
|
5
|
+
exports.getImportDeclarations = getImportDeclarations;
|
|
6
|
+
exports.getImportAddFix = getImportAddFix;
|
|
7
|
+
exports.getImportRemoveFix = getImportRemoveFix;
|
|
8
|
+
exports.getNodeToCommaRemoveFix = getNodeToCommaRemoveFix;
|
|
9
|
+
exports.getInterfaceName = getInterfaceName;
|
|
10
|
+
exports.getInterfaces = getInterfaces;
|
|
11
|
+
exports.getInterface = getInterface;
|
|
12
|
+
exports.getImplementsSchemaFixer = getImplementsSchemaFixer;
|
|
13
|
+
exports.getLast = getLast;
|
|
14
|
+
exports.getDecoratorName = getDecoratorName;
|
|
15
|
+
exports.getRawText = getRawText;
|
|
16
|
+
exports.capitalize = capitalize;
|
|
17
|
+
exports.getNgRxEffectActions = getNgRxEffectActions;
|
|
18
|
+
exports.getNgRxComponentStores = getNgRxComponentStores;
|
|
19
|
+
exports.getNgRxStores = getNgRxStores;
|
|
20
|
+
exports.escapeText = escapeText;
|
|
21
|
+
exports.asPattern = asPattern;
|
|
4
22
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
23
|
const guards_1 = require("./guards");
|
|
6
24
|
const ngrx_modules_1 = require("./ngrx-modules");
|
|
@@ -13,7 +31,6 @@ function getNearestUpperNodeFrom({ parent }, predicate) {
|
|
|
13
31
|
}
|
|
14
32
|
return undefined;
|
|
15
33
|
}
|
|
16
|
-
exports.getNearestUpperNodeFrom = getNearestUpperNodeFrom;
|
|
17
34
|
function getImportDeclarationSpecifier(importDeclarations, importName) {
|
|
18
35
|
for (const importDeclaration of importDeclarations) {
|
|
19
36
|
const importSpecifier = importDeclaration.specifiers.find((importClause) => {
|
|
@@ -26,7 +43,6 @@ function getImportDeclarationSpecifier(importDeclarations, importName) {
|
|
|
26
43
|
}
|
|
27
44
|
return undefined;
|
|
28
45
|
}
|
|
29
|
-
exports.getImportDeclarationSpecifier = getImportDeclarationSpecifier;
|
|
30
46
|
function getImportDeclarations(node, moduleName) {
|
|
31
47
|
let parentNode = node;
|
|
32
48
|
while (parentNode && !(0, guards_1.isProgram)(parentNode)) {
|
|
@@ -36,7 +52,6 @@ function getImportDeclarations(node, moduleName) {
|
|
|
36
52
|
return (0, guards_1.isImportDeclaration)(node) && node.source.value === moduleName;
|
|
37
53
|
});
|
|
38
54
|
}
|
|
39
|
-
exports.getImportDeclarations = getImportDeclarations;
|
|
40
55
|
function getCorrespondentImportClause(importDeclarations, compatibleWithTypeOnlyImport = false) {
|
|
41
56
|
let importClause;
|
|
42
57
|
for (const { importKind, specifiers } of importDeclarations) {
|
|
@@ -68,7 +83,6 @@ function getImportAddFix({ compatibleWithTypeOnlyImport = false, fixer, importNa
|
|
|
68
83
|
: `, ${importName}`;
|
|
69
84
|
return fixer.insertTextAfter(importClause, replacementText);
|
|
70
85
|
}
|
|
71
|
-
exports.getImportAddFix = getImportAddFix;
|
|
72
86
|
function getImportRemoveFix(sourceCode, importDeclarations, importedName, fixer) {
|
|
73
87
|
const { importDeclaration, importSpecifier } = getImportDeclarationSpecifier(importDeclarations, importedName) ?? {};
|
|
74
88
|
if (!importDeclaration || !importSpecifier) {
|
|
@@ -96,7 +110,6 @@ function getImportRemoveFix(sourceCode, importDeclarations, importedName, fixer)
|
|
|
96
110
|
importSpecifier.range[1],
|
|
97
111
|
]);
|
|
98
112
|
}
|
|
99
|
-
exports.getImportRemoveFix = getImportRemoveFix;
|
|
100
113
|
function getNodeToCommaRemoveFix(sourceCode, fixer, node) {
|
|
101
114
|
const nextToken = sourceCode.getTokenAfter(node);
|
|
102
115
|
const isNextTokenComma = nextToken && utils_1.ASTUtils.isCommaToken(nextToken);
|
|
@@ -105,7 +118,6 @@ function getNodeToCommaRemoveFix(sourceCode, fixer, node) {
|
|
|
105
118
|
...(isNextTokenComma ? [fixer.remove(nextToken)] : []),
|
|
106
119
|
];
|
|
107
120
|
}
|
|
108
|
-
exports.getNodeToCommaRemoveFix = getNodeToCommaRemoveFix;
|
|
109
121
|
function getInterfaceName(interfaceMember) {
|
|
110
122
|
if ((0, guards_1.isIdentifier)(interfaceMember)) {
|
|
111
123
|
return interfaceMember.name;
|
|
@@ -114,28 +126,23 @@ function getInterfaceName(interfaceMember) {
|
|
|
114
126
|
? interfaceMember.property.name
|
|
115
127
|
: undefined;
|
|
116
128
|
}
|
|
117
|
-
exports.getInterfaceName = getInterfaceName;
|
|
118
129
|
function getInterfaces({ implements: classImplements, }) {
|
|
119
130
|
return (classImplements ?? [])
|
|
120
131
|
.map(({ expression }) => expression)
|
|
121
132
|
.filter(guards_1.isIdentifierOrMemberExpression);
|
|
122
133
|
}
|
|
123
|
-
exports.getInterfaces = getInterfaces;
|
|
124
134
|
function getInterface(node, interfaceName) {
|
|
125
135
|
return getInterfaces(node).find((interfaceMember) => getInterfaceName(interfaceMember) === interfaceName);
|
|
126
136
|
}
|
|
127
|
-
exports.getInterface = getInterface;
|
|
128
137
|
function getImplementsSchemaFixer({ id, implements: classImplements }, interfaceName) {
|
|
129
138
|
const [implementsNodeReplace, implementsTextReplace] = classImplements && classImplements.length
|
|
130
139
|
? [getLast(classImplements), `, ${interfaceName}`]
|
|
131
140
|
: [id, ` implements ${interfaceName}`];
|
|
132
141
|
return { implementsNodeReplace, implementsTextReplace };
|
|
133
142
|
}
|
|
134
|
-
exports.getImplementsSchemaFixer = getImplementsSchemaFixer;
|
|
135
143
|
function getLast(items) {
|
|
136
144
|
return items.slice(-1)[0];
|
|
137
145
|
}
|
|
138
|
-
exports.getLast = getLast;
|
|
139
146
|
function getDecoratorName({ expression, }) {
|
|
140
147
|
if ((0, guards_1.isIdentifier)(expression)) {
|
|
141
148
|
return expression.name;
|
|
@@ -144,7 +151,6 @@ function getDecoratorName({ expression, }) {
|
|
|
144
151
|
? expression.callee.name
|
|
145
152
|
: undefined;
|
|
146
153
|
}
|
|
147
|
-
exports.getDecoratorName = getDecoratorName;
|
|
148
154
|
function getRawText(node) {
|
|
149
155
|
if ((0, guards_1.isIdentifier)(node)) {
|
|
150
156
|
return node.name;
|
|
@@ -165,11 +171,9 @@ function getRawText(node) {
|
|
|
165
171
|
}
|
|
166
172
|
return null;
|
|
167
173
|
}
|
|
168
|
-
exports.getRawText = getRawText;
|
|
169
174
|
function capitalize(text) {
|
|
170
175
|
return `${text[0].toUpperCase()}${text.slice(1)}`;
|
|
171
176
|
}
|
|
172
|
-
exports.capitalize = capitalize;
|
|
173
177
|
function getInjectedParametersWithSourceCode(context, moduleName, importName) {
|
|
174
178
|
const sourceCode = context.getSourceCode();
|
|
175
179
|
const importDeclarations = getImportDeclarations(sourceCode.ast, moduleName) ?? [];
|
|
@@ -212,23 +216,18 @@ function getInjectedParametersWithSourceCode(context, moduleName, importName) {
|
|
|
212
216
|
function getNgRxEffectActions(context) {
|
|
213
217
|
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS.effects, 'Actions');
|
|
214
218
|
}
|
|
215
|
-
exports.getNgRxEffectActions = getNgRxEffectActions;
|
|
216
219
|
function getNgRxComponentStores(context) {
|
|
217
220
|
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS['component-store'], 'ComponentStore');
|
|
218
221
|
}
|
|
219
|
-
exports.getNgRxComponentStores = getNgRxComponentStores;
|
|
220
222
|
function getNgRxStores(context) {
|
|
221
223
|
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS.store, 'Store');
|
|
222
224
|
}
|
|
223
|
-
exports.getNgRxStores = getNgRxStores;
|
|
224
225
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
|
225
226
|
function escapeText(text) {
|
|
226
227
|
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
227
228
|
}
|
|
228
|
-
exports.escapeText = escapeText;
|
|
229
229
|
function asPattern(identifiers) {
|
|
230
230
|
const escapedNames = identifiers.map(({ name }) => escapeText(name));
|
|
231
231
|
return new RegExp(`^(${escapedNames.join('|')})$`);
|
|
232
232
|
}
|
|
233
|
-
exports.asPattern = asPattern;
|
|
234
233
|
//# 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":";;;AACA,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,CAAC,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAbD,0DAaC;AAED,SAAgB,6BAA6B,CAC3C,kBAAyD,EACzD,UAAkB;IAElB,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;QACnD,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CACvD,CAAC,YAAY,EAA4C,EAAE;YACzD,OAAO,CACL,IAAA,0BAAiB,EAAC,YAAY,CAAC;gBAC/B,YAAY,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAC1C,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAW,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AApBD,sEAoBC;AAED,SAAgB,qBAAqB,CACnC,IAAmB,EACnB,UAAkB;IAElB,IAAI,UAAU,GAA8B,IAAI,CAAC;IAEjD,OAAO,UAAU,IAAI,CAAC,IAAA,kBAAS,EAAC,UAAU,CAAC,EAAE,CAAC;QAC5C,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,OAAO,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,I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,CAAC,MAAM,CAAC;YAC1C,IAAA,qBAAY,EAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC;YACtC,qBAAqB,EACrB,CAAC;YACD,OAAO,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAwB,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACrC,CAAC;AAED,SAAgB,oBAAoB,CAClC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,OAAO,EACzB,SAAS,CACV,CAAC;AACJ,CAAC;AARD,oDAQC;AAED,SAAgB,sBAAsB,CACpC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,iBAAiB,CAAC,EACpC,gBAAgB,CACjB,CAAC;AACJ,CAAC;AARD,wDAQC;AAED,SAAgB,aAAa,CAC3B,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,KAAK,EACvB,OAAO,CACR,CAAC;AACJ,CAAC;AARD,sCAQC;AAED,6FAA6F;AAC7F,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAFD,gCAEC;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;AAHD,8BAGC","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 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,sEAoBC;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;AAxZD,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,CAAC,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,6BAA6B,CAC3C,kBAAyD,EACzD,UAAkB;IAElB,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;QACnD,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CACvD,CAAC,YAAY,EAA4C,EAAE;YACzD,OAAO,CACL,IAAA,0BAAiB,EAAC,YAAY,CAAC;gBAC/B,YAAY,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAC1C,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAW,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,qBAAqB,CACnC,IAAmB,EACnB,UAAkB;I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;YACrC,aAAa,CAAC,MAAM;YACpB,IAAA,6BAAoB,EAAC,aAAa,CAAC,MAAM,CAAC;YAC1C,IAAA,qBAAY,EAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC;YACtC,qBAAqB,EACrB,CAAC;YACD,OAAO,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAwB,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACrC,CAAC;AAED,SAAgB,oBAAoB,CAClC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,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","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 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"]}
|
|
@@ -23,7 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.setNgrxVersion = setNgrxVersion;
|
|
27
|
+
exports.clearCache = clearCache;
|
|
28
|
+
exports.ngrxVersionSatisfies = ngrxVersionSatisfies;
|
|
27
29
|
const semver = __importStar(require("semver"));
|
|
28
30
|
const noopVersion = '0.0.0';
|
|
29
31
|
const versionsCache = new Map();
|
|
@@ -49,13 +51,11 @@ function readPlatformVersion(pkg) {
|
|
|
49
51
|
function setNgrxVersion(pkg, version) {
|
|
50
52
|
versionsCache.set(pkg, version);
|
|
51
53
|
}
|
|
52
|
-
exports.setNgrxVersion = setNgrxVersion;
|
|
53
54
|
// @internal for testing purposes
|
|
54
55
|
function clearCache() {
|
|
55
56
|
versionsCache.clear();
|
|
56
57
|
satisfiesCache.clear();
|
|
57
58
|
}
|
|
58
|
-
exports.clearCache = clearCache;
|
|
59
59
|
function versionSatisfies(pkg, version) {
|
|
60
60
|
if (!satisfiesCache.has(pkg)) {
|
|
61
61
|
satisfiesCache.set(pkg, semver.satisfies(getNgrxVersion(pkg), version));
|
|
@@ -65,5 +65,4 @@ function versionSatisfies(pkg, version) {
|
|
|
65
65
|
function ngrxVersionSatisfies(pkg, version) {
|
|
66
66
|
return versionSatisfies(pkg, version);
|
|
67
67
|
}
|
|
68
|
-
exports.ngrxVersionSatisfies = ngrxVersionSatisfies;
|
|
69
68
|
//# sourceMappingURL=versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/versions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/versions.ts"],"names":[],"mappings":";;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Ac,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAY,CAAC;AAC5C,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAW,EAAE,OAAe;IAC/D,OAAO,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import * as semver from 'semver';\n\nconst noopVersion = '0.0.0';\nconst versionsCache = new Map<string, string>();\nconst satisfiesCache = new Map<string, boolean>();\n\nfunction getNgrxVersion(pkg: string): string {\n if (!versionsCache.has(pkg)) {\n const version = readPlatformVersion(pkg);\n versionsCache.set(pkg, version ?? noopVersion);\n }\n\n return versionsCache.get(pkg) as string;\n}\n\nfunction readPlatformVersion(pkg: string) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports\n const ngrxVersion = require(`${pkg}/package.json`) as {\n version?: string;\n };\n return ngrxVersion.version?.replace(/[^\\d.]/g, '');\n } catch {\n return null;\n }\n}\n\n// @internal for testing purposes\nexport function setNgrxVersion(pkg: string, version: string): void {\n versionsCache.set(pkg, version);\n}\n\n// @internal for testing purposes\nexport function clearCache() {\n versionsCache.clear();\n satisfiesCache.clear();\n}\n\nfunction versionSatisfies(pkg: string, version: string) {\n if (!satisfiesCache.has(pkg)) {\n satisfiesCache.set(pkg, semver.satisfies(getNgrxVersion(pkg), version));\n }\n\n return satisfiesCache.get(pkg) as boolean;\n}\n\nexport function ngrxVersionSatisfies(pkg: string, version: string): boolean {\n return versionSatisfies(pkg, version);\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapLikeOperatorCallExpressions = exports.actionReducerMap = exports.storeActionReducerMap = exports.onFunctionWithoutType = exports.createReducer = exports.dispatchInEffects = exports.dispatchExpression = exports.selectExpression = exports.pipeableSelect = exports.pipeExpression = exports.namedCallableExpression = exports.namedExpression = exports.effectsInNgModuleProviders = exports.effectsInNgModuleImports = exports.ngModuleProviders = exports.ngModuleImports = exports.ngModuleDecorator = exports.
|
|
3
|
+
exports.mapLikeOperatorCallExpressions = exports.actionReducerMap = exports.storeActionReducerMap = exports.onFunctionWithoutType = exports.createReducer = exports.dispatchInEffects = exports.dispatchExpression = exports.selectExpression = exports.pipeableSelect = exports.pipeExpression = exports.namedCallableExpression = exports.namedExpression = exports.effectsInNgModuleProviders = exports.effectsInNgModuleImports = exports.ngModuleProviders = exports.ngModuleImports = exports.ngModuleDecorator = exports.constructorDefinition = exports.actionCreatorPropsComputed = exports.actionCreatorProps = exports.actionCreatorWithLiteral = exports.actionCreator = exports.propertyDefinitionWithEffectDecorator = exports.effectDecorator = exports.createEffectExpression = exports.effectCreator = void 0;
|
|
4
|
+
exports.metadataProperty = metadataProperty;
|
|
4
5
|
exports.effectCreator = `PropertyDefinition[value.callee.name='createEffect']`;
|
|
5
6
|
exports.createEffectExpression = `CallExpression[callee.name='createEffect']`;
|
|
6
7
|
exports.effectDecorator = `Decorator[expression.callee.name='Effect']`;
|
|
@@ -13,7 +14,6 @@ exports.constructorDefinition = `MethodDefinition[kind='constructor']`;
|
|
|
13
14
|
function metadataProperty(key) {
|
|
14
15
|
return `Property:matches([key.name=${key}][computed=false], [key.value=${key}], [key.quasis.0.value.raw=${key}])`;
|
|
15
16
|
}
|
|
16
|
-
exports.metadataProperty = metadataProperty;
|
|
17
17
|
exports.ngModuleDecorator = `ClassDeclaration > Decorator > CallExpression[callee.name='NgModule']`;
|
|
18
18
|
exports.ngModuleImports = `${exports.ngModuleDecorator} ObjectExpression ${metadataProperty('imports')} > ArrayExpression`;
|
|
19
19
|
exports.ngModuleProviders = `${exports.ngModuleDecorator} ObjectExpression ${metadataProperty('providers')} > ArrayExpression`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/selectors/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/selectors/index.ts"],"names":[],"mappings":";;;AAqBA,4CAEC;AAvBY,QAAA,aAAa,GAAG,sDAAsD,CAAC;AACvE,QAAA,sBAAsB,GAAG,4CAA4C,CAAC;AAEtE,QAAA,eAAe,GAAG,4CAA4C,CAAC;AAC/D,QAAA,qCAAqC,GAChD,uDAAuD,uBAAe,EAAW,CAAC;AAEvE,QAAA,aAAa,GAAG,4CAA4C,CAAC;AAC7D,QAAA,wBAAwB,GACnC,GAAG,qBAAa,oDAA6D,CAAC;AACnE,QAAA,kBAAkB,GAC7B,GAAG,qBAAa,wCAAiD,CAAC;AACvD,QAAA,0BAA0B,GACrC,GAAG,0BAAkB,yHAAkI,CAAC;AAE7I,QAAA,qBAAqB,GAAG,sCAAsC,CAAC;AAM5E,SAAgB,gBAAgB,CAAC,GAAoB;IACnD,OAAO,8BAA8B,GAAG,iCAAiC,GAAG,8BAA8B,GAAG,IAAI,CAAC;AACpH,CAAC;AAEY,QAAA,iBAAiB,GAAG,uEAAuE,CAAC;AAE5F,QAAA,eAAe,GAC1B,GAAG,yBAAiB,qBAAqB,gBAAgB,CACvD,SAAS,CACV,oBAA6B,CAAC;AAEpB,QAAA,iBAAiB,GAC5B,GAAG,yBAAiB,qBAAqB,gBAAgB,CACvD,WAAW,CACZ,oBAA6B,CAAC;AAEpB,QAAA,wBAAwB,GACnC,GAAG,uBAAe,8HAAuI,CAAC;AAE/I,QAAA,0BAA0B,GACrC,GAAG,yBAAiB,aAAsB,CAAC;AAEtC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAE,EAAE,CACvD,YAAY,6BAAqB,sCAAsC,IAAI,6FAA6F,IAAI,IAAa,CAAC;AAD/K,QAAA,eAAe,mBACgK;AAErL,MAAM,uBAAuB,GAAG,CAAC,IAAqB,EAAE,EAAE,CAC/D,YA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']`;\nexport const createEffectExpression = `CallExpression[callee.name='createEffect']`;\n\nexport const effectDecorator = `Decorator[expression.callee.name='Effect']`;\nexport const propertyDefinitionWithEffectDecorator =\n `ClassDeclaration > ClassBody > PropertyDefinition > ${effectDecorator}` as const;\n\nexport const actionCreator = `CallExpression[callee.name='createAction']`;\nexport const actionCreatorWithLiteral =\n `${actionCreator}[arguments.0.type='Literal'][arguments.0.raw=/^'/]` as const;\nexport const actionCreatorProps =\n `${actionCreator} > CallExpression[callee.name='props']` as const;\nexport const actionCreatorPropsComputed =\n `${actionCreatorProps} > TSTypeParameterInstantiation > :matches(TSTypeReference[typeName.name!='Readonly'], [type=/^TS(.*)(Keyword|Type)$/])` as const;\n\nexport const constructorDefinition = `MethodDefinition[kind='constructor']`;\n\nexport function metadataProperty(key: RegExp): string;\nexport function metadataProperty<TKey extends string>(\n key: TKey\n): `Property:matches([key.name=${TKey}][computed=false], [key.value=${TKey}], [key.quasis.0.value.raw=${TKey}])`;\nexport function metadataProperty(key: RegExp | string): string {\n return `Property:matches([key.name=${key}][computed=false], [key.value=${key}], [key.quasis.0.value.raw=${key}])`;\n}\n\nexport const ngModuleDecorator = `ClassDeclaration > Decorator > CallExpression[callee.name='NgModule']`;\n\nexport const ngModuleImports =\n `${ngModuleDecorator} ObjectExpression ${metadataProperty(\n 'imports'\n )} > ArrayExpression` as const;\n\nexport const ngModuleProviders =\n `${ngModuleDecorator} ObjectExpression ${metadataProperty(\n 'providers'\n )} > ArrayExpression` as const;\n\nexport const effectsInNgModuleImports =\n `${ngModuleImports} CallExpression[callee.object.name='EffectsModule'][callee.property.name=/^for(Root|Feature)$/] ArrayExpression > Identifier` as const;\n\nexport const effectsInNgModuleProviders =\n `${ngModuleProviders} Identifier` as const;\n\nexport const namedExpression = (name: RegExp | string) =>\n `:matches(${constructorDefinition} CallExpression[callee.object.name=${name}], CallExpression[callee.object.object.type='ThisExpression'][callee.object.property.name=${name}])` as const;\n\nexport const namedCallableExpression = (name: RegExp | string) =>\n `:matches(${namedExpression(\n name\n )}, ${constructorDefinition} CallExpression[callee.object.callee.object.name=${name}], CallExpression[callee.object.callee.object.object.type='ThisExpression'][callee.object.callee.object.property.name=${name}])` as const;\n\nexport const pipeExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='pipe']` as const;\n\nexport const pipeableSelect = (name: RegExp | string) =>\n `${pipeExpression(name)} CallExpression[callee.name='select']` as const;\n\nexport const selectExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='select']` as const;\n\nexport const dispatchExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='dispatch']` as const;\n\nexport const dispatchInEffects = (name: RegExp | string) =>\n `${createEffectExpression} ${dispatchExpression(\n name\n )} > MemberExpression:has(Identifier[name=${name}])` as const;\n\nexport const createReducer = `CallExpression[callee.name='createReducer']`;\n\nexport const onFunctionWithoutType =\n `${createReducer} CallExpression[callee.name='on'] > ArrowFunctionExpression:not([returnType.typeAnnotation], :has(CallExpression))` as const;\n\nexport const storeActionReducerMap =\n `${ngModuleImports} CallExpression[callee.object.name='StoreModule'][callee.property.name=/^for(Root|Feature)$/] > ObjectExpression:first-child` as const;\n\nexport const actionReducerMap = `VariableDeclarator[id.typeAnnotation.typeAnnotation.typeName.name='ActionReducerMap'] > ObjectExpression`;\n\nconst mapLikeOperators = '/^(concat|exhaust|flat|merge|switch)Map$/';\nconst mapLikeToOperators = '/^(concat|merge|switch)MapTo$/';\nexport const mapLikeOperatorCallExpressions =\n `:matches(CallExpression[callee.name=${mapLikeToOperators}], CallExpression[callee.name=${mapLikeOperators}] > :matches(ReturnStatement,ArrowFunctionExpression,FunctionExpression))` as const;\n"]}
|