@ngrx/eslint-plugin 17.1.1 → 18.0.0-beta.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.
Files changed (32) hide show
  1. package/package.json +4 -1
  2. package/schematics/ng-add/index.js.map +1 -1
  3. package/scripts/generate-docs.js.map +1 -1
  4. package/spec/utils/index.js +1 -1
  5. package/spec/utils/index.js.map +1 -1
  6. package/src/rule-creator.js.map +1 -1
  7. package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
  8. package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
  9. package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
  10. package/src/rules/effects/no-effects-in-providers.js.map +1 -1
  11. package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
  12. package/src/rules/effects/prefer-concat-latest-from.js.map +1 -1
  13. package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
  14. package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
  15. package/src/rules/store/avoid-combining-selectors.js.map +1 -1
  16. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
  17. package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
  18. package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
  19. package/src/rules/store/good-action-hygiene.js.map +1 -1
  20. package/src/rules/store/no-multiple-global-stores.js.map +1 -1
  21. package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
  22. package/src/rules/store/no-store-subscription.js.map +1 -1
  23. package/src/rules/store/no-typed-global-store.js.map +1 -1
  24. package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
  25. package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
  26. package/src/rules/store/prefer-selector-in-select.js.map +1 -1
  27. package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
  28. package/src/rules/store/select-style.js.map +1 -1
  29. package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
  30. package/src/utils/helper-functions/utils.js +1 -1
  31. package/src/utils/helper-functions/utils.js.map +1 -1
  32. package/src/utils/helper-functions/versions.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrx/eslint-plugin",
3
- "version": "17.1.1",
3
+ "version": "18.0.0-beta.0",
4
4
  "description": "NgRx ESLint Plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,6 +35,9 @@
35
35
  ],
36
36
  "migrations": "./migrations/migration.json"
37
37
  },
38
+ "ng-add": {
39
+ "save": "devDependencies"
40
+ },
38
41
  "sideEffects": false,
