@ngrx/eslint-plugin 18.0.0-rc.1 → 18.0.1
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 +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.js +10 -3
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/utils/helper-functions/guards.d.ts +3 -0
- package/src/utils/helper-functions/guards.js +2 -1
- package/src/utils/helper-functions/guards.js.map +1 -1
- package/src/utils/selectors/index.d.ts +1 -2
- package/src/utils/selectors/index.js +2 -3
- package/src/utils/selectors/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
46
46
|
defaultOptions: [],
|
|
47
47
|
create: (context) => {
|
|
48
48
|
return {
|
|
49
|
-
[`${utils_2.createEffectExpression}
|
|
49
|
+
[`${utils_2.createEffectExpression} ${utils_2.mapLikeOperatorCallExpressions}`](node) {
|
|
50
50
|
const nodeToReport = getNodeToReport(node);
|
|
51
51
|
if (!nodeToReport) {
|
|
52
52
|
return;
|
|
@@ -74,11 +74,18 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
74
74
|
function getNodeToReport(node) {
|
|
75
75
|
switch (node.type) {
|
|
76
76
|
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
77
|
-
|
|
77
|
+
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
|
78
|
+
return (0, utils_2.isBlockStatement)(node.body)
|
|
79
|
+
? findReturnStatement(node.body.body)
|
|
80
|
+
: node.body;
|
|
78
81
|
case utils_1.AST_NODE_TYPES.CallExpression:
|
|
79
|
-
return node.arguments[0];
|
|
82
|
+
return findReturnStatement(node.arguments) ?? node.arguments[0];
|
|
80
83
|
default:
|
|
81
84
|
return node.argument;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
function findReturnStatement(nodes) {
|
|
88
|
+
const returnNode = nodes.find((n) => (0, utils_2.isReturnStatement)(n));
|
|
89
|
+
return returnNode?.argument;
|
|
90
|
+
}
|
|
84
91
|
//# sourceMappingURL=no-multiple-actions-in-effects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-multiple-actions-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-multiple-actions-in-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAIkC;AAClC,2CAA6B;AAC7B,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"no-multiple-actions-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-multiple-actions-in-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAIkC;AAClC,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,SAAS,GAAG,4BAA4B,CAAC;AAUtD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;YAC3D,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,yCAAyC;SACvD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,GAAG,8BAAsB,IAAI,sCAA8B,EAAE,CAAC,CAC7D,IAAmC;gBAEnC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,OAAO;gBACT,CAAC;gBAED,MAAM,QAAQ,GAAG,mBAAW,CAAC,iBAAiB,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,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAiC,EAAE,CACjE,IAAA,yBAAiB,EAAC,CAAC,CAAC,CACrB,CAAC;IACF,OAAO,UAAU,EAAE,QAAQ,CAAC;AAC9B,CAAC","sourcesContent":["import {\n AST_NODE_TYPES,\n ESLintUtils,\n type TSESTree,\n} from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n createEffectExpression,\n isBlockStatement,\n isReturnStatement,\n mapLikeOperatorCallExpressions,\n} from '../../utils';\n\nexport const messageId = 'noMultipleActionsInEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly unknown[];\ntype EffectsMapLikeOperatorsReturn =\n | TSESTree.ArrowFunctionExpression\n | TSESTree.CallExpression\n | TSESTree.FunctionExpression\n | TSESTree.ReturnStatement;\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description: '`Effect` should not return multiple actions.',\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: '`Effect` should return a single action.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`${createEffectExpression} ${mapLikeOperatorCallExpressions}`](\n node: EffectsMapLikeOperatorsReturn\n ) {\n const nodeToReport = getNodeToReport(node);\n if (!nodeToReport) {\n return;\n }\n\n const services = ESLintUtils.getParserServices(context);\n const typeChecker = services.program.getTypeChecker();\n const type = services.getTypeAtLocation(nodeToReport);\n\n if (typeChecker.isArrayType(type)) {\n context.report({\n node: nodeToReport,\n messageId,\n });\n } else if (\n type.isUnion() &&\n type.types.some((ut) => !typeChecker.isArrayType(ut))\n ) {\n context.report({\n node: nodeToReport,\n messageId,\n });\n }\n },\n };\n },\n});\n\nfunction getNodeToReport(node: EffectsMapLikeOperatorsReturn) {\n switch (node.type) {\n case AST_NODE_TYPES.ArrowFunctionExpression:\n case AST_NODE_TYPES.FunctionExpression:\n return isBlockStatement(node.body)\n ? findReturnStatement(node.body.body)\n : node.body;\n case AST_NODE_TYPES.CallExpression:\n return findReturnStatement(node.arguments) ?? node.arguments[0];\n default:\n return node.argument;\n }\n}\n\nfunction findReturnStatement(nodes: TSESTree.Node[]) {\n const returnNode = nodes.find((n): n is TSESTree.ReturnStatement =>\n isReturnStatement(n)\n );\n return returnNode?.argument;\n}\n"]}
|
|
@@ -92,6 +92,9 @@ export declare const isProperty: (node: TSESTree.Node) => node is (TSESTree.Prop
|
|
|
92
92
|
export declare const isArrayExpression: (node: TSESTree.Node) => node is TSESTree.ArrayExpression & {
|
|
93
93
|
type: TSESTree.AST_NODE_TYPES.ArrayExpression;
|
|
94
94
|
};
|
|
95
|
+
export declare const isBlockStatement: (node: TSESTree.Node) => node is TSESTree.BlockStatement & {
|
|
96
|
+
type: TSESTree.AST_NODE_TYPES.BlockStatement;
|
|
97
|
+
};
|
|
95
98
|
export declare function isIdentifierOrMemberExpression(node: TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
96
99
|
export declare function isTypeReference(type: ts.Type): type is ts.TypeReference;
|
|
97
100
|
export declare function isCallExpressionWith(node: TSESTree.CallExpression, objectName: RegExp | string, propertyName: string): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCallExpressionWith = exports.isTypeReference = exports.isIdentifierOrMemberExpression = 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.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
3
|
+
exports.isCallExpressionWith = exports.isTypeReference = exports.isIdentifierOrMemberExpression = 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.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
5
|
const isNodeOfType = (nodeType) => (node) => node.type === nodeType;
|
|
6
6
|
exports.isArrowFunctionExpression = isNodeOfType(utils_1.AST_NODE_TYPES.ArrowFunctionExpression);
|
|
@@ -27,6 +27,7 @@ exports.isTSTypeReference = isNodeOfType(utils_1.AST_NODE_TYPES.TSTypeReference)
|
|
|
27
27
|
exports.isTSInstantiationExpression = isNodeOfType(utils_1.AST_NODE_TYPES.TSInstantiationExpression);
|
|
28
28
|
exports.isProperty = isNodeOfType(utils_1.AST_NODE_TYPES.Property);
|
|
29
29
|
exports.isArrayExpression = isNodeOfType(utils_1.AST_NODE_TYPES.ArrayExpression);
|
|
30
|
+
exports.isBlockStatement = isNodeOfType(utils_1.AST_NODE_TYPES.BlockStatement);
|
|
30
31
|
function isIdentifierOrMemberExpression(node) {
|
|
31
32
|
return (0, exports.isIdentifier)(node) || (0, exports.isMemberExpression)(node);
|
|
32
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AACA,oDAA0D;AAG1D,MAAM,YAAY,GAChB,CAAkC,QAAk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,SAAS,GAAG,YAAY,CAAC,sBAAc,CAAC,OAAO,CAAC,CAAC;AACjD,QAAA,gBAAgB,GAAG,YAAY,CAAC,sBAAc,CAAC,cAAc,CAAC,CAAC;AAC/D,QAAA,qBAAqB,GAAG,YAAY,CAC/C,sBAAc,CAAC,mBAAmB,CACnC,CAAC;AACW,QAAA,kBAAkB,GAAG,YAAY,CAAC,sBAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,iBAAiB,GAAG,YAAY,CAAC,sBAAc,CAAC,eAAe,CAAC,CAAC;AACjE,QAAA,2BAA2B,GAAG,YAAY,CACrD,sBAAc,CAAC,yBAAyB,CACzC,CAAC;AACW,QAAA,UAAU,GAAG,YAAY,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAA,iBAAiB,GAAG,YAAY,CAAC,sBAAc,CAAC,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AACA,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,CAClC,CAAC;AACW,Q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,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC;AAhBD,oDAgBC","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 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"]}
|
|
@@ -25,5 +25,4 @@ export declare const createReducer = "CallExpression[callee.name='createReducer'
|
|
|
25
25
|
export declare const onFunctionWithoutType: "CallExpression[callee.name='createReducer'] CallExpression[callee.name='on'] > ArrowFunctionExpression:not([returnType.typeAnnotation], :has(CallExpression))";
|
|
26
26
|
export declare const storeActionReducerMap: "ClassDeclaration > Decorator > CallExpression[callee.name='NgModule'] ObjectExpression Property:matches([key.name=imports][computed=false], [key.value=imports], [key.quasis.0.value.raw=imports]) > ArrayExpression CallExpression[callee.object.name='StoreModule'][callee.property.name=/^for(Root|Feature)$/] > ObjectExpression:first-child";
|
|
27
27
|
export declare const actionReducerMap = "VariableDeclarator[id.typeAnnotation.typeAnnotation.typeName.name='ActionReducerMap'] > ObjectExpression";
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const mapLikeOperatorsImplicitReturn: ":matches(CallExpression[callee.name=/^(concat|merge|switch)MapTo$/], CallExpression[callee.name=/^(concat|exhaust|flat|merge|switch)Map$/] > ArrowFunctionExpression)";
|
|
28
|
+
export declare const mapLikeOperatorCallExpressions: ":matches(CallExpression[callee.name=/^(concat|merge|switch)MapTo$/], CallExpression[callee.name=/^(concat|exhaust|flat|merge|switch)Map$/] > :matches(ReturnStatement,ArrowFunctionExpression,FunctionExpression))";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.metadataProperty = exports.constructorDefinition = exports.actionCreatorPropsComputed = exports.actionCreatorProps = exports.actionCreatorWithLiteral = exports.actionCreator = exports.propertyDefinitionWithEffectDecorator = exports.effectDecorator = exports.createEffectExpression = exports.effectCreator = void 0;
|
|
4
4
|
exports.effectCreator = `PropertyDefinition[value.callee.name='createEffect']`;
|
|
5
5
|
exports.createEffectExpression = `CallExpression[callee.name='createEffect']`;
|
|
6
6
|
exports.effectDecorator = `Decorator[expression.callee.name='Effect']`;
|
|
@@ -39,6 +39,5 @@ exports.storeActionReducerMap = `${exports.ngModuleImports} CallExpression[calle
|
|
|
39
39
|
exports.actionReducerMap = `VariableDeclarator[id.typeAnnotation.typeAnnotation.typeName.name='ActionReducerMap'] > ObjectExpression`;
|
|
40
40
|
const mapLikeOperators = '/^(concat|exhaust|flat|merge|switch)Map$/';
|
|
41
41
|
const mapLikeToOperators = '/^(concat|merge|switch)MapTo$/';
|
|
42
|
-
exports.
|
|
43
|
-
exports.mapLikeOperatorsImplicitReturn = `:matches(CallExpression[callee.name=${mapLikeToOperators}], CallExpression[callee.name=${mapLikeOperators}] > ArrowFunctionExpression)`;
|
|
42
|
+
exports.mapLikeOperatorCallExpressions = `:matches(CallExpression[callee.name=${mapLikeToOperators}], CallExpression[callee.name=${mapLikeOperators}] > :matches(ReturnStatement,ArrowFunctionExpression,FunctionExpression))`;
|
|
44
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/selectors/index.ts"],"names":[],"mappings":";;;AAAa,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;AAFD,4CAEC;AAEY,QAAA,iBAAiB,GAAG,uEAAuE,CAAC;AAE5F,QAAA,eAAe,GAC1B,GAAG,yBAAiB,qBAAqB,gBAAgB,CACvD,SA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AAqB,GAChC,GAAG,uBAAe,8HAAuI,CAAC;AAE/I,QAAA,gBAAgB,GAAG,0GAA0G,CAAC;AAE3I,MAAM,gBAAgB,GAAG,2CAA2C,CAAC;AACrE,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAC/C,QAAA,8BAA8B,GACzC,uCAAuC,kBAAkB,iCAAiC,gBAAgB,2EAAoF,CAAC","sourcesContent":["export const effectCreator = `PropertyDefinition[value.callee.name='createEffect']`;\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"]}
|