39
42
  "dependencies": {
40
43
  "@typescript-eslint/experimental-utils": "^5.4.0",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,4EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,UAAC,IAAU,EAAE,OAAyB;;QAC3C,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,IAAM,IAAI,GAAG,qCAAqC,CAAC;QAEnD,IAAM,MAAM,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iDACc,gBAAgB,uFAG3C,IAAI,4CAChB,CAAC,CAAC;YACG,OAAO,IAAI,CAAC;SACb;QAED,IAAI;YACF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,6BAAiB,EAAC,MAAM,CAAC,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IACE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAC,QAAa;;oBACjC,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,IAAI,CAAC,UAAC,MAAW;wBACjC,OAAA,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC;oBAAjC,CAAiC,CAClC,CAAA;iBAAA,CACF,EACD;oBACA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;iBACrD;aACF;iBAAM,IACL,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,UAAC,MAAW,IAAK,OAAA,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,EAAjC,CAAiC,CAAC,CAAA,EACvE;gBACA,IAAI,CAAC,SAAS,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;aACnD;YAED,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAEhE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2EACuC,MAAM,CAAC,MAAM,uDAE/C,IAAI,0DAChC,CAAC,CAAC;YACC,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,GAAG,EAAE;YACZ,IAAM,cAAc,GAClB,GAAG,YAAY,KAAK;gBAClB,CAAC,CAAC,sBAEV,GAAG,CAAC,OAAO,OACZ;gBACS,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6IAIb,IAAI,oDACf,cAAc,OACf,CAAC,CAAC;SACE;IACH,CAAC,CAAC;IACF,SAAS,eAAe,CAAC,MAAwB;QAC/C,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,OAAO,EAAE,CAAC,uBAAgB,MAAM,CAAE,CAAC;SACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAjED,sCAiEC","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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,4EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,UAAC,IAAU,EAAE,OAAyB;;QAC3C,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,IAAM,IAAI,GAAG,qCAAqC,CAA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I,0DAChC,CAAC,CAAC;YACC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAM,cAAc,GAClB,GAAG,YAAY,KAAK;gBAClB,CAAC,CAAC,sBAEV,GAAG,CAAC,OAAO,OACZ;gBACS,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6IAIb,IAAI,oDACf,cAAc,OACf,CAAC,CAAC;QACC,CAAC;IACH,CAAC,CAAC;IACF,SAAS,eAAe,CAAC,MAAwB;QAC/C,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,OAAO,EAAE,CAAC,uBAAgB,MAAM,CAAE,CAAC;SACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAjED,sCAiEC","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 +1 @@
1
- {"version":3,"file":"generate-docs.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA6D;AAC7D,yCAA6B;AAC7B,qCAAiD;AACjD,sCAAqC;AAErC,IAAM,cAAc,GAAG,wBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrD,IAAM,WAAW,GAAG,2BAA2B,CAAC;AAChD,IAAM,UAAU,GAAG,sDAAsD,CAAC;;IAE1E,KAAmC,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,aAAK,CAAC,CAAA,gBAAA,4BAAE;QAA/C,IAAA,KAAA,mBAAoB,EAAnB,QAAQ,QAAA,EAAI,IAAI,aAAA;QAC1B,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAG,QAAQ,QAAK,CAAC,CAAC;QACxD,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE;YACxB,IAAA,kBAAa,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SAC5B;QACD,IAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAC9B,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,MAAM,CAC9C,CAAC;QACF,IAAM,MAAM,GAAG,IAAA,iBAAM,EACnB,YAAK,QAAQ,iBAEf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC,EAAE,kBAEpE,MAAA,IAAI,CAAC,IAAI,0CAAE,WAAW,6BAEV,IAAI,CAAC,IAAI,kCACF,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,WAAW,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,8BACzC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,iCACxB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,6CACtB,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,oBAAoB,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,mCACxD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,qGAKrD,UAAU,CAAE,aAER,MAAM,EAAE,UAAU,IACf,cAAc,EAEpB,CAAC;QAEF,IAAA,kBAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAChC","sourcesContent":["import { readFileSync, writeFileSync, existsSync } from 'fs';\nimport * as path from 'path';\nimport { format, resolveConfig } from 'prettier';\nimport { rules } from '../src/rules';\n\nconst prettierConfig = resolveConfig.sync(__dirname);\nconst PLACEHOLDER = '<!-- MANUAL-DOC:START -->';\nconst RULES_PATH = './projects/ngrx.io/content/guide/eslint-plugin/rules';\n\nfor (const [ruleName, { meta }] of Object.entries(rules)) {\n const docPath = path.join(RULES_PATH, `${ruleName}.md`);\n if (!existsSync(docPath)) {\n writeFileSync(docPath, ``);\n }\n const doc = readFileSync(docPath, 'utf-8');\n const docContent = doc.substring(\n doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length\n );\n const newDoc = format(\n `# ${ruleName}\n\n${meta.version ? '> Required NgRx Version Range: ${meta.version}' : ''} \n\n${meta.docs?.description}\n\n- **Type**: ${meta.type}\n- **Recommended**: ${meta.docs?.recommended ? 'Yes' : 'No'}\n- **Fixable**: ${meta.fixable ? 'Yes' : 'No'}\n- **Suggestion**: ${meta.hasSuggestions ? 'Yes' : 'No'}\n- **Requires type checking**: ${meta.docs?.requiresTypeChecking ? 'Yes' : 'No'}\n- **Configurable**: ${meta.schema.length ? 'Yes' : 'No'}\n\n<!-- Everything above this generated, do not edit -->\n<!-- MANUAL-DOC:START -->\n\n${docContent}`,\n {\n parser: 'markdown',\n ...prettierConfig,\n }\n );\n\n writeFileSync(docPath, newDoc);\n}\n"]}
1
+ {"version":3,"file":"generate-docs.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA6D;AAC7D,yCAA6B;AAC7B,qCAAiD;AACjD,sCAAqC;AAErC,IAAM,cAAc,GAAG,wBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrD,IAAM,WAAW,GAAG,2BAA2B,CAAC;AAChD,IAAM,UAAU,GAAG,sDAAsD,CAAC;;IAE1E,KAAmC,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,aAAK,CAAC,CAAA,gBAAA,4BAAE,CAAC;QAAhD,IAAA,KAAA,mBAAoB,EAAnB,QAAQ,QAAA,EAAI,IAAI,aAAA;QAC1B,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAG,QAAQ,QAAK,CAAC,CAAC;QACxD,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAA,kBAAa,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,IAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAC9B,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,MAAM,CAC9C,CAAC;QACF,IAAM,MAAM,GAAG,IAAA,iBAAM,EACnB,YAAK,QAAQ,iBAEf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC,EAAE,kBAEpE,MAAA,IAAI,CAAC,IAAI,0CAAE,WAAW,6BAEV,IAAI,CAAC,IAAI,kCACF,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,WAAW,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,8BACzC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,iCACxB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,6CACtB,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,oBAAoB,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,mCACxD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,qGAKrD,UAAU,CAAE,aAER,MAAM,EAAE,UAAU,IACf,cAAc,EAEpB,CAAC;QAEF,IAAA,kBAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC","sourcesContent":["import { readFileSync, writeFileSync, existsSync } from 'fs';\nimport * as path from 'path';\nimport { format, resolveConfig } from 'prettier';\nimport { rules } from '../src/rules';\n\nconst prettierConfig = resolveConfig.sync(__dirname);\nconst PLACEHOLDER = '<!-- MANUAL-DOC:START -->';\nconst RULES_PATH = './projects/ngrx.io/content/guide/eslint-plugin/rules';\n\nfor (const [ruleName, { meta }] of Object.entries(rules)) {\n const docPath = path.join(RULES_PATH, `${ruleName}.md`);\n if (!existsSync(docPath)) {\n writeFileSync(docPath, ``);\n }\n const doc = readFileSync(docPath, 'utf-8');\n const docContent = doc.substring(\n doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length\n );\n const newDoc = format(\n `# ${ruleName}\n\n${meta.version ? '> Required NgRx Version Range: ${meta.version}' : ''} \n\n${meta.docs?.description}\n\n- **Type**: ${meta.type}\n- **Recommended**: ${meta.docs?.recommended ? 'Yes' : 'No'}\n- **Fixable**: ${meta.fixable ? 'Yes' : 'No'}\n- **Suggestion**: ${meta.hasSuggestions ? 'Yes' : 'No'}\n- **Requires type checking**: ${meta.docs?.requiresTypeChecking ? 'Yes' : 'No'}\n- **Configurable**: ${meta.schema.length ? 'Yes' : 'No'}\n\n<!-- Everything above this generated, do not edit -->\n<!-- MANUAL-DOC:START -->\n\n${docContent}`,\n {\n parser: 'markdown',\n ...prettierConfig,\n }\n );\n\n writeFileSync(docPath, newDoc);\n}\n"]}
@@ -10,7 +10,7 @@ function ruleTester(environment) {
10
10
  (0, utils_1.setNgrxVersion)(environment.ngrxModule, environment.version);
11
11
  }
12
12
  return new experimental_utils_1.TSESLint.RuleTester({
13
- parser: (0, path_1.resolve)('./node_modules/@typescript-eslint/parser'),
13
+ parser: (0, path_1.resolve)('./node_modules/@typescript-eslint/parser/dist'),
14
14
  parserOptions: {
15
15
  project: (0, path_1.resolve)('./modules/eslint-plugin/spec/tsconfig.json'),
16
16
  ecmaVersion: 2020,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/index.ts"],"names":[],"mappings":";;;AAAA,4EAAiE;AACjE,6BAA+B;AAC/B,yCAA6D;AAE7D,SAAgB,UAAU,CAAC,WAG1B;IACC,IAAA,kBAAU,GAAE,CAAC;IAEb,IAAI,WAAW,EAAE;QACf,IAAA,sBAAc,EAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;KAC7D;IAED,OAAO,IAAI,6BAAQ,CAAC,UAAU,CAAC;QAC7B,MAAM,EAAE,IAAA,cAAO,EAAC,0CAA0C,CAAC;QAC3D,aAAa,EAAE;YACb,OAAO,EAAE,IAAA,cAAO,EAAC,4CAA4C,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,QAAQ;SACrB;KACF,CAAC,CAAC;AACL,CAAC;AAlBD,gCAkBC","sourcesContent":["import { TSESLint } from '@typescript-eslint/experimental-utils';\nimport { resolve } from 'path';\nimport { clearCache, setNgrxVersion } from '../../src/utils';\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 TSESLint.RuleTester({\n parser: resolve('./node_modules/@typescript-eslint/parser'),\n parserOptions: {\n project: resolve('./modules/eslint-plugin/spec/tsconfig.json'),\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n });\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/spec/utils/index.ts"],"names":[],"mappings":";;;AAAA,4EAAiE;AACjE,6BAA+B;AAC/B,yCAA6D;AAE7D,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,6BAAQ,CAAC,UAAU,CAAC;QAC7B,MAAM,EAAE,IAAA,cAAO,EAAC,+CAA+C,CAAC;QAChE,aAAa,EAAE;YACb,OAAO,EAAE,IAAA,cAAO,EAAC,4CAA4C,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,QAAQ;SACrB;KACF,CAAC,CAAC;AACL,CAAC;AAlBD,gCAkBC","sourcesContent":["import { TSESLint } from '@typescript-eslint/experimental-utils';\nimport { resolve } from 'path';\nimport { clearCache, setNgrxVersion } from '../../src/utils';\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 TSESLint.RuleTester({\n parser: resolve('./node_modules/@typescript-eslint/parser/dist'),\n parserOptions: {\n project: resolve('./modules/eslint-plugin/spec/tsconfig.json'),\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAoE;AAEpE,iCAA2E;AAiB3E,SAAgB,UAAU,CAIxB,MAQE;;IAEF,IAAM,eAAe,yBAChB,MAAM,KACT,MAAM,EAAE,UACN,OAA8D,EAC9D,kBAAsC;YAGpC,IAAA,KACE,MAAM,KADqB,EAArB,UAAU,gBAAA,EAAE,OAAO,aAAE,CACpB;YACX,IACE,OAAO,KAAK,SAAS;gBACrB,CAAC,IAAA,4BAAoB,EAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,EAC7D;gBACA,OAAO,EAAE,CAAC;aACX;YAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACpD,CAAC,GACF,CAAC;;QAEF,KAA6B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA,gBAAA,4BAAE;YAAjE,IAAA,KAAA,mBAAc,EAAb,GAAG,QAAA,EAAE,OAAO,QAAA;YACrB,eAAe,CAAC,IAAI,CAAC,QAAgB,CAAC,GAAG,CAAC,GAAG,UAAG,OAAO,eAAK,IAAA,eAAO,EAClE,MAAM,CAAC,IAAI,CACZ,MAAG,CAAC;SACN;;;;;;;;;IAED,OAAO,gCAAW,CAAC,WAAW,CAAC,eAAO,CAAC,CAAC,eAAe,CAAC,CAAC;AAC3D,CAAC;AAzCD,gCAyCC","sourcesContent":["import type { TSESLint } from '@typescript-eslint/experimental-utils';\nimport { ESLintUtils } from '@typescript-eslint/experimental-utils';\nimport type { NGRX_MODULE } from './utils';\nimport { docsUrl, ngrxVersionSatisfies, NGRX_MODULE_PATHS } from './utils';\n\ntype Meta<TMessageIds extends string> =\n | TSESLint.RuleMetaData<TMessageIds> & {\n ngrxModule: NGRX_MODULE;\n version?: string;\n };\ntype CreateRuleMeta<TMessageIds extends string> = {\n docs: Omit<TSESLint.RuleMetaDataDocs, 'url'>;\n} & Omit<Meta<TMessageIds>, 'docs'>;\nexport type NgRxRuleModule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n> = Omit<TSESLint.RuleModule<TMessageIds, TOptions>, 'meta'> & {\n meta: Meta<TMessageIds>;\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>;\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"]}
1
+ {"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAoE;AAEpE,iCAA2E;AAiB3E,SAAgB,UAAU,CAIxB,MAQE;;IAEF,IAAM,eAAe,yBAChB,MAAM,KACT,MAAM,EAAE,UACN,OAA8D,EAC9D,kBAAsC;YAGpC,IAAA,KACE,MAAM,KADqB,EAArB,UAAU,gBAAA,EAAE,OAAO,aAAE,CACpB;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,GACF,CAAC;;QAEF,KAA6B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAAlE,IAAA,KAAA,mBAAc,EAAb,GAAG,QAAA,EAAE,OAAO,QAAA;YACrB,eAAe,CAAC,IAAI,CAAC,QAAgB,CAAC,GAAG,CAAC,GAAG,UAAG,OAAO,eAAK,IAAA,eAAO,EAClE,MAAM,CAAC,IAAI,CACZ,MAAG,CAAC;QACP,CAAC;;;;;;;;;IAED,OAAO,gCAAW,CAAC,WAAW,CAAC,eAAO,CAAC,CAAC,eAAe,CAAC,CAAC;AAC3D,CAAC;AAzCD,gCAyCC","sourcesContent":["import type { TSESLint } from '@typescript-eslint/experimental-utils';\nimport { ESLintUtils } from '@typescript-eslint/experimental-utils';\nimport type { NGRX_MODULE } from './utils';\nimport { docsUrl, ngrxVersionSatisfies, NGRX_MODULE_PATHS } from './utils';\n\ntype Meta<TMessageIds extends string> =\n | TSESLint.RuleMetaData<TMessageIds> & {\n ngrxModule: NGRX_MODULE;\n version?: string;\n };\ntype CreateRuleMeta<TMessageIds extends string> = {\n docs: Omit<TSESLint.RuleMetaDataDocs, 'url'>;\n} & Omit<Meta<TMessageIds>, 'docs'>;\nexport type NgRxRuleModule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n> = Omit<TSESLint.RuleModule<TMessageIds, TOptions>, 'meta'> & {\n meta: Meta<TMessageIds>;\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>;\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AACR,QAAA,SAAS,GAAG,uCAAuC,CAAC;AAIjE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,I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,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxComponentStores,\n namedExpression,\n} from '../../utils';\nexport const messageId = 'avoidCombiningComponentStoreSelectors';\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'component-store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;\n const storeSelects = storeNames ? namedExpression(storeNames) : null;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ${thisSelects} ~ ${thisSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest'] ${storeSelects} ~ ${storeSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AACR,QAAA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AAC;4BACb,IAAI,MAAA;4BACJ,SAAS,mBAAA;yBACV,CAAC,CAAC;oBACL,CAAC;;;;;;;;;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxComponentStores,\n namedExpression,\n} from '../../utils';\nexport const messageId = 'avoidCombiningComponentStoreSelectors';\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'component-store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;\n const storeSelects = storeNames ? namedExpression(storeNames) : null;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ${thisSelects} ~ ${thisSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest'] ${storeSelects} ~ ${storeSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-cyclic-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/avoid-cyclic-effects.ts"],"names":[],"mappings":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;YACjF,IAAI,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE;gBACrD,OAAO,EAAE,CAAC;aACX;YACD,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB;YACE,GAAC,UAAG,8BAAsB,+JAAqJ,YAAY,MAAG,IAA9L,UACE,IAAI;gBAEJ,IAAI,SAAS,EAAE;oBACb,SAAS,CAAC,IAAI,CAAC,CAAC;oBAChB,SAAS,GAAG,KAAK,CAAC;oBAClB,OAAO;iBACR;YACH,CAAC;YAED,GAAC,UAAG,8BAAsB,+HAA4H,IAAtJ;gBACE,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { getTypeServices } from 'eslint-etc';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getNgRxEffectActions,\n isCallExpression,\n isIdentifier,\n isTypeReference,\n} from '../../utils';\n\nexport const messageId = 'avoidCyclicEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\n// This rule is a modified version (to support dispatch: false) from the eslint-plugin-rxjs plugin.\n// The original implementation can be found at https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-cyclic-action.ts\n// Thank you Nicholas Jamieson (@cartant).\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description: 'Avoid `Effect` that re-emit filtered actions.',\n recommended: 'warn',\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: '`Effect` that re-emit filtered actions are forbidden.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n const { getType, typeChecker } = getTypeServices(context);\n\n function checkNode(pipeCallExpression: TSESTree.CallExpression) {\n const operatorCallExpression = pipeCallExpression.arguments.find(\n (arg) =>\n isCallExpression(arg) &&\n isIdentifier(arg.callee) &&\n arg.callee.name === 'ofType'\n );\n if (!operatorCallExpression) {\n return;\n }\n const operatorType = getType(operatorCallExpression);\n const [signature] = typeChecker.getSignaturesOfType(\n operatorType,\n ts.SignatureKind.Call\n );\n\n if (!signature) {\n return;\n }\n const operatorReturnType =\n typeChecker.getReturnTypeOfSignature(signature);\n if (!isTypeReference(operatorReturnType)) {\n return;\n }\n const [operatorElementType] =\n typeChecker.getTypeArguments(operatorReturnType);\n if (!operatorElementType) {\n return;\n }\n\n const pipeType = getType(pipeCallExpression);\n if (!isTypeReference(pipeType)) {\n return;\n }\n const [pipeElementType] = typeChecker.getTypeArguments(pipeType);\n if (!pipeElementType) {\n return;\n }\n\n const operatorActionTypes = getActionTypes(operatorElementType);\n const pipeActionTypes = getActionTypes(pipeElementType);\n\n for (const actionType of operatorActionTypes) {\n if (pipeActionTypes.includes(actionType)) {\n context.report({\n node: pipeCallExpression.callee,\n messageId,\n });\n return;\n }\n }\n }\n\n function getActionType(symbol: ts.Symbol): ts.Type | null {\n const { valueDeclaration } = symbol;\n\n if (!valueDeclaration) {\n return null;\n }\n\n if (valueDeclaration.kind === ts.SyntaxKind.PropertyDeclaration) {\n const { parent } = symbol as typeof symbol & { parent: ts.Symbol };\n return parent.valueDeclaration\n ? typeChecker.getTypeOfSymbolAtLocation(\n parent,\n parent.valueDeclaration\n )\n : null;\n }\n\n return typeChecker.getTypeOfSymbolAtLocation(symbol, valueDeclaration);\n }\n\n function getActionTypes(type: ts.Type): string[] {\n if (type.isUnion()) {\n const memberActionTypes: string[] = [];\n for (const memberType of type.types) {\n memberActionTypes.push(...getActionTypes(memberType));\n }\n return memberActionTypes;\n }\n\n const symbol = typeChecker.getPropertyOfType(type, 'type');\n\n if (!symbol) {\n return [];\n }\n\n const actionType = getActionType(symbol);\n\n if (!actionType) {\n return [];\n }\n\n // TODO: support \"dynamic\" types\n // e.g. const genericFoo = createAction(`${subject} FOO`); (resolves to 'string')\n if (typeChecker.typeToString(actionType) === 'string') {\n return [];\n }\n return [typeChecker.typeToString(actionType)];\n }\n\n let firstPipe = true;\n return {\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe'][callee.object.property.name=${actionsNames}]`](\n node\n ) {\n if (firstPipe) {\n checkNode(node);\n firstPipe = false;\n return;\n }\n },\n\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe']:exit`]() {\n firstPipe = true;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-cyclic-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/avoid-cyclic-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6C;AAC7C,yCAA6B;AAC7B,6CAAiC;AACjC,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,oBAAoB,CAAC;AAK9C,mGAAmG;AACnG,uIAAuI;AACvI,0CAA0C;AAE1C,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,+CAA+C;YAC5D,WAAW,EAAE,MAAM;YACnB,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,uDAAuD;eACrE;KACF;IACD,cAAc,EAAE,EAAE;I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C;YACH,CAAC;YAED,GAAC,UAAG,8BAAsB,+HAA4H,IAAtJ;gBACE,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { getTypeServices } from 'eslint-etc';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getNgRxEffectActions,\n isCallExpression,\n isIdentifier,\n isTypeReference,\n} from '../../utils';\n\nexport const messageId = 'avoidCyclicEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\n// This rule is a modified version (to support dispatch: false) from the eslint-plugin-rxjs plugin.\n// The original implementation can be found at https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-cyclic-action.ts\n// Thank you Nicholas Jamieson (@cartant).\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description: 'Avoid `Effect` that re-emit filtered actions.',\n recommended: 'warn',\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: '`Effect` that re-emit filtered actions are forbidden.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n const { getType, typeChecker } = getTypeServices(context);\n\n function checkNode(pipeCallExpression: TSESTree.CallExpression) {\n const operatorCallExpression = pipeCallExpression.arguments.find(\n (arg) =>\n isCallExpression(arg) &&\n isIdentifier(arg.callee) &&\n arg.callee.name === 'ofType'\n );\n if (!operatorCallExpression) {\n return;\n }\n const operatorType = getType(operatorCallExpression);\n const [signature] = typeChecker.getSignaturesOfType(\n operatorType,\n ts.SignatureKind.Call\n );\n\n if (!signature) {\n return;\n }\n const operatorReturnType =\n typeChecker.getReturnTypeOfSignature(signature);\n if (!isTypeReference(operatorReturnType)) {\n return;\n }\n const [operatorElementType] =\n typeChecker.getTypeArguments(operatorReturnType);\n if (!operatorElementType) {\n return;\n }\n\n const pipeType = getType(pipeCallExpression);\n if (!isTypeReference(pipeType)) {\n return;\n }\n const [pipeElementType] = typeChecker.getTypeArguments(pipeType);\n if (!pipeElementType) {\n return;\n }\n\n const operatorActionTypes = getActionTypes(operatorElementType);\n const pipeActionTypes = getActionTypes(pipeElementType);\n\n for (const actionType of operatorActionTypes) {\n if (pipeActionTypes.includes(actionType)) {\n context.report({\n node: pipeCallExpression.callee,\n messageId,\n });\n return;\n }\n }\n }\n\n function getActionType(symbol: ts.Symbol): ts.Type | null {\n const { valueDeclaration } = symbol;\n\n if (!valueDeclaration) {\n return null;\n }\n\n if (valueDeclaration.kind === ts.SyntaxKind.PropertyDeclaration) {\n const { parent } = symbol as typeof symbol & { parent: ts.Symbol };\n return parent.valueDeclaration\n ? typeChecker.getTypeOfSymbolAtLocation(\n parent,\n parent.valueDeclaration\n )\n : null;\n }\n\n return typeChecker.getTypeOfSymbolAtLocation(symbol, valueDeclaration);\n }\n\n function getActionTypes(type: ts.Type): string[] {\n if (type.isUnion()) {\n const memberActionTypes: string[] = [];\n for (const memberType of type.types) {\n memberActionTypes.push(...getActionTypes(memberType));\n }\n return memberActionTypes;\n }\n\n const symbol = typeChecker.getPropertyOfType(type, 'type');\n\n if (!symbol) {\n return [];\n }\n\n const actionType = getActionType(symbol);\n\n if (!actionType) {\n return [];\n }\n\n // TODO: support \"dynamic\" types\n // e.g. const genericFoo = createAction(`${subject} FOO`); (resolves to 'string')\n if (typeChecker.typeToString(actionType) === 'string') {\n return [];\n }\n return [typeChecker.typeToString(actionType)];\n }\n\n let firstPipe = true;\n return {\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe'][callee.object.property.name=${actionsNames}]`](\n node\n ) {\n if (firstPipe) {\n checkNode(node);\n firstPipe = false;\n return;\n }\n },\n\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe']:exit`]() {\n firstPipe = true;\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-dispatch-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-dispatch-in-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAUvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE;YACJ,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,2BAAmB,IAClB,oDAAoD;YACtD,GAAC,kCAA0B,IAAG,0BAA0B;eACzD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,IAAA,yBAAiB,EAAC,UAAU,CAAC,IAA9B,UACE,IAA0C;gBAE1C,IAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;gBAC3C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,YAAY;oBAClB,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAA1B,CAA0B;yBAC3C;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,IAA0C;IACzD,IAAA,MAAM,GAAK,IAAI,OAAT,CAAU;IAChB,IAAQ,WAAW,GAAK,MAAM,OAAX,CAAY;IACvC,OAAO,WAAW;QAChB,CAAC,IAAA,iCAAyB,EAAC,WAAW,CAAC,IAAI,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC;QAC1E,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM,CAAC;AACb,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n dispatchInEffects,\n getNgRxStores,\n isArrowFunctionExpression,\n isReturnStatement,\n} from '../../utils';\n\nexport const noDispatchInEffects = 'noDispatchInEffects';\nexport const noDispatchInEffectsSuggest = 'noDispatchInEffectsSuggest';\n\ntype MessageIds =\n | typeof noDispatchInEffects\n | typeof noDispatchInEffectsSuggest;\ntype Options = readonly [];\ntype MemberExpressionWithinCallExpression = TSESTree.MemberExpression & {\n parent: TSESTree.CallExpression;\n};\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n hasSuggestions: true,\n docs: {\n description: '`Effect` should not call `store.dispatch`.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noDispatchInEffects]:\n 'Calling `store.dispatch` in `Effect` is forbidden.',\n [noDispatchInEffectsSuggest]: 'Remove `store.dispatch`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [dispatchInEffects(storeNames)](\n node: MemberExpressionWithinCallExpression\n ) {\n const nodeToReport = getNodeToReport(node);\n context.report({\n node: nodeToReport,\n messageId: noDispatchInEffects,\n suggest: [\n {\n messageId: noDispatchInEffectsSuggest,\n fix: (fixer) => fixer.remove(nodeToReport),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getNodeToReport(node: MemberExpressionWithinCallExpression) {\n const { parent } = node;\n const { parent: grandParent } = parent;\n return grandParent &&\n (isArrowFunctionExpression(grandParent) || isReturnStatement(grandParent))\n ? node\n : parent;\n}\n"]}
1
+ {"version":3,"file":"no-dispatch-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-dispatch-in-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAUvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE;YACJ,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,2BAAmB,IAClB,oDAAoD;YACtD,GAAC,kCAA0B,IAAG,0BAA0B;eACzD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED;YACE,GAAC,IAAA,yBAAiB,EAAC,UAAU,CAAC,IAA9B,UACE,IAA0C;gBAE1C,IAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;gBAC3C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,YAAY;oBAClB,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAA1B,CAA0B;yBAC3C;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,IAA0C;IACzD,IAAA,MAAM,GAAK,IAAI,OAAT,CAAU;IAChB,IAAQ,WAAW,GAAK,MAAM,OAAX,CAAY;IACvC,OAAO,WAAW;QAChB,CAAC,IAAA,iCAAyB,EAAC,WAAW,CAAC,IAAI,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC;QAC1E,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM,CAAC;AACb,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n dispatchInEffects,\n getNgRxStores,\n isArrowFunctionExpression,\n isReturnStatement,\n} from '../../utils';\n\nexport const noDispatchInEffects = 'noDispatchInEffects';\nexport const noDispatchInEffectsSuggest = 'noDispatchInEffectsSuggest';\n\ntype MessageIds =\n | typeof noDispatchInEffects\n | typeof noDispatchInEffectsSuggest;\ntype Options = readonly [];\ntype MemberExpressionWithinCallExpression = TSESTree.MemberExpression & {\n parent: TSESTree.CallExpression;\n};\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n hasSuggestions: true,\n docs: {\n description: '`Effect` should not call `store.dispatch`.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noDispatchInEffects]:\n 'Calling `store.dispatch` in `Effect` is forbidden.',\n [noDispatchInEffectsSuggest]: 'Remove `store.dispatch`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [dispatchInEffects(storeNames)](\n node: MemberExpressionWithinCallExpression\n ) {\n const nodeToReport = getNodeToReport(node);\n context.report({\n node: nodeToReport,\n messageId: noDispatchInEffects,\n suggest: [\n {\n messageId: noDispatchInEffectsSuggest,\n fix: (fixer) => fixer.remove(nodeToReport),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getNodeToReport(node: MemberExpressionWithinCallExpression) {\n const { parent } = node;\n const { parent: grandParent } = parent;\n return grandParent &&\n (isArrowFunctionExpression(grandParent) || isReturnStatement(grandParent))\n ? node\n : parent;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-effects-in-providers.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effects-in-providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,sBAAsB,CAAC;AAKhD,kBAAe,IAAA,yBAAU,EA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;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBACzB,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAC7B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n effectsInNgModuleImports,\n effectsInNgModuleProviders,\n getNodeToCommaRemoveFix,\n ngModuleDecorator,\n} from '../../utils';\n\nexport const messageId = 'noEffectsInProviders';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n recommended: 'error',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const effectsInProviders = new Set<TSESTree.Identifier>();\n const effectsInImports = new Set<string>();\n\n return {\n [effectsInNgModuleProviders](node: TSESTree.Identifier) {\n effectsInProviders.add(node);\n },\n [effectsInNgModuleImports]({ name }: TSESTree.Identifier) {\n effectsInImports.add(name);\n },\n [`${ngModuleDecorator}:exit`]() {\n for (const effectInProvider of effectsInProviders) {\n if (!effectsInImports.has(effectInProvider.name)) {\n continue;\n }\n\n context.report({\n node: effectInProvider,\n messageId,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, effectInProvider),\n });\n }\n\n effectsInImports.clear();\n effectsInProviders.clear();\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"no-effects-in-providers.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effects-in-providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAA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,IAAA,uBAAA,SAAA,kBAAkB,CAAA,sDAAA;wBAA5C,IAAM,gBAAgB,+BAAA;gCAAhB,gBAAgB;qBAW1B;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBACzB,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAC7B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n effectsInNgModuleImports,\n effectsInNgModuleProviders,\n getNodeToCommaRemoveFix,\n ngModuleDecorator,\n} from '../../utils';\n\nexport const messageId = 'noEffectsInProviders';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n recommended: 'error',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const effectsInProviders = new Set<TSESTree.Identifier>();\n const effectsInImports = new Set<string>();\n\n return {\n [effectsInNgModuleProviders](node: TSESTree.Identifier) {\n effectsInProviders.add(node);\n },\n [effectsInNgModuleImports]({ name }: TSESTree.Identifier) {\n effectsInImports.add(name);\n },\n [`${ngModuleDecorator}:exit`]() {\n for (const effectInProvider of effectsInProviders) {\n if (!effectsInImports.has(effectInProvider.name)) {\n continue;\n }\n\n context.report({\n node: effectInProvider,\n messageId,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, effectInProvider),\n });\n }\n\n effectsInImports.clear();\n effectsInProviders.clear();\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-multiple-actions-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint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C;QAC3B;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;KACxB;AACH,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';\nimport { getTypeServices } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n createEffectExpression,\n mapLikeOperatorsExplicitReturn,\n mapLikeOperatorsImplicitReturn,\n} from '../../utils';\n\nexport const messageId = 'noMultipleActionsInEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\ntype EffectsMapLikeOperatorsReturn =\n | TSESTree.ArrowFunctionExpression\n | TSESTree.CallExpression\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 recommended: 'warn',\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} :matches(${mapLikeOperatorsImplicitReturn}, ${mapLikeOperatorsExplicitReturn})`](\n node: EffectsMapLikeOperatorsReturn\n ) {\n const nodeToReport = getNodeToReport(node);\n\n if (\n !nodeToReport ||\n !getTypeServices(context).couldBeType(nodeToReport, 'Array')\n ) {\n return;\n }\n\n context.report({\n node: nodeToReport,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getNodeToReport(node: EffectsMapLikeOperatorsReturn) {\n switch (node.type) {\n case AST_NODE_TYPES.ArrowFunctionExpression:\n return node.body;\n case AST_NODE_TYPES.CallExpression:\n return node.arguments[0];\n default:\n return node.argument;\n }\n}\n"]}
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAA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Content":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';\nimport { getTypeServices } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n createEffectExpression,\n mapLikeOperatorsExplicitReturn,\n mapLikeOperatorsImplicitReturn,\n} from '../../utils';\n\nexport const messageId = 'noMultipleActionsInEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\ntype EffectsMapLikeOperatorsReturn =\n | TSESTree.ArrowFunctionExpression\n | TSESTree.CallExpression\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 recommended: 'warn',\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} :matches(${mapLikeOperatorsImplicitReturn}, ${mapLikeOperatorsExplicitReturn})`](\n node: EffectsMapLikeOperatorsReturn\n ) {\n const nodeToReport = getNodeToReport(node);\n\n if (\n !nodeToReport ||\n !getTypeServices(context).couldBeType(nodeToReport, 'Array')\n ) {\n return;\n }\n\n context.report({\n node: nodeToReport,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getNodeToReport(node: EffectsMapLikeOperatorsReturn) {\n switch (node.type) {\n case AST_NODE_TYPES.ArrowFunctionExpression:\n return node.body;\n case AST_NODE_TYPES.CallExpression:\n return node.arguments[0];\n default:\n return node.argument;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-concat-latest-from.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-concat-latest-from.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAuD;AACvD,yCAA6B;AAC7B,mDA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C1C,OAAO,CAAA;QACL,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,uBAAuB,CAAC;cAC7C,CAAC,IAAA,sCAAyB,EAAC,aAAa,CAAC;QAC1C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,SACvD,CAAA,CAAC,MAAM,0BACN,IAAA,uBAAe,EAAC;YACd,KAAK,OAAA;YACL,UAAU,EAAE,uBAAuB;YACnC,UAAU,EAAE,yBAAiB,CAAC,OAAO;YACrC,IAAI,MAAA;SACL,CAAC,UACC,CAAC,kCAAkC,IAAI,SAAS;QACjD,CAAC,CAAC;YACE,IAAA,uBAAe,EAAC;gBACd,KAAK,OAAA;gBACL,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,MAAA;aACL,CAAC;YACF,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;SACvD;QACH,CAAC,CAAC,EAAE,CAAC,WACP;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { isArrowFunctionExpression } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getImportAddFix,\n getNgRxEffectActions,\n namedExpression,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'preferConcatLatestFrom';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [{ readonly strict: boolean }];\ntype WithLatestFromIdentifier = TSESTree.Identifier & {\n parent: TSESTree.CallExpression;\n};\n\nconst defaultOptions: Options[number] = { strict: false };\nconst concatLatestFromKeyword = 'concatLatestFrom';\nconst withLatestFromKeyword = 'withLatestFrom';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n version: '>=12.0.0',\n docs: {\n description: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\` to prevent the selector from firing until the correct \\`Action\\` is dispatched.`,\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'object',\n properties: {\n strict: {\n type: 'boolean',\n default: defaultOptions.strict,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n [messageId]: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\`.`,\n },\n },\n defaultOptions: [defaultOptions],\n create: (context, [options]) => {\n if (options.strict) {\n return {\n [`${createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(context.getSourceCode(), fixer, node),\n });\n },\n };\n }\n\n const { identifiers = [], sourceCode } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n return {\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(sourceCode, fixer, node),\n });\n },\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: WithLatestFromIdentifier\n) {\n const { parent } = node;\n const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;\n const [firstArgument] = parent.arguments;\n const nextToken =\n isUsingDeprecatedProjectorArgument &&\n sourceCode.getTokenAfter(firstArgument);\n return [\n fixer.replaceText(node, concatLatestFromKeyword),\n ...(isArrowFunctionExpression(firstArgument)\n ? []\n : [fixer.insertTextBefore(firstArgument, '() => ')]),\n ].concat(\n getImportAddFix({\n fixer,\n importName: concatLatestFromKeyword,\n moduleName: NGRX_MODULE_PATHS.effects,\n node,\n }),\n ...(isUsingDeprecatedProjectorArgument && nextToken\n ? [\n getImportAddFix({\n fixer,\n importName: 'map',\n moduleName: 'rxjs/operators',\n node,\n }),\n fixer.insertTextAfterRange(nextToken.range, '), map('),\n ]\n : [])\n );\n}\n"]}
1
+ {"version":3,"file":"prefer-concat-latest-from.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-concat-latest-from.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAuD;AACvD,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAQlD,IAAM,cAAc,GAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1D,IAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,IAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,eAAS,uBAAuB,2BAAmB,qBAAqB,oFAAoF;YACzK,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,cAAc,CAAC,MAAM;qBAC/B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ;YACN,GAAC,iBAAS,IAAG,eA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ils';\nimport { isArrowFunctionExpression } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getImportAddFix,\n getNgRxEffectActions,\n namedExpression,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'preferConcatLatestFrom';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [{ readonly strict: boolean }];\ntype WithLatestFromIdentifier = TSESTree.Identifier & {\n parent: TSESTree.CallExpression;\n};\n\nconst defaultOptions: Options[number] = { strict: false };\nconst concatLatestFromKeyword = 'concatLatestFrom';\nconst withLatestFromKeyword = 'withLatestFrom';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n version: '>=12.0.0',\n docs: {\n description: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\` to prevent the selector from firing until the correct \\`Action\\` is dispatched.`,\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'object',\n properties: {\n strict: {\n type: 'boolean',\n default: defaultOptions.strict,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n [messageId]: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\`.`,\n },\n },\n defaultOptions: [defaultOptions],\n create: (context, [options]) => {\n if (options.strict) {\n return {\n [`${createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(context.getSourceCode(), fixer, node),\n });\n },\n };\n }\n\n const { identifiers = [], sourceCode } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n return {\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(sourceCode, fixer, node),\n });\n },\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: WithLatestFromIdentifier\n) {\n const { parent } = node;\n const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;\n const [firstArgument] = parent.arguments;\n const nextToken =\n isUsingDeprecatedProjectorArgument &&\n sourceCode.getTokenAfter(firstArgument);\n return [\n fixer.replaceText(node, concatLatestFromKeyword),\n ...(isArrowFunctionExpression(firstArgument)\n ? []\n : [fixer.insertTextBefore(firstArgument, '() => ')]),\n ].concat(\n getImportAddFix({\n fixer,\n importName: concatLatestFromKeyword,\n moduleName: NGRX_MODULE_PATHS.effects,\n node,\n }),\n ...(isUsingDeprecatedProjectorArgument && nextToken\n ? [\n getImportAddFix({\n fixer,\n importName: 'map',\n moduleName: 'rxjs/operators',\n node,\n }),\n fixer.insertTextAfterRange(nextToken.range, '), map('),\n ]\n : [])\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-effect-callback-in-block-statement.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-effect-callback-in-block-statement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqD;AAExC,QAAA,SAAS,GAAG,sCAAsC,CAAC;AAKhE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,IAAI,EA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mBAAmB,CAAC,SAAS,CAAC,EACvC;QACA,OAAO,CAAC,aAAa,EAAE,SAAS,CAAU,CAAC;KAC5C;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAC/B,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createEffectExpression } from '../../utils';\n\nexport const messageId = 'preferEffectCallbackInBlockStatement';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n docs: {\n description: 'A block statement is easier to troubleshoot.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'The callback of `Effect` should be wrapped in a block statement.',\n },\n fixable: 'code',\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const nonParametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > .body[type!=/^(ArrowFunctionExpression|BlockStatement)$/]` as const;\n const parametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n const parametrizedEffectWithinBlockStatement =\n `${createEffectExpression} > ArrowFunctionExpression > BlockStatement > ReturnStatement > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n\n return {\n [`${nonParametrizedEffect}, ${parametrizedEffect}, ${parametrizedEffectWithinBlockStatement}`](\n node: TSESTree.ArrowFunctionExpression['body']\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => {\n const [previousNode, nextNode] = getSafeNodesToApplyFix(\n sourceCode,\n node\n );\n return [\n fixer.insertTextBefore(previousNode, `{ return `),\n fixer.insertTextAfter(nextNode, ` }`),\n ];\n },\n });\n },\n };\n },\n});\n\nfunction getSafeNodesToApplyFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n node: TSESTree.Node\n) {\n const previousToken = sourceCode.getTokenBefore(node);\n const nextToken = sourceCode.getTokenAfter(node);\n\n if (\n previousToken &&\n ASTUtils.isOpeningParenToken(previousToken) &&\n nextToken &&\n ASTUtils.isClosingParenToken(nextToken)\n ) {\n return [previousToken, nextToken] as const;\n }\n\n return [node, node] as const;\n}\n"]}
1
+ {"version":3,"file":"prefer-effect-callback-in-block-statement.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-effect-callback-in-block-statement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqD;AAExC,QAAA,SAAS,GAAG,sCAAsC,CAAC;AAKhE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;YAC3D,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,kEAAkE;eACrE;QACD,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,IAAM,qBAAqB,GACzB,UAAG,8BAAsB,2FAAiG,CAAC;QAC7H,IAAM,kBAAkB,GACtB,UAAG,8BAAsB,yFAA+F,CAAC;QAC3H,IAAM,sCAAsC,GAC1C,UAAG,8BAAsB,4HAAkI,CAAC;QAE9J;YACE,GAAC,UAAG,qBAAqB,eAAK,kBAAkB,eAAK,sCAAsC,CAAE,IAA7F,UACE,IAA8C;gBAE9C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,GAAG,EAAE,UAAC,KAAK;wBACH,IAAA,KAAA,OAA2B,sBAAsB,CACrD,UAAU,EACV,IAAI,CACL,IAAA,EAHM,YAAY,QAAA,EAAE,QAAQ,QAG5B,CAAC;wBACF,OAAO;4BACL,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE,WAAW,CAAC;4BACjD,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC;yBACtC,CAAC;oBACJ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAC7B,UAAyC,EACzC,IAAmB;IAEnB,IAAM,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACtD,IAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAEjD,IACE,aAAa;QACb,6BAAQ,CAAC,mBAAmB,CAAC,aAAa,CAAC;QAC3C,SAAS;QACT,6BAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACvC,CAAC;QACD,OAAO,CAAC,aAAa,EAAE,SAAS,CAAU,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAC/B,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createEffectExpression } from '../../utils';\n\nexport const messageId = 'preferEffectCallbackInBlockStatement';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n docs: {\n description: 'A block statement is easier to troubleshoot.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'The callback of `Effect` should be wrapped in a block statement.',\n },\n fixable: 'code',\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const nonParametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > .body[type!=/^(ArrowFunctionExpression|BlockStatement)$/]` as const;\n const parametrizedEffect =\n `${createEffectExpression} > ArrowFunctionExpression > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n const parametrizedEffectWithinBlockStatement =\n `${createEffectExpression} > ArrowFunctionExpression > BlockStatement > ReturnStatement > ArrowFunctionExpression > .body[type!='BlockStatement']` as const;\n\n return {\n [`${nonParametrizedEffect}, ${parametrizedEffect}, ${parametrizedEffectWithinBlockStatement}`](\n node: TSESTree.ArrowFunctionExpression['body']\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => {\n const [previousNode, nextNode] = getSafeNodesToApplyFix(\n sourceCode,\n node\n );\n return [\n fixer.insertTextBefore(previousNode, `{ return `),\n fixer.insertTextAfter(nextNode, ` }`),\n ];\n },\n });\n },\n };\n },\n});\n\nfunction getSafeNodesToApplyFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n node: TSESTree.Node\n) {\n const previousToken = sourceCode.getTokenBefore(node);\n const nextToken = sourceCode.getTokenAfter(node);\n\n if (\n previousToken &&\n ASTUtils.isOpeningParenToken(previousToken) &&\n nextToken &&\n ASTUtils.isClosingParenToken(nextToken)\n ) {\n return [previousToken, nextToken] as const;\n }\n\n return [node, node] as const;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-effects-lifecycle-interface.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/use-effects-lifecycle-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,8BAA8B,CAAC;AAKxD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CA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B,CAAC,OAAO;4BACrC,IAAI,EAAE,gBAAgB;yBACvB,CAAC,CACH,CAAC;oBACJ,CAAC;oBACD,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,aAAa,eAAA;wBACb,UAAU,YAAA;qBACX;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getImplementsSchemaFixer,\n getImportAddFix,\n getInterface,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'useEffectsLifecycleInterface';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n docs: {\n description:\n 'Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const lifecycleMapper = {\n ngrxOnIdentifyEffects: 'OnIdentifyEffects',\n ngrxOnInitEffects: 'OnInitEffects',\n ngrxOnRunEffects: 'OnRunEffects',\n } as const;\n const lifecyclesPattern = Object.keys(lifecycleMapper).join('|');\n\n return {\n [`ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/${lifecyclesPattern}/]`](\n node: TSESTree.Identifier & {\n name: keyof typeof lifecycleMapper;\n parent: TSESTree.MethodDefinition & {\n parent: TSESTree.ClassBody & { parent: TSESTree.ClassDeclaration };\n };\n }\n ) {\n const classDeclaration = node.parent.parent.parent;\n const methodName = node.name;\n const interfaceName = lifecycleMapper[methodName];\n\n if (getInterface(classDeclaration, interfaceName)) {\n return;\n }\n\n context.report({\n fix: (fixer) => {\n const { implementsNodeReplace, implementsTextReplace } =\n getImplementsSchemaFixer(classDeclaration, interfaceName);\n return [\n fixer.insertTextAfter(\n implementsNodeReplace,\n implementsTextReplace\n ),\n ].concat(\n getImportAddFix({\n compatibleWithTypeOnlyImport: true,\n fixer,\n importName: interfaceName,\n moduleName: NGRX_MODULE_PATHS.effects,\n node: classDeclaration,\n })\n );\n },\n node,\n messageId,\n data: {\n interfaceName,\n methodName,\n },\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"use-effects-lifecycle-interface.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/use-effects-lifecycle-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,8BAA8B,CAAC;AAKxD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,iGAAiG;YACnG,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,gGAAgG;eACnG;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,eAAe,GAAG;YACtB,qBAAqB,EAAE,mBAAmB;YAC1C,iBAAiB,EAAE,eAAe;YAClC,gBAAgB,EAAE,cAAc;SACxB,CAAC;QACX,IAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjE;YACE,GAAC,6EAAsE,iBAAiB,OAAI,IAA5F,UACE,IAKC;gBAED,IAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBACnD,IAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;gBAC7B,IAAM,aAAa,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;gBAElD,IAAI,IAAA,oBAAY,EAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;oBAClD,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,GAAG,EAAE,UAAC,KAAK;wBACH,IAAA,KACJ,IAAA,gCAAwB,EAAC,gBAAgB,EAAE,aAAa,CAAC,EADnD,qBAAqB,2BAAA,EAAE,qBAAqB,2BACO,CAAC;wBAC5D,OAAO;4BACL,KAAK,CAAC,eAAe,CACnB,qBAAqB,EACrB,qBAAqB,CACtB;yBACF,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;4BACd,4BAA4B,EAAE,IAAI;4BAClC,KAAK,OAAA;4BACL,UAAU,EAAE,aAAa;4BACzB,UAAU,EAAE,yBAAiB,CAAC,OAAO;4BACrC,IAAI,EAAE,gBAAgB;yBACvB,CAAC,CACH,CAAC;oBACJ,CAAC;oBACD,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,aAAa,eAAA;wBACb,UAAU,YAAA;qBACX;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getImplementsSchemaFixer,\n getImportAddFix,\n getInterface,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'useEffectsLifecycleInterface';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'effects',\n docs: {\n description:\n 'Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const lifecycleMapper = {\n ngrxOnIdentifyEffects: 'OnIdentifyEffects',\n ngrxOnInitEffects: 'OnInitEffects',\n ngrxOnRunEffects: 'OnRunEffects',\n } as const;\n const lifecyclesPattern = Object.keys(lifecycleMapper).join('|');\n\n return {\n [`ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/${lifecyclesPattern}/]`](\n node: TSESTree.Identifier & {\n name: keyof typeof lifecycleMapper;\n parent: TSESTree.MethodDefinition & {\n parent: TSESTree.ClassBody & { parent: TSESTree.ClassDeclaration };\n };\n }\n ) {\n const classDeclaration = node.parent.parent.parent;\n const methodName = node.name;\n const interfaceName = lifecycleMapper[methodName];\n\n if (getInterface(classDeclaration, interfaceName)) {\n return;\n }\n\n context.report({\n fix: (fixer) => {\n const { implementsNodeReplace, implementsTextReplace } =\n getImplementsSchemaFixer(classDeclaration, interfaceName);\n return [\n fixer.insertTextAfter(\n implementsNodeReplace,\n implementsTextReplace\n ),\n ].concat(\n getImportAddFix({\n compatibleWithTypeOnlyImport: true,\n fixer,\n importName: interfaceName,\n moduleName: NGRX_MODULE_PATHS.effects,\n node: classDeclaration,\n })\n );\n },\n node,\n messageId,\n data: {\n interfaceName,\n methodName,\n },\n });\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,yBAAyB,CAAC;AAKnD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED,IAAM,qBAAqB,GAAG,mBAAY,IAAA,uBAAe,EACvD,UAAU,CACX,sFAA4E,IAAA,wBAAgB,EAC3F,UAAU,CACX,MAAY,CAAC;QAEd,IAAM,cAAc,GAA8B,EAAE,CAAC;QACrD;YACE,GAAC,sDAA+C,qBAAqB,gBAAM,qBAAqB,CAAE,IAAlG,UACE,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,GAAC,kDAAkD,IAAnD;;;oBACE,KAAmB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE;wBAA9B,IAAM,IAAI,2BAAA;wBACb,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,MAAA;4BACJ,SAAS,mBAAA;yBACV,CAAC,CAAC;qBACJ;;;;;;;;;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n namedExpression,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidCombiningSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeableOrStoreSelect = `:matches(${namedExpression(\n storeNames\n )}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${selectExpression(\n storeNames\n )})` as const;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,yBAAyB,CAAC;AAKnD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAM,qBAAqB,GAAG,mBAAY,IAAA,uBAAe,EACvD,UAAU,CACX,sFAA4E,IAAA,wBAAgB,EAC3F,UAAU,CACX,MAAY,CAAC;QAEd,IAAM,cAAc,GAA8B,EAAE,CAAC;QACrD;YACE,GAAC,sDAA+C,qBAAqB,gBAAM,qBAAqB,CAAE,IAAlG,UACE,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,GAAC,kDAAkD,IAAnD;;;oBACE,KAAmB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE,CAAC;wBAA/B,IAAM,IAAI,2BAAA;wBACb,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,MAAA;4BACJ,SAAS,mBAAA;yBACV,CAAC,CAAC;oBACL,CAAC;;;;;;;;;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n namedExpression,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidCombiningSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeableOrStoreSelect = `:matches(${namedExpression(\n storeNames\n )}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${selectExpression(\n storeNames\n )})` as const;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE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AG,CAAC,CAAC;YACjC,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches: TSESTree.CallExpression[] = [];\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.push(node);\n },\n 'BlockStatement:exit'() {\n const withSameParent = collectedDispatches.filter((d1) =>\n collectedDispatches.some(\n (d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent\n )\n );\n if (withSameParent.length > 1) {\n for (const node of withSameParent) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.length = 0;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,kBAAe,IAAA,yBAAU,EAA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cAAc,CAAA,8CAAA,0EAAE,CAAC;4BAA/B,IAAM,IAAI,2BAAA;4BACb,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,MAAA;gCACJ,SAAS,mBAAA;6BACV,CAAC,CAAC;wBACL,CAAC;;;;;;;;;gBACH,CAAC;gBAED,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC;YACjC,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches: TSESTree.CallExpression[] = [];\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.push(node);\n },\n 'BlockStatement:exit'() {\n const withSameParent = collectedDispatches.filter((d1) =>\n collectedDispatches.some(\n (d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent\n )\n );\n if (withSameParent.length > 1) {\n for (const node of withSameParent) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.length = 0;\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/e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AA/C,IAAA,KAAA,qCAAyB,EAAxB,UAAU,QAAA,EAAE,WAAW,QAAA;wBACjC,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;4BAC3B,MAAM;yBACP;gDAEU,IAAI;4BACb,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,MAAA;gCACJ,SAAS,EAAE,sCAA8B;gCACzC,IAAI,EAAE;oCACJ,UAAU,YAAA;iCACX;gCACD,OAAO,EAAE;oCACP;wCACE,SAAS,EAAE,6CAAqC;wCAChD,GAAG,EAAE,UAAC,KAAK;4CACT,OAAA,IAAA,+BAAuB,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;wCAAvD,CAAuD;qCAC1D;iCACF;6BACF,CAAC,CAAC;;;4BAdL,KAAmB,IAAA,+BAAA,SAAA,WAAW,CAAA,CAAA,wCAAA;gCAAzB,IAAM,IAAI,wBAAA;wCAAJ,IAAI;6BAed;;;;;;;;;qBACF;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, node.parent),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,WAAW,EAAE,MAAM;Y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AAA,SAAA,WAAW,CAAA,CAAA,wCAAA;gCAAzB,IAAM,IAAI,wBAAA;wCAAJ,IAAI;6BAed;;;;;;;;;oBACH,CAAC;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, node.parent),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAC5D,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED,IAAM,4BAA4B,GAAG,UAAG,IAAA,sBAAc,EACpD,UAAU,CACX,mFAAyF,CAAC;QAC3F,IAAM,cAAc,GAAG,UAAG,IAAA,+BAAuB,EAC/C,UAAU,CACX,kDAAwD,CAAC;QAE1D,SAAS,gB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Tree } from '@typescript-eslint/experimental-utils';\nimport { isCallExpression, isIdentifier } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isMemberExpression,\n namedCallableExpression,\n pipeExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMapppingSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeWithSelectAndMapSelector = `${pipeExpression(\n storeNames\n )}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])` as const;\n const selectSelector = `${namedCallableExpression(\n storeNames\n )}[callee.object.callee.property.name='select']` as const;\n\n function isInCreateEffect(node: TSESTree.CallExpression) {\n let parent = node.parent;\n while (parent) {\n if (\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name === 'createEffect'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n\n let pipeHasThisExpression = false;\n\n const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;\n return {\n [`${selectorQuery} > CallExpression:has(ThisExpression)`](\n node: TSESTree.CallExpression\n ) {\n pipeHasThisExpression = true;\n },\n [`${selectorQuery}[callee.property.name=pipe]:exit`](\n node: TSESTree.CallExpression\n ) {\n if (pipeHasThisExpression) {\n pipeHasThisExpression = false;\n return;\n }\n\n if (isInCreateEffect(node)) {\n return;\n }\n\n const operators = node.arguments;\n const mapOperator = operators.find(\n (operator) =>\n isCallExpression(operator) &&\n isIdentifier(operator.callee) &&\n operator.callee.name === 'map'\n );\n if (mapOperator) {\n context.report({\n node: mapOperator,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAC5D,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAM,4BAA4B,GAAG,UAAG,IAAA,sBAAc,EACpD,UAAU,CACX,mFAAyF,CAAC;QAC3F,IAAM,cAAc,GAAG,UAAG,IAAA,+BAAuB,EAC/C,UAAU,CACX,kDAAwD,CAAC;QAE1D,SAAS,gBAAgB,CAAC,IAA6B;YACrD,IAAI,MAAM,GAAG,IAAI,CAAC,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type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { isCallExpression, isIdentifier } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isMemberExpression,\n namedCallableExpression,\n pipeExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMapppingSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeWithSelectAndMapSelector = `${pipeExpression(\n storeNames\n )}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])` as const;\n const selectSelector = `${namedCallableExpression(\n storeNames\n )}[callee.object.callee.property.name='select']` as const;\n\n function isInCreateEffect(node: TSESTree.CallExpression) {\n let parent = node.parent;\n while (parent) {\n if (\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name === 'createEffect'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n\n let pipeHasThisExpression = false;\n\n const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;\n return {\n [`${selectorQuery} > CallExpression:has(ThisExpression)`](\n node: TSESTree.CallExpression\n ) {\n pipeHasThisExpression = true;\n },\n [`${selectorQuery}[callee.property.name=pipe]:exit`](\n node: TSESTree.CallExpression\n ) {\n if (pipeHasThisExpression) {\n pipeHasThisExpression = false;\n return;\n }\n\n if (isInCreateEffect(node)) {\n return;\n }\n\n const operators = node.arguments;\n const mapOperator = operators.find(\n (operator) =>\n isCallExpression(operator) &&\n isIdentifier(operator.callee) &&\n operator.callee.name === 'map'\n );\n if (mapOperator) {\n context.report({\n node: mapOperator,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"good-action-hygiene.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/good-action-hygiene.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAuD;AAE1C,QAAA,SAAS,GAAG,mBAAmB,CAAC;AAK7C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,yCAAyC;YACtD,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0IAA0I;eAC7I;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,kBAAkB,GAAG,eAAe,CAAC;QAE3C;YACE,GAAC,gCAAwB,IAAzB,UAA2B,EAI1B;oBAHC,KAAA,uBAAiB,EAAL,IAAI,QAAA;gBAIR,IAAO,UAAU,GAAK,IAAI,MAAT,CAAU;gBAEnC,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;oBACvC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,UAAU,YAAA;qBACX;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { actionCreatorWithLiteral } from '../../utils';\n\nexport const messageId = 'goodActionHygiene';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Ensures the use of good action hygiene.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use \"[Source] {{ actionType }}\" to define action types.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceEventPattern = /[[].*[\\]]\\s.*/;\n\n return {\n [actionCreatorWithLiteral]({\n arguments: [node],\n }: Omit<TSESTree.CallExpression, 'arguments'> & {\n arguments: TSESTree.StringLiteral[];\n }) {\n const { value: actionType } = node;\n\n if (sourceEventPattern.test(actionType)) {\n return;\n }\n\n context.report({\n node,\n messageId,\n data: {\n actionType,\n },\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"good-action-hygiene.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/good-action-hygiene.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAuD;AAE1C,QAAA,SAAS,GAAG,mBAAmB,CAAC;AAK7C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,yCAAyC;YACtD,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0IAA0I;eAC7I;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,kBAAkB,GAAG,eAAe,CAAC;QAE3C;YACE,GAAC,gCAAwB,IAAzB,UAA2B,EAI1B;oBAHC,KAAA,uBAAiB,EAAL,IAAI,QAAA;gBAIR,IAAO,UAAU,GAAK,IAAI,MAAT,CAAU;gBAEnC,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBACxC,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,UAAU,YAAA;qBACX;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { actionCreatorWithLiteral } from '../../utils';\n\nexport const messageId = 'goodActionHygiene';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Ensures the use of good action hygiene.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use \"[Source] {{ actionType }}\" to define action types.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceEventPattern = /[[].*[\\]]\\s.*/;\n\n return {\n [actionCreatorWithLiteral]({\n arguments: [node],\n }: Omit<TSESTree.CallExpression, 'arguments'> & {\n arguments: TSESTree.StringLiteral[];\n }) {\n const { value: actionType } = node;\n\n if (sourceEventPattern.test(actionType)) {\n return;\n }\n\n context.report({\n node,\n messageId,\n data: {\n actionType,\n },\n });\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-multiple-global-stores.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-multiple-global-stores.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,CAAC;YAC/B,UAAU;kBACV,CAAC;IACL,CAAC,EACD,IAAI,GAAG,EAAE,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgRxStores,\n getNodeToCommaRemoveFix,\n isTSParameterProperty,\n} from '../../utils';\n\nexport const noMultipleGlobalStores = 'noMultipleGlobalStores';\nexport const noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';\n\ntype MessageIds =\n | typeof noMultipleGlobalStores\n | typeof noMultipleGlobalStoresSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'There should only be one global store injected.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noMultipleGlobalStores]: 'Global store should be injected only once.',\n [noMultipleGlobalStoresSuggest]: 'Remove this reference.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const flattenedIdentifiers = groupBy(identifiers).values();\n\n for (const identifiers of flattenedIdentifiers) {\n if (identifiers.length <= 1) {\n continue;\n }\n\n for (const node of identifiers) {\n const nodeToReport = getNodeToReport(node);\n context.report({\n node: nodeToReport,\n messageId: noMultipleGlobalStores,\n suggest: [\n {\n messageId: noMultipleGlobalStoresSuggest,\n fix: (fixer) => getFixes(sourceCode, fixer, nodeToReport),\n },\n ],\n });\n }\n }\n },\n };\n },\n});\n\nfunction getNodeToReport(node: TSESTree.Node) {\n return node.parent && isTSParameterProperty(node.parent) ? node.parent : node;\n}\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const { parent } = node;\n const nodeToRemove = parent && isTSParameterProperty(parent) ? parent : node;\n return getNodeToCommaRemoveFix(sourceCode, fixer, nodeToRemove);\n}\n\ntype Identifiers = NonNullable<ReturnType<typeof getNgRxStores>['identifiers']>;\n\nfunction groupBy(identifiers: Identifiers): Map<TSESTree.Node, Identifiers> {\n return identifiers.reduce<Map<TSESTree.Node, Identifiers>>(\n (accumulator, identifier) => {\n const parent = isTSParameterProperty(identifier.parent)\n ? identifier.parent.parent\n : identifier.parent;\n const collectedIdentifiers = accumulator.get(parent);\n return accumulator.set(parent, [\n ...(collectedIdentifiers ?? []),\n identifier,\n ]);\n },\n new Map()\n );\n}\n"]}
1
+ {"version":3,"file":"no-multiple-global-stores.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-multiple-global-stores.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AAER,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAO7E,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,8BAAsB,IAAG,4CAA4C;YACtE,GAAC,qCAA6B,IAAG,wBAAwB;eAC1D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,OAAO;;gBACC,IAAA,KAAmC,IAAA,qBAAa,EAAC,OAAO,CAAC,EAAvD,mBAAgB,EAAhB,WAAW,mBAA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,IAAI,CAAC;IAC7E,OAAO,IAAA,+BAAuB,EAAC,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AAClE,CAAC;AAID,SAAS,OAAO,CAAC,WAAwB;IACvC,OAAO,WAAW,CAAC,MAAM,CACvB,UAAC,WAAW,EAAE,UAAU;QACtB,IAAM,MAAM,GAAG,IAAA,6BAAqB,EAAC,UAAU,CAAC,MAAM,CAAC;YACrD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM;YAC1B,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;QACtB,IAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,GAAG,CAAC,MAAM,yCACxB,CAAC,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,EAAE,CAAC;YAC/B,UAAU;kBACV,CAAC;IACL,CAAC,EACD,IAAI,GAAG,EAAE,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgRxStores,\n getNodeToCommaRemoveFix,\n isTSParameterProperty,\n} from '../../utils';\n\nexport const noMultipleGlobalStores = 'noMultipleGlobalStores';\nexport const noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';\n\ntype MessageIds =\n | typeof noMultipleGlobalStores\n | typeof noMultipleGlobalStoresSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'There should only be one global store injected.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noMultipleGlobalStores]: 'Global store should be injected only once.',\n [noMultipleGlobalStoresSuggest]: 'Remove this reference.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const flattenedIdentifiers = groupBy(identifiers).values();\n\n for (const identifiers of flattenedIdentifiers) {\n if (identifiers.length <= 1) {\n continue;\n }\n\n for (const node of identifiers) {\n const nodeToReport = getNodeToReport(node);\n context.report({\n node: nodeToReport,\n messageId: noMultipleGlobalStores,\n suggest: [\n {\n messageId: noMultipleGlobalStoresSuggest,\n fix: (fixer) => getFixes(sourceCode, fixer, nodeToReport),\n },\n ],\n });\n }\n }\n },\n };\n },\n});\n\nfunction getNodeToReport(node: TSESTree.Node) {\n return node.parent && isTSParameterProperty(node.parent) ? node.parent : node;\n}\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const { parent } = node;\n const nodeToRemove = parent && isTSParameterProperty(parent) ? parent : node;\n return getNodeToCommaRemoveFix(sourceCode, fixer, nodeToRemove);\n}\n\ntype Identifiers = NonNullable<ReturnType<typeof getNgRxStores>['identifiers']>;\n\nfunction groupBy(identifiers: Identifiers): Map<TSESTree.Node, Identifiers> {\n return identifiers.reduce<Map<TSESTree.Node, Identifiers>>(\n (accumulator, identifier) => {\n const parent = isTSParameterProperty(identifier.parent)\n ? identifier.parent.parent\n : identifier.parent;\n const collectedIdentifiers = accumulator.get(parent);\n return accumulator.set(parent, [\n ...(collectedIdentifiers ?? []),\n identifier,\n ]);\n },\n new Map()\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-reducer-in-key-names.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-reducer-in-key-names.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAOvE,IAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAmB,cAAc,yBAAqB;YACnE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,2BAAmB,IAAG,2BAAmB,cAAc,uDAAmD;YAC3G,GAAC,kCAA0B,IAAG,4BAAoB,cAAc,QAAI;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,mBAAY,6BAAqB,eAAK,wBAAgB,iBAAO,IAAA,wBAAgB,EAC5E,UAAU,CACX,YAAS,IAFV,UAEY,IAA8B;gBACxC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,UAAC,KAAK;gCACT,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;gCAEjC,IAAI,CAAC,OAAO,EAAE;oCACZ,OAAO,IAAI,CAAC;iCACb;gCAED,OAAO,KAAK,CAAC,WAAW,CACtB,IAAI,EACJ,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CACrD,CAAC;4BACJ,CAAC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n actionReducerMap,\n getRawText,\n metadataProperty,\n storeActionReducerMap,\n} from '../../utils';\n\nexport const noReducerInKeyNames = 'noReducerInKeyNames';\nexport const noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';\n\ntype MessageIds =\n | typeof noReducerInKeyNames\n | typeof noReducerInKeyNamesSuggest;\ntype Options = readonly [];\n\nconst reducerKeyword = 'reducer';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: `Avoid the word \"${reducerKeyword}\" in the key names.`,\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noReducerInKeyNames]: `Avoid the word \"${reducerKeyword}\" in the key names to better represent the state.`,\n [noReducerInKeyNamesSuggest]: `Remove the word \"${reducerKeyword}\".`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`:matches(${storeActionReducerMap}, ${actionReducerMap}) > ${metadataProperty(\n /reducer/i\n )} > .key`](node: TSESTree.Property['key']) {\n context.report({\n node,\n messageId: noReducerInKeyNames,\n suggest: [\n {\n messageId: noReducerInKeyNamesSuggest,\n fix: (fixer) => {\n const keyName = getRawText(node);\n\n if (!keyName) {\n return null;\n }\n\n return fixer.replaceText(\n node,\n keyName.replace(new RegExp(reducerKeyword, 'i'), '')\n );\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"no-reducer-in-key-names.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-reducer-in-key-names.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAOvE,IAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAmB,cAAc,yBAAqB;YACnE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,2BAAmB,IAAG,2BAAmB,cAAc,uDAAmD;YAC3G,GAAC,kCAA0B,IAAG,4BAAoB,cAAc,QAAI;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,mBAAY,6BAAqB,eAAK,wBAAgB,iBAAO,IAAA,wBAAgB,EAC5E,UAAU,CACX,YAAS,IAFV,UAEY,IAA8B;gBACxC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,UAAC,KAAK;gCACT,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;gCAEjC,IAAI,CAAC,OAAO,EAAE,CAAC;oCACb,OAAO,IAAI,CAAC;gCACd,CAAC;gCAED,OAAO,KAAK,CAAC,WAAW,CACtB,IAAI,EACJ,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CACrD,CAAC;4BACJ,CAAC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n actionReducerMap,\n getRawText,\n metadataProperty,\n storeActionReducerMap,\n} from '../../utils';\n\nexport const noReducerInKeyNames = 'noReducerInKeyNames';\nexport const noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';\n\ntype MessageIds =\n | typeof noReducerInKeyNames\n | typeof noReducerInKeyNamesSuggest;\ntype Options = readonly [];\n\nconst reducerKeyword = 'reducer';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: `Avoid the word \"${reducerKeyword}\" in the key names.`,\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noReducerInKeyNames]: `Avoid the word \"${reducerKeyword}\" in the key names to better represent the state.`,\n [noReducerInKeyNamesSuggest]: `Remove the word \"${reducerKeyword}\".`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`:matches(${storeActionReducerMap}, ${actionReducerMap}) > ${metadataProperty(\n /reducer/i\n )} > .key`](node: TSESTree.Property['key']) {\n context.report({\n node,\n messageId: noReducerInKeyNames,\n suggest: [\n {\n messageId: noReducerInKeyNamesSuggest,\n fix: (fixer) => {\n const keyName = getRawText(node);\n\n if (!keyName) {\n return null;\n }\n\n return fixer.replaceText(\n node,\n keyName.replace(new RegExp(reducerKeyword, 'i'), '')\n );\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-store-subscription.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-store-subscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAgF;AAEnE,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAK/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,kEAAkE;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,+BAAuB,EACzB,UAAU,CACX,uDAAoD,IAFrD,UAGE,IAAyB;gBAEzB,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, getNgRxStores, namedCallableExpression } from '../../utils';\n\nexport const messageId = 'noStoreSubscription';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using the `async` pipe is preferred over `store` subscription.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n '`Store` subscription is forbidden. Use the `async` pipe instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${namedCallableExpression(\n storeNames\n )} > MemberExpression > Identifier[name='subscribe']`](\n node: TSESTree.Identifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"no-store-subscription.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-store-subscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAgF;AAEnE,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAK/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,kEAAkE;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED;YACE,GAAC,UAAG,IAAA,+BAAuB,EACzB,UAAU,CACX,uDAAoD,IAFrD,UAGE,IAAyB;gBAEzB,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, getNgRxStores, namedCallableExpression } from '../../utils';\n\nexport const messageId = 'noStoreSubscription';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using the `async` pipe is preferred over `store` subscription.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n '`Store` subscription is forbidden. Use the `async` pipe instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${namedCallableExpression(\n storeNames\n )} > MemberExpression > Identifier[name='subscribe']`](\n node: TSESTree.Identifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"no-typed-global-store.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-typed-global-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAGR,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,oBAAY,IACX,qEAAqE;YACvE,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BAAmB;wBAC9B,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,EAA5B,CAA4B;qBAC7C;iBACF;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgRxStores,\n isPropertyDefinition,\n isTSTypeReference,\n isCallExpression,\n isTSInstantiationExpression,\n} from '../../utils';\nimport type { TSESTree } from '@typescript-eslint/experimental-utils';\n\nexport const noTypedStore = 'noTypedStore';\nexport const noTypedStoreSuggest = 'noTypedStoreSuggest';\n\ntype MessageIds = typeof noTypedStore | typeof noTypedStoreSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'The global store should not be typed.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noTypedStore]:\n '`Store` should not be typed, use `Store` (without generic) instead.',\n [noTypedStoreSuggest]: 'Remove generic from `Store`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const identifier of identifiers) {\n // using inject()\n if (!identifier.typeAnnotation) {\n const { parent } = identifier;\n if (\n isPropertyDefinition(parent) &&\n parent.value &&\n isCallExpression(parent.value) &&\n parent.value.arguments.length\n ) {\n const [storeArgument] = parent.value.arguments;\n if (isTSInstantiationExpression(storeArgument)) {\n report(storeArgument.typeParameters);\n }\n }\n\n continue;\n }\n\n if (\n !isTSTypeReference(identifier.typeAnnotation.typeAnnotation) ||\n !identifier.typeAnnotation.typeAnnotation.typeParameters\n ) {\n continue;\n }\n\n report(identifier.typeAnnotation.typeAnnotation.typeParameters);\n }\n },\n };\n\n function report(typeParameters: TSESTree.TSTypeParameterInstantiation) {\n context.report({\n node: typeParameters,\n messageId: noTypedStore,\n suggest: [\n {\n messageId: noTypedStoreSuggest,\n fix: (fixer) => fixer.remove(typeParameters),\n },\n ],\n });\n }\n },\n});\n"]}
1
+ {"version":3,"file":"no-typed-global-store.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-typed-global-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAGR,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,oBAAY,IACX,qEAAqE;YACvE,GAAC,2BAAmB,IAAG,8BAA8B;eACtD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,OAAO;;gBACG,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;;oBAEpD,KAAyB,IAAA,gBAAA,SAAA,WAAW,CAAA,wCAAA,iEAAE,CAAC;wBAAlC,IAAM,UAAU,wBAAA;wBACnB,iBAAiB;wBACjB,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;4BACvB,IAAA,QAAM,GAAK,UAAU,OAAf,CAAgB;4BAC9B,IACE,IAAA,4BAAoB,EAAC,QAAM,CAAC;gCAC5B,QAAM,CAAC,KAAK;gCACZ,IAAA,wBAAgB,EAAC,QAAM,CAAC,KAAK,CAAC;gCAC9B,QAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAC7B,CAAC;gCACK,IAAA,KAAA,OAAkB,QAAM,CAAC,KAAK,CAAC,SAAS,IAAA,EAAvC,aAAa,QAA0B,CAAC;gCAC/C,IAAI,IAAA,mCAA2B,EAAC,aAAa,CAAC,EAAE,CAAC;oCAC/C,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;gCACvC,CAAC;4BACH,CAAC;4BAED,SAAS;wBACX,CAAC;wBAED,IACE,CAAC,IAAA,yBAAiB,EAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC;4BAC5D,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,EACxD,CAAC;4BACD,SAAS;wBACX,CAAC;wBAED,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;oBAClE,CAAC;;;;;;;;;YACH,CAAC;SACF,CAAC;QAEF,SAAS,MAAM,CAAC,cAAqD;YACnE,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,cAAc;gBACpB,SAAS,EAAE,oBAAY;gBACvB,OAAO,EAAE;oBACP;wBACE,SAAS,EAAE,2BAAmB;wBAC9B,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,EAA5B,CAA4B;qBAC7C;iBACF;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgRxStores,\n isPropertyDefinition,\n isTSTypeReference,\n isCallExpression,\n isTSInstantiationExpression,\n} from '../../utils';\nimport type { TSESTree } from '@typescript-eslint/experimental-utils';\n\nexport const noTypedStore = 'noTypedStore';\nexport const noTypedStoreSuggest = 'noTypedStoreSuggest';\n\ntype MessageIds = typeof noTypedStore | typeof noTypedStoreSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'The global store should not be typed.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noTypedStore]:\n '`Store` should not be typed, use `Store` (without generic) instead.',\n [noTypedStoreSuggest]: 'Remove generic from `Store`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const identifier of identifiers) {\n // using inject()\n if (!identifier.typeAnnotation) {\n const { parent } = identifier;\n if (\n isPropertyDefinition(parent) &&\n parent.value &&\n isCallExpression(parent.value) &&\n parent.value.arguments.length\n ) {\n const [storeArgument] = parent.value.arguments;\n if (isTSInstantiationExpression(storeArgument)) {\n report(storeArgument.typeParameters);\n }\n }\n\n continue;\n }\n\n if (\n !isTSTypeReference(identifier.typeAnnotation.typeAnnotation) ||\n !identifier.typeAnnotation.typeAnnotation.typeParameters\n ) {\n continue;\n }\n\n report(identifier.typeAnnotation.typeAnnotation.typeParameters);\n }\n },\n };\n\n function report(typeParameters: TSESTree.TSTypeParameterInstantiation) {\n context.report({\n node: typeParameters,\n messageId: noTypedStore,\n suggest: [\n {\n messageId: noTypedStoreSuggest,\n fix: (fixer) => fixer.remove(typeParameters),\n },\n ],\n });\n }\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAA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;IAC5B,IAAM,SAAS,GAAG,IAAA,eAAO,EAAC,MAAM,CAAC,CAAC;IAClC,IAAM,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC5D,IAAM,eAAe,GACnB,aAAa,IAAI,6BAAQ,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAE/D,IAAI,eAAe,EAAE;QACnB,IAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS,EAAE,SAAS,CAAC,CAAC;KACjE;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC;QACvC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;KACpC,CAAC;AACb,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getLast, onFunctionWithoutType } from '../../utils';\n\nexport const onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';\nexport const onFunctionExplicitReturnTypeSuggest =\n 'onFunctionExplicitReturnTypeSuggest';\n\ntype MessageIds =\n | typeof onFunctionExplicitReturnType\n | typeof onFunctionExplicitReturnTypeSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: '`On` function should have an explicit return type.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [onFunctionExplicitReturnType]:\n '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',\n [onFunctionExplicitReturnTypeSuggest]:\n 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n\n return {\n [onFunctionWithoutType](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId: onFunctionExplicitReturnType,\n suggest: [\n {\n messageId: onFunctionExplicitReturnTypeSuggest,\n fix: (fixer) => getFixes(node, sourceCode, fixer),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getFixes(\n node: TSESTree.ArrowFunctionExpression,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n) {\n const { params } = node;\n\n if (params.length === 0) {\n const [, closingParen] = sourceCode.getTokens(node);\n return fixer.insertTextAfter(closingParen, ': State');\n }\n\n const [firstParam] = params;\n const lastParam = getLast(params);\n const previousToken = sourceCode.getTokenBefore(firstParam);\n const isParenthesized =\n previousToken && ASTUtils.isOpeningParenToken(previousToken);\n\n if (isParenthesized) {\n const nextToken = sourceCode.getTokenAfter(lastParam);\n return fixer.insertTextAfter(nextToken ?? lastParam, ': State');\n }\n\n return [\n fixer.insertTextBefore(firstParam, '('),\n fixer.insertTextAfter(lastParam, '): State'),\n ] as const;\n}\n"]}
1
+ {"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;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CAAC;IAE/D,IAAI,eAAe,EAAE,CAAC;QACpB,IAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC;QACvC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;KACpC,CAAC;AACb,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getLast, onFunctionWithoutType } from '../../utils';\n\nexport const onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';\nexport const onFunctionExplicitReturnTypeSuggest =\n 'onFunctionExplicitReturnTypeSuggest';\n\ntype MessageIds =\n | typeof onFunctionExplicitReturnType\n | typeof onFunctionExplicitReturnTypeSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: '`On` function should have an explicit return type.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [onFunctionExplicitReturnType]:\n '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',\n [onFunctionExplicitReturnTypeSuggest]:\n 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n\n return {\n [onFunctionWithoutType](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId: onFunctionExplicitReturnType,\n suggest: [\n {\n messageId: onFunctionExplicitReturnTypeSuggest,\n fix: (fixer) => getFixes(node, sourceCode, fixer),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getFixes(\n node: TSESTree.ArrowFunctionExpression,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n) {\n const { params } = node;\n\n if (params.length === 0) {\n const [, closingParen] = sourceCode.getTokens(node);\n return fixer.insertTextAfter(closingParen, ': State');\n }\n\n const [firstParam] = params;\n const lastParam = getLast(params);\n const previousToken = sourceCode.getTokenBefore(firstParam);\n const isParenthesized =\n previousToken && ASTUtils.isOpeningParenToken(previousToken);\n\n if (isParenthesized) {\n const nextToken = sourceCode.getTokenAfter(lastParam);\n return fixer.insertTextAfter(nextToken ?? lastParam, ': State');\n }\n\n return [\n fixer.insertTextBefore(firstParam, '('),\n fixer.insertTextAfter(lastParam, '): State'),\n ] as const;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-action-creator-in-dispatch.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator-in-dispatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,+BAA+B,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,4EAA4E;eAC/E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,0BAAkB,EACpB,UAAU,CACX,qEAAkE,IAFnE,UAGE,IAAwD;gBAExD,IAAM,0BAA0B,GAAG,IAAA,+BAAuB,EACxD,IAAI,EACJ,wBAAgB,CACjB,CAAC;gBACF,IAAM,8BAA8B,GAClC,0BAA0B,KAAK,SAAS;oBACxC,IAAA,4BAAoB,EAClB,0BAA0B,EAC1B,UAAU,EACV,UAAU,CACX,CAAC;gBAEJ,IAAI,CAAC,8BAA8B,EAAE;oBACnC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n dispatchExpression,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isCallExpressionWith,\n} from '../../utils';\n\nexport const messageId = 'preferActionCreatorInDispatch';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using `action creator` in `dispatch` is preferred over `object` or old `Action`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `object` or old `Action` is forbidden. Use `action creator` instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${dispatchExpression(\n storeNames\n )} :matches(NewExpression, :not(NewExpression) > ObjectExpression)`](\n node: TSESTree.NewExpression | TSESTree.ObjectExpression\n ) {\n const nearestUpperCallExpression = getNearestUpperNodeFrom(\n node,\n isCallExpression\n );\n const isStoreDispatchImmediateParent =\n nearestUpperCallExpression !== undefined &&\n isCallExpressionWith(\n nearestUpperCallExpression,\n storeNames,\n 'dispatch'\n );\n\n if (!isStoreDispatchImmediateParent) {\n return;\n }\n\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"prefer-action-creator-in-dispatch.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator-in-dispatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,+BAA+B,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,4EAA4E;eAC/E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED;YACE,GAAC,UAAG,IAAA,0BAAkB,EACpB,UAAU,CACX,qEAAkE,IAFnE,UAGE,IAAwD;gBAExD,IAAM,0BAA0B,GAAG,IAAA,+BAAuB,EACxD,IAAI,EACJ,wBAAgB,CACjB,CAAC;gBACF,IAAM,8BAA8B,GAClC,0BAA0B,KAAK,SAAS;oBACxC,IAAA,4BAAoB,EAClB,0BAA0B,EAC1B,UAAU,EACV,UAAU,CACX,CAAC;gBAEJ,IAAI,CAAC,8BAA8B,EAAE,CAAC;oBACpC,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n dispatchExpression,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isCallExpressionWith,\n} from '../../utils';\n\nexport const messageId = 'preferActionCreatorInDispatch';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using `action creator` in `dispatch` is preferred over `object` or old `Action`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `object` or old `Action` is forbidden. Use `action creator` instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${dispatchExpression(\n storeNames\n )} :matches(NewExpression, :not(NewExpression) > ObjectExpression)`](\n node: TSESTree.NewExpression | TSESTree.ObjectExpression\n ) {\n const nearestUpperCallExpression = getNearestUpperNodeFrom(\n node,\n isCallExpression\n );\n const isStoreDispatchImmediateParent =\n nearestUpperCallExpression !== undefined &&\n isCallExpressionWith(\n nearestUpperCallExpression,\n storeNames,\n 'dispatch'\n );\n\n if (!isStoreDispatchImmediateParent) {\n return;\n }\n\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-selector-in-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-selector-in-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAQqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0EAA0E;eAC7E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,sBAAc,EAAC,UAAU,CAAC,eAAK,IAAA,wBAAgB,EAAC,UAAU,CAAC,CAAE,IAAjE,UACE,IAA6B;;;oBAE7B,KAAuB,IAAA,KAAA,SAAA,IAAI,CAAC,SAAS,CAAA,gBAAA,4BAAE;wBAAlC,IAAM,QAAQ,WAAA;wBACjB,IACE,CAAC,IAAA,iBAAS,EAAC,QAAQ,CAAC;4BACpB,CAAC,IAAA,iCAAyB,EAAC,QAAQ,CAAC;4BACpC,CAAC,IAAA,4BAAoB,EAAC,QAAQ,CAAC,EAC/B;4BACA,MAAM;yBACP;wBAED,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,QAAQ;4BACd,SAAS,mBAAA;yBACV,CAAC,CAAC;qBACJ;;;;;;;;;YACH,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isArrowFunctionExpression,\n isFunctionExpression,\n isLiteral,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'preferSelectorInSelect';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using a selector in the `select` is preferred over `string` or `props drilling`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `string` or `props drilling` is forbidden. Use a selector instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${pipeableSelect(storeNames)}, ${selectExpression(storeNames)}`](\n node: TSESTree.CallExpression\n ) {\n for (const argument of node.arguments) {\n if (\n !isLiteral(argument) &&\n !isArrowFunctionExpression(argument) &&\n !isFunctionExpression(argument)\n ) {\n break;\n }\n\n context.report({\n node: argument,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"prefer-selector-in-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-selector-in-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAQqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0EAA0E;eAC7E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED;YACE,GAAC,UAAG,IAAA,sBAAc,EAAC,UAAU,CAAC,eAAK,IAAA,wBAAgB,EAAC,UAAU,CAAC,CAAE,IAAjE,UACE,IAA6B;;;oBAE7B,KAAuB,IAAA,KAAA,SAAA,IAAI,CAAC,SAAS,CAAA,gBAAA,4BAAE,CAAC;wBAAnC,IAAM,QAAQ,WAAA;wBACjB,IACE,CAAC,IAAA,iBAAS,EAAC,QAAQ,CAAC;4BACpB,CAAC,IAAA,iCAAyB,EAAC,QAAQ,CAAC;4BACpC,CAAC,IAAA,4BAAoB,EAAC,QAAQ,CAAC,EAC/B,CAAC;4BACD,MAAM;wBACR,CAAC;wBAED,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,QAAQ;4BACd,SAAS,mBAAA;yBACV,CAAC,CAAC;oBACL,CAAC;;;;;;;;;YACH,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isArrowFunctionExpression,\n isFunctionExpression,\n isLiteral,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'preferSelectorInSelect';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using a selector in the `select` is preferred over `string` or `props drilling`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `string` or `props drilling` is forbidden. Use a selector instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${pipeableSelect(storeNames)}, ${selectExpression(storeNames)}`](\n node: TSESTree.CallExpression\n ) {\n for (const argument of node.arguments) {\n if (\n !isLiteral(argument) &&\n !isArrowFunctionExpression(argument) &&\n !isFunctionExpression(argument)\n ) {\n break;\n }\n\n context.report({\n node: argument,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefix-selectors-with-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA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KAAK,CAAC,CAAC,CAAC,EAAE,MAAA,MAAA,EAAE,CAAC,cAAc,0CAAE,KAAK,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzD,aAAa,CACd,CAAA;6BAAA;yBACJ;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAM,UAAU,GAAG,QAAQ,CAAC;IAC5B,yCAAyC;IACzC,IAAI,oBAAoB,GAAG,IAAI,CAAC,OAAO,CACrC,IAAI,MAAM,CAAC,WAAI,UAAU,SAAM,CAAC,EAChC,UAAC,CAAC,EAAE,IAAY;QACd,OAAO,UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;IAC5C,CAAC,CACF,CAAC;IAEF,IAAI,IAAI,KAAK,oBAAoB,EAAE;QACjC,OAAO,oBAAoB,CAAC;KAC7B;IAED,kCAAkC;IAClC,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAC,CAAC,EAAE,IAAY;QACpE,OAAO,UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,KAAK,oBAAoB,EAAE;QACjC,OAAO,oBAAoB,CAAC;KAC7B;IAED,6BAA6B;IAC7B,OAAO,UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;AAC5C,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { capitalize } from '../../utils';\n\nexport const prefixSelectorsWithSelect = 'prefixSelectorsWithSelect';\nexport const prefixSelectorsWithSelectSuggest =\n 'prefixSelectorsWithSelectSuggest';\n\ntype MessageIds =\n | typeof prefixSelectorsWithSelect\n | typeof prefixSelectorsWithSelectSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description:\n 'The selector should start with \"select\", for example \"selectThing\".',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [prefixSelectorsWithSelect]: 'The selector should start with \"select\".',\n [prefixSelectorsWithSelectSuggest]:\n 'Prefix the selector with \"select\": `{{ name }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n 'VariableDeclarator[id.name!=/^select[^a-z].+$/]:not(:has(Identifier[name=\"createFeature\"])):matches([id.typeAnnotation.typeAnnotation.typeName.name=/^MemoizedSelector(WithProps)?$/], :has(CallExpression[callee.name=/^(create(Feature)?Selector|createSelectorFactory)$/]))'({\n id,\n }: TSESTree.VariableDeclarator & { id: TSESTree.Identifier }) {\n const suggestedName = getSuggestedName(id.name);\n context.report({\n loc: {\n ...id.loc,\n end: {\n ...id.loc.end,\n column: id.typeAnnotation?.range[0]\n ? id.typeAnnotation.range[0] - 1\n : id.loc.end.column,\n },\n },\n messageId: prefixSelectorsWithSelect,\n suggest: [\n {\n messageId: prefixSelectorsWithSelectSuggest,\n data: {\n name: suggestedName,\n },\n fix: (fixer) =>\n fixer.replaceTextRange(\n [id.range[0], id.typeAnnotation?.range[0] ?? id.range[1]],\n suggestedName\n ),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getSuggestedName(name: string) {\n const selectWord = 'select';\n // Ex: 'selectfeature' => 'selectFeature'\n let possibleReplacedName = name.replace(\n new RegExp(`^${selectWord}(.+)`),\n (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n }\n );\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'getCount' => 'selectCount'\n possibleReplacedName = name.replace(/^get([^a-z].+)/, (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n });\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'item' => 'selectItem'\n return `${selectWord}${capitalize(name)}`;\n}\n"]}
1
+ {"version":3,"file":"prefix-selectors-with-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAyC;AAE5B,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,gCAAgC,GAC3C,kCAAkC,CAAC;AAOrC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,qEAAqE;YACvE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iCAAyB,IAAG,0CAA0C;YACvE,GAAC,wCAAgC,IAC/B,kDAAkD;eACrD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,gRAAgR,YAAC,EAErN;;oBAD1D,EAAE,QAAA;gBAEF,IAAM,aAAa,GAAG,gBAAgB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,GAAG,wBACE,EAAE,CAAC,GAAG,KACT,GAAG,wBACE,EAAE,CAAC,GAAG,CAAC,GAAG,KACb,MAAM,EAAE,CAAA,MAAA,EAAE,CAAC,cAAc,0CAAE,KAAK,CAAC,CAAC,CAAC;gCACjC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;g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UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;AAC5C,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { capitalize } from '../../utils';\n\nexport const prefixSelectorsWithSelect = 'prefixSelectorsWithSelect';\nexport const prefixSelectorsWithSelectSuggest =\n 'prefixSelectorsWithSelectSuggest';\n\ntype MessageIds =\n | typeof prefixSelectorsWithSelect\n | typeof prefixSelectorsWithSelectSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description:\n 'The selector should start with \"select\", for example \"selectThing\".',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [prefixSelectorsWithSelect]: 'The selector should start with \"select\".',\n [prefixSelectorsWithSelectSuggest]:\n 'Prefix the selector with \"select\": `{{ name }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n 'VariableDeclarator[id.name!=/^select[^a-z].+$/]:not(:has(Identifier[name=\"createFeature\"])):matches([id.typeAnnotation.typeAnnotation.typeName.name=/^MemoizedSelector(WithProps)?$/], :has(CallExpression[callee.name=/^(create(Feature)?Selector|createSelectorFactory)$/]))'({\n id,\n }: TSESTree.VariableDeclarator & { id: TSESTree.Identifier }) {\n const suggestedName = getSuggestedName(id.name);\n context.report({\n loc: {\n ...id.loc,\n end: {\n ...id.loc.end,\n column: id.typeAnnotation?.range[0]\n ? id.typeAnnotation.range[0] - 1\n : id.loc.end.column,\n },\n },\n messageId: prefixSelectorsWithSelect,\n suggest: [\n {\n messageId: prefixSelectorsWithSelectSuggest,\n data: {\n name: suggestedName,\n },\n fix: (fixer) =>\n fixer.replaceTextRange(\n [id.range[0], id.typeAnnotation?.range[0] ?? id.range[1]],\n suggestedName\n ),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getSuggestedName(name: string) {\n const selectWord = 'select';\n // Ex: 'selectfeature' => 'selectFeature'\n let possibleReplacedName = name.replace(\n new RegExp(`^${selectWord}(.+)`),\n (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n }\n );\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'getCount' => 'selectCount'\n possibleReplacedName = name.replace(/^get([^a-z].+)/, (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n });\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'item' => 'selectItem'\n return `${selectWord}${capitalize(name)}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"select-style.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/select-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAYqB;AAER,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAwB/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,0EAA0C;gBAChD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ;YACN,wCACE,4EAA4E;YAC9E,4CACE,0FAA0F;eAC7F;KACF;IACD,cAAc,EAAE,mCAAoB;IACpC,MAAM,EAAE,UAAC,OAAO,EAAE,EAAM;;YAAN,KAAA,aAAM,EAAL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AsB,EAAE;QAC3B,IAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACjD,IAAM,oBAAoB,GAAG,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9D,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;QACtC;YACE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;kBACjB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,WAAI,aAAa,CAAE,CAAC;kBACjD;KACH;IAEO,IAAA,QAAQ,GAAK,SAAS,CAAC,MAAM,SAArB,CAAsB;IACtC,IAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAA,KAAA,OAAmC,QAAQ,CAAC,KAAK,IAAA,EAAhD,gBAAgB,QAAA,EAAE,YAAY,QAAkB,CAAC;IACxD,IAAM,SAAS,GAAmB;QAChC,gBAAgB;QAChB,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,KAAK,CAAC,CAAC,CAAC,mCAAI,YAAY;KAC7C,CAAC;IACI,IAAA,KAAA,OAAqB,UAAU,CAAC,KAAK,IAAA,EAAlC,cAAc,QAAoB,CAAC;IAC5C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;QAC5B,KAAK,CAAC,oBAAoB,CAAC,CAAC,cAAc,EAAE,cAAc,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getImportAddFix,\n getImportRemoveFix,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isClassDeclaration,\n isMemberExpression,\n NGRX_MODULE_PATHS,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const selectMethod = 'selectMethod';\nexport const selectOperator = 'selectOperator';\n\nexport const enum SelectStyle {\n Method = 'method',\n Operator = 'operator',\n}\n\ntype MessageIds = `${SelectStyle}`;\ntype Options = readonly [MessageIds];\ntype MemberExpressionWithProperty = Omit<\n TSESTree.MemberExpression,\n 'property'\n> & {\n property: TSESTree.Identifier;\n};\ntype CallExpression = Omit<TSESTree.CallExpression, 'parent'> & {\n callee: MemberExpressionWithProperty;\n parent: TSESTree.CallExpression & {\n callee: Omit<TSESTree.MemberExpression, 'object'> & {\n object: MemberExpressionWithProperty;\n };\n };\n};\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Selector can be used either with `select` as a pipeable operator or as a method.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'string',\n enum: [SelectStyle.Method, SelectStyle.Operator],\n additionalProperties: false,\n },\n ],\n messages: {\n [SelectStyle.Method]:\n 'Selector should be used with select method: `this.store.select(selector)`.',\n [SelectStyle.Operator]:\n 'Selector should be used with the pipeable operator: `this.store.pipe(select(selector))`.',\n },\n },\n defaultOptions: [SelectStyle.Method],\n create: (context, [mode]) => {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n if (mode === SelectStyle.Operator) {\n return {\n [selectExpression(storeNames)](node: CallExpression) {\n context.report({\n node: node.callee.property,\n messageId: SelectStyle.Operator,\n fix: (fixer) => getMethodToOperatorFixes(node, fixer),\n });\n },\n };\n }\n\n return {\n [`Program:has(${pipeableSelect(\n storeNames\n )}) ImportDeclaration[source.value='${\n NGRX_MODULE_PATHS.store\n }'] > ImportSpecifier[imported.name='select']`](\n node: TSESTree.ImportSpecifier & {\n parent: TSESTree.ImportDeclaration;\n }\n ) {\n context.report({\n node,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getImportRemoveFix(sourceCode, [node.parent], 'select', fixer),\n });\n\n const [{ references }] = context.getDeclaredVariables(node);\n\n for (const { identifier } of references) {\n context.report({\n node: identifier,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getOperatorToMethodFixes(identifier, sourceCode, fixer),\n });\n }\n },\n };\n },\n});\n\nfunction getMethodToOperatorFixes(\n node: CallExpression,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const classDeclaration = getNearestUpperNodeFrom(node, isClassDeclaration);\n\n if (!classDeclaration) {\n return [];\n }\n\n return [\n fixer.insertTextBefore(node.callee.property, 'pipe('),\n fixer.insertTextAfter(node, ')'),\n ].concat(\n getImportAddFix({\n fixer,\n importName: 'select',\n moduleName: NGRX_MODULE_PATHS.store,\n node: classDeclaration,\n })\n );\n}\n\nfunction getOperatorToMethodFixes(\n identifier: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const select = identifier.parent;\n const storePipe = select?.parent;\n\n if (\n !storePipe ||\n !isCallExpression(storePipe) ||\n !isMemberExpression(storePipe.callee)\n ) {\n return [];\n }\n\n const pipeContainsOnlySelect = storePipe.arguments.length === 1;\n\n if (!pipeContainsOnlySelect) {\n const selectContent = sourceCode.getText(select);\n const nextTokenAfterSelect = sourceCode.getTokenAfter(select);\n const store = storePipe.callee.object;\n return [\n fixer.remove(select),\n ...(nextTokenAfterSelect ? [fixer.remove(nextTokenAfterSelect)] : []),\n fixer.insertTextAfter(store, `.${selectContent}`),\n ];\n }\n\n const { property } = storePipe.callee;\n const nextTokenAfterPipe = sourceCode.getTokenAfter(property);\n const [pipeInitialRange, pipeEndRange] = property.range;\n const pipeRange: TSESTree.Range = [\n pipeInitialRange,\n nextTokenAfterPipe?.range[1] ?? pipeEndRange,\n ];\n const [, selectEndRange] = identifier.range;\n return [\n fixer.removeRange(pipeRange),\n fixer.insertTextAfterRange([selectEndRange, selectEndRange + 1], '('),\n ];\n}\n"]}
1
+ {"version":3,"file":"select-style.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/select-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAYqB;AAER,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAwB/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,0EAA0C;gBAChD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ;YACN,wCACE,4EAA4E;YAC9E,4CACE,0FAA0F;eAC7F;KACF;IACD,cAAc,EAAE,mCAAoB;IACpC,MAAM,EAAE,UAAC,OAAO,EAAE,EAAM;;YAAN,KAAA,aAAM,EAAL,IAAI,QAAA;QACf,IAAA,KAAmC,IAAA,qBAAa,EAAC,OAAO,CAAC,EAAvD,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA,EAAE,UAAU,gBAA2B,CAAC;QAChE,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EA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AAC,MAAM,CAAC;kBACjB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,WAAI,aAAa,CAAE,CAAC;kBACjD;IACJ,CAAC;IAEO,IAAA,QAAQ,GAAK,SAAS,CAAC,MAAM,SAArB,CAAsB;IACtC,IAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAA,KAAA,OAAmC,QAAQ,CAAC,KAAK,IAAA,EAAhD,gBAAgB,QAAA,EAAE,YAAY,QAAkB,CAAC;IACxD,IAAM,SAAS,GAAmB;QAChC,gBAAgB;QAChB,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,KAAK,CAAC,CAAC,CAAC,mCAAI,YAAY;KAC7C,CAAC;IACI,IAAA,KAAA,OAAqB,UAAU,CAAC,KAAK,IAAA,EAAlC,cAAc,QAAoB,CAAC;IAC5C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;QAC5B,KAAK,CAAC,oBAAoB,CAAC,CAAC,cAAc,EAAE,cAAc,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getImportAddFix,\n getImportRemoveFix,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isClassDeclaration,\n isMemberExpression,\n NGRX_MODULE_PATHS,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const selectMethod = 'selectMethod';\nexport const selectOperator = 'selectOperator';\n\nexport const enum SelectStyle {\n Method = 'method',\n Operator = 'operator',\n}\n\ntype MessageIds = `${SelectStyle}`;\ntype Options = readonly [MessageIds];\ntype MemberExpressionWithProperty = Omit<\n TSESTree.MemberExpression,\n 'property'\n> & {\n property: TSESTree.Identifier;\n};\ntype CallExpression = Omit<TSESTree.CallExpression, 'parent'> & {\n callee: MemberExpressionWithProperty;\n parent: TSESTree.CallExpression & {\n callee: Omit<TSESTree.MemberExpression, 'object'> & {\n object: MemberExpressionWithProperty;\n };\n };\n};\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Selector can be used either with `select` as a pipeable operator or as a method.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'string',\n enum: [SelectStyle.Method, SelectStyle.Operator],\n additionalProperties: false,\n },\n ],\n messages: {\n [SelectStyle.Method]:\n 'Selector should be used with select method: `this.store.select(selector)`.',\n [SelectStyle.Operator]:\n 'Selector should be used with the pipeable operator: `this.store.pipe(select(selector))`.',\n },\n },\n defaultOptions: [SelectStyle.Method],\n create: (context, [mode]) => {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n if (mode === SelectStyle.Operator) {\n return {\n [selectExpression(storeNames)](node: CallExpression) {\n context.report({\n node: node.callee.property,\n messageId: SelectStyle.Operator,\n fix: (fixer) => getMethodToOperatorFixes(node, fixer),\n });\n },\n };\n }\n\n return {\n [`Program:has(${pipeableSelect(\n storeNames\n )}) ImportDeclaration[source.value='${\n NGRX_MODULE_PATHS.store\n }'] > ImportSpecifier[imported.name='select']`](\n node: TSESTree.ImportSpecifier & {\n parent: TSESTree.ImportDeclaration;\n }\n ) {\n context.report({\n node,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getImportRemoveFix(sourceCode, [node.parent], 'select', fixer),\n });\n\n const [{ references }] = context.getDeclaredVariables(node);\n\n for (const { identifier } of references) {\n context.report({\n node: identifier,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getOperatorToMethodFixes(identifier, sourceCode, fixer),\n });\n }\n },\n };\n },\n});\n\nfunction getMethodToOperatorFixes(\n node: CallExpression,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const classDeclaration = getNearestUpperNodeFrom(node, isClassDeclaration);\n\n if (!classDeclaration) {\n return [];\n }\n\n return [\n fixer.insertTextBefore(node.callee.property, 'pipe('),\n fixer.insertTextAfter(node, ')'),\n ].concat(\n getImportAddFix({\n fixer,\n importName: 'select',\n moduleName: NGRX_MODULE_PATHS.store,\n node: classDeclaration,\n })\n );\n}\n\nfunction getOperatorToMethodFixes(\n identifier: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const select = identifier.parent;\n const storePipe = select?.parent;\n\n if (\n !storePipe ||\n !isCallExpression(storePipe) ||\n !isMemberExpression(storePipe.callee)\n ) {\n return [];\n }\n\n const pipeContainsOnlySelect = storePipe.arguments.length === 1;\n\n if (!pipeContainsOnlySelect) {\n const selectContent = sourceCode.getText(select);\n const nextTokenAfterSelect = sourceCode.getTokenAfter(select);\n const store = storePipe.callee.object;\n return [\n fixer.remove(select),\n ...(nextTokenAfterSelect ? [fixer.remove(nextTokenAfterSelect)] : []),\n fixer.insertTextAfter(store, `.${selectContent}`),\n ];\n }\n\n const { property } = storePipe.callee;\n const nextTokenAfterPipe = sourceCode.getTokenAfter(property);\n const [pipeInitialRange, pipeEndRange] = property.range;\n const pipeRange: TSESTree.Range = [\n pipeInitialRange,\n nextTokenAfterPipe?.range[1] ?? pipeEndRange,\n ];\n const [, selectEndRange] = identifier.range;\n return [\n fixer.removeRange(pipeRange),\n fixer.insertTextAfterRange([selectEndRange, selectEndRange + 1], '('),\n ];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-consistent-global-store-name.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/use-consistent-global-store-name.ts"],"names":[],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AAM,MAEzC;wBACD,SAAS,EAAE,oCAA4B;wBACvC,IAAI,MAAA;wBACJ,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,2CAAmC;gCAC9C,IAAI,MAAA;gCACJ,GAAG,EAAE,UAAC,KAAK;;oCACT,OAAA,KAAK,CAAC,gBAAgB,CACpB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAC,CAAC,CAAC,mCAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAChD,SAAS,CACV,CAAA;iCAAA;6BACJ;yBACF;qBACF,CAAC,CAAC;;;oBA3BL,KAAmD,IAAA,gBAAA,SAAA,WAAW,CAAA,wCAAA;wBAAnD,IAAA,0BAAoC,EAAlC,GAAG,SAAA,EAAE,MAAI,UAAA,EAAE,KAAK,WAAA,EAAE,cAAc,oBAAA;8CAAhC,GAAG,EAAE,MAAI,EAAE,KAAK,EAAE,cAAc;;;qBA4B5C;;;;;;;;;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgRxStores } from '../../utils';\n\nexport const useConsistentGlobalStoreName = 'useConsistentGlobalStoreName';\nexport const useConsistentGlobalStoreNameSuggest =\n 'useConsistentGlobalStoreNameSuggest';\n\ntype MessageIds =\n | typeof useConsistentGlobalStoreName\n | typeof useConsistentGlobalStoreNameSuggest;\ntype Options = readonly [string];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'Use a consistent name for the global store.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [\n {\n type: 'string',\n additionalProperties: false,\n },\n ],\n messages: {\n [useConsistentGlobalStoreName]:\n 'Global store should be named as `{{ storeName }}`.',\n [useConsistentGlobalStoreNameSuggest]: 'Rename it to `{{ storeName }}`.',\n },\n },\n defaultOptions: ['store'],\n create: (context, [storeName]) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const { loc, name, range, typeAnnotation } of identifiers) {\n if (name === storeName) {\n return;\n }\n\n const data = { storeName };\n context.report({\n loc: {\n ...loc,\n end: {\n ...loc.start,\n column: loc.start.column + name.length,\n },\n },\n messageId: useConsistentGlobalStoreName,\n data,\n suggest: [\n {\n messageId: useConsistentGlobalStoreNameSuggest,\n data,\n fix: (fixer) =>\n fixer.replaceTextRange(\n [range[0], typeAnnotation?.range[0] ?? range[1]],\n storeName\n ),\n },\n ],\n });\n }\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"use-consistent-global-store-name.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/use-consistent-global-store-name.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA4C;AAE/B,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ;YACN,GAAC,oCAA4B,IAC3B,oDAAoD;YACtD,GAAC,2CAAmC,IAAG,iCAAiC;eACzE;KACF;IACD,cAAc,EAAE,CAAC,OAAO,CAAC;I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ule } from '../../rule-creator';\nimport { getNgRxStores } from '../../utils';\n\nexport const useConsistentGlobalStoreName = 'useConsistentGlobalStoreName';\nexport const useConsistentGlobalStoreNameSuggest =\n 'useConsistentGlobalStoreNameSuggest';\n\ntype MessageIds =\n | typeof useConsistentGlobalStoreName\n | typeof useConsistentGlobalStoreNameSuggest;\ntype Options = readonly [string];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'Use a consistent name for the global store.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [\n {\n type: 'string',\n additionalProperties: false,\n },\n ],\n messages: {\n [useConsistentGlobalStoreName]:\n 'Global store should be named as `{{ storeName }}`.',\n [useConsistentGlobalStoreNameSuggest]: 'Rename it to `{{ storeName }}`.',\n },\n },\n defaultOptions: ['store'],\n create: (context, [storeName]) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const { loc, name, range, typeAnnotation } of identifiers) {\n if (name === storeName) {\n return;\n }\n\n const data = { storeName };\n context.report({\n loc: {\n ...loc,\n end: {\n ...loc.start,\n column: loc.start.column + name.length,\n },\n },\n messageId: useConsistentGlobalStoreName,\n data,\n suggest: [\n {\n messageId: useConsistentGlobalStoreNameSuggest,\n data,\n fix: (fixer) =>\n fixer.replaceTextRange(\n [range[0], typeAnnotation?.range[0] ?? range[1]],\n storeName\n ),\n },\n ],\n });\n }\n },\n };\n },\n});\n"]}
@@ -192,7 +192,7 @@ function getInterface(node, interfaceName) {
192
192
  exports.getInterface = getInterface;
193
193
  function getImplementsSchemaFixer(_a, interfaceName) {
194
194
  var id = _a.id, classImplements = _a.implements;
195
- var _b = __read(classImplements
195
+ var _b = __read(classImplements && classImplements.length
196
196
  ? [getLast(classImplements), ", ".concat(interfaceName)]
197
197
  : [id, " implements ".concat(interfaceName)], 2), implementsNodeReplace = _b[0], implementsTextReplace = _b[1];
198
198
  return { implementsNodeReplace: implementsNodeReplace, implementsTextReplace: implementsTextReplace };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,mCAkBkB;AAClB,+CAAmD;AAoBnD,SAAgB,uBAAuB,CACrC,EAAyB,EACzB,SAAiD;QAD/C,MAAM,YAAA;IAGR,OAAO,MAAM,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE;QACnC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;YACrB,OAAO,MAAM,CAAC;SACf;QAED,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;KACxB;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAbD,0DAaC;AAED,SAAgB,6BAA6B,CAC3C,kBAAyD,EACzD,UAAkB;;;QAElB,KAAgC,IAAA,uBAAA,SAAA,kBAAkB,CAAA,sDAAA,sFAAE;YAA/C,IAAM,iBAAiB,+BAAA;YAC1B,IAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CACvD,UAAC,YAAY;gBACX,OAAO,CACL,IAAA,0BAAiB,EAAC,YAAY,CAAC;oBAC/B,YAAY,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAC1C,CAAC;YACJ,CAAC,CACF,CAAC;YAEF,IAAI,eAAe,EAAE;gBACnB,OAAO,EAAE,iBAAiB,mBAAA,EAAE,eAAe,iBAAA,EAAW,CAAC;aACxD;SACF;;;;;;;;;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;QAC3C,UAAU,GAAG,UAAU,CAAC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ACrE,OAAO,IAAI,MAAM,CAAC,YAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,OAAI,CAAC,CAAC;AACrD,CAAC;AAHD,8BAGC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-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`;\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] = classImplements\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 = context.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,mCAkBkB;AAClB,+CAAmD;AAoBnD,SAAgB,uBAAuB,CACrC,EAAyB,EACzB,SAAiD;QAD/C,MAAM,YAAA;IAGR,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;;;QAElB,KAAgC,IAAA,uBAAA,SAAA,kBAAkB,CAAA,sDAAA,sFAAE,CAAC;YAAhD,IAAM,iBAAiB,+BAAA;YAC1B,IAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CACvD,UAAC,YAAY;gBACX,OAAO,CACL,IAAA,0BAAiB,EAAC,YAAY,CAAC;oBAC/B,YAAY,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAC1C,CAAC;YACJ,CAAC,CACF,CAAC;YAEF,IAAI,eAAe,EAAE,CAAC;gBACpB,OAAO,EAAE,iBAAiB,mBAAA,EAAE,eAAe,iBAAA,EAAW,CAAC;YACzD,CAAC;QACH,CAAC;;;;;;;;;IAED,OAAO,SAAS,CAAC;AAC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B,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,IAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,EAAQ;YAAN,IAAI,UAAA;QAAO,OAAA,UAAU,CAAC,IAAI,CAAC;IAAhB,CAAgB,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,YAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,OAAI,CAAC,CAAC;AACrD,CAAC;AAHD,8BAGC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-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`;\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 = context.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 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/versions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiC;AAEjC,IAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,IAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAChD,IAAM,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;AAElD,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC3B,IAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC,CAAC;KAChD;IAED,OAAO,aAAa,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;;IACtC,IAAI;QACF,8DAA8D;QAC9D,IAAM,WAAW,GAAG,OAAO,CAAC,UAAG,GAAG,kBAAe,CAEhD,CAAC;QACF,OAAO,MAAA,WAAW,CAAC,OAAO,0CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;KACpD;IAAC,WAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,iCAAiC;AACjC,SAAgB,cAAc,CAAC,GAAW,EAAE,OAAe;IACzD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC;AAED,iCAAiC;AACjC,SAAgB,UAAU;IACxB,aAAa,CAAC,KAAK,EAAE,CAAC;IACtB,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAHD,gCAGC;AAED,SAAS,gBAAgB,CAAC,GAAW,EAAE,OAAe;IACpD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC5B,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KACzE;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;AAFD,oDAEC","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\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
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/versions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiC;AAEjC,IAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,IAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAChD,IAAM,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;AAElD,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,IAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,aAAa,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;;IACtC,IAAI,CAAC;QACH,8DAA8D;QAC9D,IAAM,WAAW,GAAG,OAAO,CAAC,UAAG,GAAG,kBAAe,CAEhD,CAAC;QACF,OAAO,MAAA,WAAW,CAAC,OAAO,0CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,iCAAiC;AACjC,SAAgB,cAAc,CAAC,GAAW,EAAE,OAAe;IACzD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC;AAED,iCAAiC;AACjC,SAAgB,UAAU;IACxB,aAAa,CAAC,KAAK,EAAE,CAAC;IACtB,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAHD,gCAGC;AAED,SAAS,gBAAgB,CAAC,GAAW,EAAE,OAAe;IACpD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc,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;AAFD,oDAEC","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\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"]}