@ngrx/eslint-plugin 16.1.0 → 16.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/scripts/generate-docs.js +3 -0
- package/scripts/generate-docs.js.map +1 -1
- package/src/configs/all-requiring-type-checking.js +2 -0
- package/src/configs/all-requiring-type-checking.js.map +1 -1
- package/src/configs/all.js +2 -0
- package/src/configs/all.js.map +1 -1
- package/src/configs/component-store-strict.js +5 -1
- package/src/configs/component-store-strict.js.map +1 -1
- package/src/configs/component-store.js +5 -1
- package/src/configs/component-store.js.map +1 -1
- package/src/configs/recommended-requiring-type-checking.js +2 -0
- package/src/configs/recommended-requiring-type-checking.js.map +1 -1
- package/src/configs/recommended.js +2 -0
- package/src/configs/recommended.js.map +1 -1
- package/src/configs/strict-requiring-type-checking.js +2 -0
- package/src/configs/strict-requiring-type-checking.js.map +1 -1
- package/src/configs/strict.js +2 -0
- package/src/configs/strict.js.map +1 -1
- package/src/rule-creator.js +41 -0
- package/src/rule-creator.js.map +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.js +95 -0
- package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -0
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js +69 -0
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -0
- package/src/rules/store/no-typed-global-store.js +48 -19
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.js +4 -2
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.js +2 -1
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/guards.js +2 -1
- package/src/utils/helper-functions/guards.js.map +1 -1
- package/src/utils/helper-functions/utils.js +15 -10
- package/src/utils/helper-functions/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/eslint-plugin",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0",
|
|
4
4
|
"description": "NgRx ESLint Plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"typescript": ">=4.4.0"
|
|
47
47
|
},
|
|
48
48
|
"main": "./src/index.js",
|
|
49
|
-
"
|
|
49
|
+
"type": "commonjs"
|
|
50
50
|
}
|
package/scripts/generate-docs.js
CHANGED
|
@@ -74,6 +74,9 @@ try {
|
|
|
74
74
|
for (var _e = __values(Object.entries(rules_1.rules)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
75
75
|
var _g = __read(_f.value, 2), ruleName = _g[0], meta = _g[1].meta;
|
|
76
76
|
var docPath = path.join(RULES_PATH, "".concat(ruleName, ".md"));
|
|
77
|
+
if (!(0, fs_1.existsSync)(docPath)) {
|
|
78
|
+
(0, fs_1.writeFileSync)(docPath, "");
|
|
79
|
+
}
|
|
77
80
|
var doc = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
78
81
|
var docContent = doc.substring(doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length);
|
|
79
82
|
var newDoc = (0, prettier_1.format)("# ".concat(ruleName, "\n\n").concat(meta.version ? '> Required NgRx Version Range: ${meta.version}' : '', " \n\n").concat((_b = meta.docs) === null || _b === void 0 ? void 0 : _b.description, "\n\n- **Type**: ").concat(meta.type, "\n- **Recommended**: ").concat(((_c = meta.docs) === null || _c === void 0 ? void 0 : _c.recommended) ? 'Yes' : 'No', "\n- **Fixable**: ").concat(meta.fixable ? 'Yes' : 'No', "\n- **Suggestion**: ").concat(meta.hasSuggestions ? 'Yes' : 'No', "\n- **Requires type checking**: ").concat(((_d = meta.docs) === null || _d === void 0 ? void 0 : _d.requiresTypeChecking) ? 'Yes' : 'No', "\n- **Configurable**: ").concat(meta.schema.length ? 'Yes' : 'No', "\n\n<!-- Everything above this generated, do not edit -->\n<!-- MANUAL-DOC:START -->\n\n").concat(docContent), __assign({ parser: 'markdown' }, prettierConfig));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-docs.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
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"]}
|
|
@@ -12,6 +12,8 @@ module.exports = {
|
|
|
12
12
|
},
|
|
13
13
|
plugins: ['@ngrx'],
|
|
14
14
|
rules: {
|
|
15
|
+
'@ngrx/avoid-combining-component-store-selectors': 'warn',
|
|
16
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'warn',
|
|
15
17
|
'@ngrx/updater-explicit-return-type': 'warn',
|
|
16
18
|
'@ngrx/avoid-cyclic-effects': 'warn',
|
|
17
19
|
'@ngrx/no-dispatch-in-effects': 'warn',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,MAAM;QAC5C,4BAA4B,EAAE,MAAM;QACpC,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/avoid-cyclic-effects': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'warn',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"all-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,+CAA+C,EAAE,MAAM;QACvD,oCAAoC,EAAE,MAAM;QAC5C,4BAA4B,EAAE,MAAM;QACpC,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'warn',\n '@ngrx/avoid-mapping-component-store-selectors': 'warn',\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/avoid-cyclic-effects': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'warn',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
package/src/configs/all.js
CHANGED
|
@@ -7,6 +7,8 @@ module.exports = {
|
|
|
7
7
|
parser: '@typescript-eslint/parser',
|
|
8
8
|
plugins: ['@ngrx'],
|
|
9
9
|
rules: {
|
|
10
|
+
'@ngrx/avoid-combining-component-store-selectors': 'warn',
|
|
11
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'warn',
|
|
10
12
|
'@ngrx/updater-explicit-return-type': 'warn',
|
|
11
13
|
'@ngrx/no-dispatch-in-effects': 'warn',
|
|
12
14
|
'@ngrx/no-effects-in-providers': 'error',
|
package/src/configs/all.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,MAAM;QAC5C,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/all.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,+CAA+C,EAAE,MAAM;QACvD,oCAAoC,EAAE,MAAM;QAC5C,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'warn',\n '@ngrx/avoid-mapping-component-store-selectors': 'warn',\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
parser: '@typescript-eslint/parser',
|
|
8
8
|
plugins: ['@ngrx'],
|
|
9
|
-
rules: {
|
|
9
|
+
rules: {
|
|
10
|
+
'@ngrx/avoid-combining-component-store-selectors': 'error',
|
|
11
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'error',
|
|
12
|
+
'@ngrx/updater-explicit-return-type': 'error',
|
|
13
|
+
},
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=component-store-strict.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-store-strict.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store-strict.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"component-store-strict.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store-strict.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+CAA+C,EAAE,OAAO;QACxD,oCAAoC,EAAE,OAAO;KAC9C;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n },\n};\n"]}
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
parser: '@typescript-eslint/parser',
|
|
8
8
|
plugins: ['@ngrx'],
|
|
9
|
-
rules: {
|
|
9
|
+
rules: {
|
|
10
|
+
'@ngrx/avoid-combining-component-store-selectors': 'warn',
|
|
11
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'warn',
|
|
12
|
+
'@ngrx/updater-explicit-return-type': 'warn',
|
|
13
|
+
},
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=component-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-store.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"component-store.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/component-store.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,+CAA+C,EAAE,MAAM;QACvD,oCAAoC,EAAE,MAAM;KAC7C;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'warn',\n '@ngrx/avoid-mapping-component-store-selectors': 'warn',\n '@ngrx/updater-explicit-return-type': 'warn',\n },\n};\n"]}
|
|
@@ -12,6 +12,8 @@ module.exports = {
|
|
|
12
12
|
},
|
|
13
13
|
plugins: ['@ngrx'],
|
|
14
14
|
rules: {
|
|
15
|
+
'@ngrx/avoid-combining-component-store-selectors': 'warn',
|
|
16
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'warn',
|
|
15
17
|
'@ngrx/updater-explicit-return-type': 'warn',
|
|
16
18
|
'@ngrx/avoid-cyclic-effects': 'warn',
|
|
17
19
|
'@ngrx/no-dispatch-in-effects': 'warn',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/recommended-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,MAAM;QAC5C,4BAA4B,EAAE,MAAM;QACpC,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/avoid-cyclic-effects': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'warn',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"recommended-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/recommended-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,+CAA+C,EAAE,MAAM;QACvD,oCAAoC,EAAE,MAAM;QAC5C,4BAA4B,EAAE,MAAM;QACpC,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'warn',\n '@ngrx/avoid-mapping-component-store-selectors': 'warn',\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/avoid-cyclic-effects': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'warn',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
@@ -7,6 +7,8 @@ module.exports = {
|
|
|
7
7
|
parser: '@typescript-eslint/parser',
|
|
8
8
|
plugins: ['@ngrx'],
|
|
9
9
|
rules: {
|
|
10
|
+
'@ngrx/avoid-combining-component-store-selectors': 'warn',
|
|
11
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'warn',
|
|
10
12
|
'@ngrx/updater-explicit-return-type': 'warn',
|
|
11
13
|
'@ngrx/no-dispatch-in-effects': 'warn',
|
|
12
14
|
'@ngrx/no-effects-in-providers': 'error',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/recommended.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,MAAM;QAC5C,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/recommended.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,+CAA+C,EAAE,MAAM;QACvD,oCAAoC,EAAE,MAAM;QAC5C,8BAA8B,EAAE,MAAM;QACtC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,MAAM;QAChD,iCAAiC,EAAE,MAAM;QACzC,iDAAiD,EAAE,MAAM;QACzD,uCAAuC,EAAE,MAAM;QAC/C,iCAAiC,EAAE,MAAM;QACzC,uDAAuD,EAAE,MAAM;QAC/D,0CAA0C,EAAE,MAAM;QAClD,+BAA+B,EAAE,MAAM;QACvC,2BAA2B,EAAE,MAAM;QACnC,iCAAiC,EAAE,MAAM;QACzC,+BAA+B,EAAE,MAAM;QACvC,6BAA6B,EAAE,MAAM;QACrC,6BAA6B,EAAE,MAAM;QACrC,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,6BAA6B,EAAE,MAAM;QACrC,kCAAkC,EAAE,MAAM;QAC1C,yDAAyD,EAAE,MAAM;QACjE,iCAAiC,EAAE,MAAM;QACzC,oCAAoC,EAAE,MAAM;QAC5C,oBAAoB,EAAE,MAAM;QAC5B,wCAAwC,EAAE,MAAM;KACjD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'warn',\n '@ngrx/avoid-mapping-component-store-selectors': 'warn',\n '@ngrx/updater-explicit-return-type': 'warn',\n '@ngrx/no-dispatch-in-effects': 'warn',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'warn',\n '@ngrx/prefer-concat-latest-from': 'warn',\n '@ngrx/prefer-effect-callback-in-block-statement': 'warn',\n '@ngrx/use-effects-lifecycle-interface': 'warn',\n '@ngrx/avoid-combining-selectors': 'warn',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'warn',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'warn',\n '@ngrx/avoid-mapping-selectors': 'warn',\n '@ngrx/good-action-hygiene': 'warn',\n '@ngrx/no-multiple-global-stores': 'warn',\n '@ngrx/no-reducer-in-key-names': 'warn',\n '@ngrx/no-store-subscription': 'warn',\n '@ngrx/no-typed-global-store': 'warn',\n '@ngrx/on-function-explicit-return-type': 'warn',\n '@ngrx/prefer-action-creator-in-dispatch': 'warn',\n '@ngrx/prefer-action-creator': 'warn',\n '@ngrx/prefer-inline-action-props': 'warn',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'warn',\n '@ngrx/prefer-selector-in-select': 'warn',\n '@ngrx/prefix-selectors-with-select': 'warn',\n '@ngrx/select-style': 'warn',\n '@ngrx/use-consistent-global-store-name': 'warn',\n },\n};\n"]}
|
|
@@ -12,6 +12,8 @@ module.exports = {
|
|
|
12
12
|
},
|
|
13
13
|
plugins: ['@ngrx'],
|
|
14
14
|
rules: {
|
|
15
|
+
'@ngrx/avoid-combining-component-store-selectors': 'error',
|
|
16
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'error',
|
|
15
17
|
'@ngrx/updater-explicit-return-type': 'error',
|
|
16
18
|
'@ngrx/avoid-cyclic-effects': 'error',
|
|
17
19
|
'@ngrx/no-dispatch-in-effects': 'error',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/strict-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,OAAO;QAC7C,4BAA4B,EAAE,OAAO;QACrC,8BAA8B,EAAE,OAAO;QACvC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,OAAO;QAC/C,wCAAwC,EAAE,OAAO;QACjD,iCAAiC,EAAE,OAAO;QAC1C,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,iCAAiC,EAAE,OAAO;QAC1C,uDAAuD,EAAE,OAAO;QAChE,0CAA0C,EAAE,OAAO;QACnD,+BAA+B,EAAE,OAAO;QACxC,2BAA2B,EAAE,OAAO;QACpC,iCAAiC,EAAE,OAAO;QAC1C,+BAA+B,EAAE,OAAO;QACxC,6BAA6B,EAAE,OAAO;QACtC,6BAA6B,EAAE,OAAO;QACtC,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,6BAA6B,EAAE,OAAO;QACtC,kCAAkC,EAAE,OAAO;QAC3C,yDAAyD,EAAE,OAAO;QAClE,iCAAiC,EAAE,OAAO;QAC1C,oCAAoC,EAAE,OAAO;QAC7C,oBAAoB,EAAE,OAAO;QAC7B,wCAAwC,EAAE,OAAO;KAClD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'error',\n '@ngrx/avoid-cyclic-effects': 'error',\n '@ngrx/no-dispatch-in-effects': 'error',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'error',\n '@ngrx/prefer-concat-latest-from': 'error',\n '@ngrx/prefer-effect-callback-in-block-statement': 'error',\n '@ngrx/use-effects-lifecycle-interface': 'error',\n '@ngrx/avoid-combining-selectors': 'error',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'error',\n '@ngrx/avoid-mapping-selectors': 'error',\n '@ngrx/good-action-hygiene': 'error',\n '@ngrx/no-multiple-global-stores': 'error',\n '@ngrx/no-reducer-in-key-names': 'error',\n '@ngrx/no-store-subscription': 'error',\n '@ngrx/no-typed-global-store': 'error',\n '@ngrx/on-function-explicit-return-type': 'error',\n '@ngrx/prefer-action-creator-in-dispatch': 'error',\n '@ngrx/prefer-action-creator': 'error',\n '@ngrx/prefer-inline-action-props': 'error',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'error',\n '@ngrx/prefer-selector-in-select': 'error',\n '@ngrx/prefix-selectors-with-select': 'error',\n '@ngrx/select-style': 'error',\n '@ngrx/use-consistent-global-store-name': 'error',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"strict-requiring-type-checking.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/strict-requiring-type-checking.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,iBAAiB;KAC3B;IACD,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+CAA+C,EAAE,OAAO;QACxD,oCAAoC,EAAE,OAAO;QAC7C,4BAA4B,EAAE,OAAO;QACrC,8BAA8B,EAAE,OAAO;QACvC,+BAA+B,EAAE,OAAO;QACxC,sCAAsC,EAAE,OAAO;QAC/C,wCAAwC,EAAE,OAAO;QACjD,iCAAiC,EAAE,OAAO;QAC1C,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,iCAAiC,EAAE,OAAO;QAC1C,uDAAuD,EAAE,OAAO;QAChE,0CAA0C,EAAE,OAAO;QACnD,+BAA+B,EAAE,OAAO;QACxC,2BAA2B,EAAE,OAAO;QACpC,iCAAiC,EAAE,OAAO;QAC1C,+BAA+B,EAAE,OAAO;QACxC,6BAA6B,EAAE,OAAO;QACtC,6BAA6B,EAAE,OAAO;QACtC,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,6BAA6B,EAAE,OAAO;QACtC,kCAAkC,EAAE,OAAO;QAC3C,yDAAyD,EAAE,OAAO;QAClE,iCAAiC,EAAE,OAAO;QAC1C,oCAAoC,EAAE,OAAO;QAC7C,oBAAoB,EAAE,OAAO;QAC7B,wCAAwC,EAAE,OAAO;KAClD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n },\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n '@ngrx/avoid-cyclic-effects': 'error',\n '@ngrx/no-dispatch-in-effects': 'error',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/no-multiple-actions-in-effects': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'error',\n '@ngrx/prefer-concat-latest-from': 'error',\n '@ngrx/prefer-effect-callback-in-block-statement': 'error',\n '@ngrx/use-effects-lifecycle-interface': 'error',\n '@ngrx/avoid-combining-selectors': 'error',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'error',\n '@ngrx/avoid-mapping-selectors': 'error',\n '@ngrx/good-action-hygiene': 'error',\n '@ngrx/no-multiple-global-stores': 'error',\n '@ngrx/no-reducer-in-key-names': 'error',\n '@ngrx/no-store-subscription': 'error',\n '@ngrx/no-typed-global-store': 'error',\n '@ngrx/on-function-explicit-return-type': 'error',\n '@ngrx/prefer-action-creator-in-dispatch': 'error',\n '@ngrx/prefer-action-creator': 'error',\n '@ngrx/prefer-inline-action-props': 'error',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'error',\n '@ngrx/prefer-selector-in-select': 'error',\n '@ngrx/prefix-selectors-with-select': 'error',\n '@ngrx/select-style': 'error',\n '@ngrx/use-consistent-global-store-name': 'error',\n },\n};\n"]}
|
package/src/configs/strict.js
CHANGED
|
@@ -7,6 +7,8 @@ module.exports = {
|
|
|
7
7
|
parser: '@typescript-eslint/parser',
|
|
8
8
|
plugins: ['@ngrx'],
|
|
9
9
|
rules: {
|
|
10
|
+
'@ngrx/avoid-combining-component-store-selectors': 'error',
|
|
11
|
+
'@ngrx/avoid-mapping-component-store-selectors': 'error',
|
|
10
12
|
'@ngrx/updater-explicit-return-type': 'error',
|
|
11
13
|
'@ngrx/no-dispatch-in-effects': 'error',
|
|
12
14
|
'@ngrx/no-effects-in-providers': 'error',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/strict.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,oCAAoC,EAAE,OAAO;QAC7C,8BAA8B,EAAE,OAAO;QACvC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,OAAO;QACjD,iCAAiC,EAAE,OAAO;QAC1C,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,iCAAiC,EAAE,OAAO;QAC1C,uDAAuD,EAAE,OAAO;QAChE,0CAA0C,EAAE,OAAO;QACnD,+BAA+B,EAAE,OAAO;QACxC,2BAA2B,EAAE,OAAO;QACpC,iCAAiC,EAAE,OAAO;QAC1C,+BAA+B,EAAE,OAAO;QACxC,6BAA6B,EAAE,OAAO;QACtC,6BAA6B,EAAE,OAAO;QACtC,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,6BAA6B,EAAE,OAAO;QACtC,kCAAkC,EAAE,OAAO;QAC3C,yDAAyD,EAAE,OAAO;QAClE,iCAAiC,EAAE,OAAO;QAC1C,oCAAoC,EAAE,OAAO;QAC7C,oBAAoB,EAAE,OAAO;QAC7B,wCAAwC,EAAE,OAAO;KAClD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/updater-explicit-return-type': 'error',\n '@ngrx/no-dispatch-in-effects': 'error',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'error',\n '@ngrx/prefer-concat-latest-from': 'error',\n '@ngrx/prefer-effect-callback-in-block-statement': 'error',\n '@ngrx/use-effects-lifecycle-interface': 'error',\n '@ngrx/avoid-combining-selectors': 'error',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'error',\n '@ngrx/avoid-mapping-selectors': 'error',\n '@ngrx/good-action-hygiene': 'error',\n '@ngrx/no-multiple-global-stores': 'error',\n '@ngrx/no-reducer-in-key-names': 'error',\n '@ngrx/no-store-subscription': 'error',\n '@ngrx/no-typed-global-store': 'error',\n '@ngrx/on-function-explicit-return-type': 'error',\n '@ngrx/prefer-action-creator-in-dispatch': 'error',\n '@ngrx/prefer-action-creator': 'error',\n '@ngrx/prefer-inline-action-props': 'error',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'error',\n '@ngrx/prefer-selector-in-select': 'error',\n '@ngrx/prefix-selectors-with-select': 'error',\n '@ngrx/select-style': 'error',\n '@ngrx/use-consistent-global-store-name': 'error',\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/configs/strict.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,iBAAS;IACP,MAAM,EAAE,2BAA2B;IAEnC,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+CAA+C,EAAE,OAAO;QACxD,oCAAoC,EAAE,OAAO;QAC7C,8BAA8B,EAAE,OAAO;QACvC,+BAA+B,EAAE,OAAO;QACxC,wCAAwC,EAAE,OAAO;QACjD,iCAAiC,EAAE,OAAO;QAC1C,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,iCAAiC,EAAE,OAAO;QAC1C,uDAAuD,EAAE,OAAO;QAChE,0CAA0C,EAAE,OAAO;QACnD,+BAA+B,EAAE,OAAO;QACxC,2BAA2B,EAAE,OAAO;QACpC,iCAAiC,EAAE,OAAO;QAC1C,+BAA+B,EAAE,OAAO;QACxC,6BAA6B,EAAE,OAAO;QACtC,6BAA6B,EAAE,OAAO;QACtC,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,6BAA6B,EAAE,OAAO;QACtC,kCAAkC,EAAE,OAAO;QAC3C,yDAAyD,EAAE,OAAO;QAClE,iCAAiC,EAAE,OAAO;QAC1C,oCAAoC,EAAE,OAAO;QAC7C,oBAAoB,EAAE,OAAO;QAC7B,wCAAwC,EAAE,OAAO;KAClD;CACF,CAAC","sourcesContent":["/**\n * DO NOT EDIT\n * This file is generated\n */\n\nexport = {\n parser: '@typescript-eslint/parser',\n\n plugins: ['@ngrx'],\n rules: {\n '@ngrx/avoid-combining-component-store-selectors': 'error',\n '@ngrx/avoid-mapping-component-store-selectors': 'error',\n '@ngrx/updater-explicit-return-type': 'error',\n '@ngrx/no-dispatch-in-effects': 'error',\n '@ngrx/no-effects-in-providers': 'error',\n '@ngrx/prefer-action-creator-in-of-type': 'error',\n '@ngrx/prefer-concat-latest-from': 'error',\n '@ngrx/prefer-effect-callback-in-block-statement': 'error',\n '@ngrx/use-effects-lifecycle-interface': 'error',\n '@ngrx/avoid-combining-selectors': 'error',\n '@ngrx/avoid-dispatching-multiple-actions-sequentially': 'error',\n '@ngrx/avoid-duplicate-actions-in-reducer': 'error',\n '@ngrx/avoid-mapping-selectors': 'error',\n '@ngrx/good-action-hygiene': 'error',\n '@ngrx/no-multiple-global-stores': 'error',\n '@ngrx/no-reducer-in-key-names': 'error',\n '@ngrx/no-store-subscription': 'error',\n '@ngrx/no-typed-global-store': 'error',\n '@ngrx/on-function-explicit-return-type': 'error',\n '@ngrx/prefer-action-creator-in-dispatch': 'error',\n '@ngrx/prefer-action-creator': 'error',\n '@ngrx/prefer-inline-action-props': 'error',\n '@ngrx/prefer-one-generic-in-create-for-feature-selector': 'error',\n '@ngrx/prefer-selector-in-select': 'error',\n '@ngrx/prefix-selectors-with-select': 'error',\n '@ngrx/select-style': 'error',\n '@ngrx/use-consistent-global-store-name': 'error',\n },\n};\n"]}
|
package/src/rule-creator.js
CHANGED
|
@@ -10,11 +10,39 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __values = (this && this.__values) || function(o) {
|
|
14
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
15
|
+
if (m) return m.call(o);
|
|
16
|
+
if (o && typeof o.length === "number") return {
|
|
17
|
+
next: function () {
|
|
18
|
+
if (o && i >= o.length) o = void 0;
|
|
19
|
+
return { value: o && o[i++], done: !o };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
23
|
+
};
|
|
24
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
+
if (!m) return o;
|
|
27
|
+
var i = m.call(o), r, ar = [], e;
|
|
28
|
+
try {
|
|
29
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) { e = { error: error }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e) throw e.error; }
|
|
37
|
+
}
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
13
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
41
|
exports.createRule = void 0;
|
|
15
42
|
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
16
43
|
var utils_1 = require("./utils");
|
|
17
44
|
function createRule(config) {
|
|
45
|
+
var e_1, _a;
|
|
18
46
|
var configOverwrite = __assign(__assign({}, config), { create: function (context, optionsWithDefault) {
|
|
19
47
|
var _a = config.meta, ngrxModule = _a.ngrxModule, version = _a.version;
|
|
20
48
|
if (version !== undefined &&
|
|
@@ -23,6 +51,19 @@ function createRule(config) {
|
|
|
23
51
|
}
|
|
24
52
|
return config.create(context, optionsWithDefault);
|
|
25
53
|
} });
|
|
54
|
+
try {
|
|
55
|
+
for (var _b = __values(Object.entries(configOverwrite.meta.messages)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
56
|
+
var _d = __read(_c.value, 2), key = _d[0], message = _d[1];
|
|
57
|
+
configOverwrite.meta.messages[key] = "".concat(message, " (").concat((0, utils_1.docsUrl)(config.name), ")");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e_1) throw e_1.error; }
|
|
66
|
+
}
|
|
26
67
|
return experimental_utils_1.ESLintUtils.RuleCreator(utils_1.docsUrl)(configOverwrite);
|
|
27
68
|
}
|
|
28
69
|
exports.createRule = createRule;
|
package/src/rule-creator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __values = (this && this.__values) || function(o) {
|
|
26
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
27
|
+
if (m) return m.call(o);
|
|
28
|
+
if (o && typeof o.length === "number") return {
|
|
29
|
+
next: function () {
|
|
30
|
+
if (o && i >= o.length) o = void 0;
|
|
31
|
+
return { value: o && o[i++], done: !o };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
|
+
};
|
|
36
|
+
var _a;
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.messageId = void 0;
|
|
39
|
+
var path = __importStar(require("path"));
|
|
40
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
41
|
+
var utils_1 = require("../../utils");
|
|
42
|
+
exports.messageId = 'avoidCombiningComponentStoreSelectors';
|
|
43
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
44
|
+
name: path.parse(__filename).name,
|
|
45
|
+
meta: {
|
|
46
|
+
type: 'suggestion',
|
|
47
|
+
ngrxModule: 'component-store',
|
|
48
|
+
docs: {
|
|
49
|
+
description: 'Prefer combining selectors at the selector level.',
|
|
50
|
+
recommended: 'warn',
|
|
51
|
+
},
|
|
52
|
+
schema: [],
|
|
53
|
+
messages: (_a = {},
|
|
54
|
+
_a[exports.messageId] = 'Combine selectors at the selector level.',
|
|
55
|
+
_a),
|
|
56
|
+
},
|
|
57
|
+
defaultOptions: [],
|
|
58
|
+
create: function (context) {
|
|
59
|
+
var _a;
|
|
60
|
+
var _b = (0, utils_1.getNgRxComponentStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
|
|
61
|
+
var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
62
|
+
var thisSelects = "CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']";
|
|
63
|
+
var storeSelects = storeNames ? (0, utils_1.namedExpression)(storeNames) : null;
|
|
64
|
+
var selectsInArray = [];
|
|
65
|
+
return _a = {},
|
|
66
|
+
_a["ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ".concat(thisSelects, " ~ ").concat(thisSelects)] = function (node) {
|
|
67
|
+
selectsInArray.push(node);
|
|
68
|
+
},
|
|
69
|
+
_a["CallExpression[callee.name='combineLatest'] ".concat(storeSelects, " ~ ").concat(storeSelects)] = function (node) {
|
|
70
|
+
selectsInArray.push(node);
|
|
71
|
+
},
|
|
72
|
+
_a["CallExpression[callee.name='combineLatest']:exit"] = function () {
|
|
73
|
+
var e_1, _a;
|
|
74
|
+
try {
|
|
75
|
+
for (var selectsInArray_1 = __values(selectsInArray), selectsInArray_1_1 = selectsInArray_1.next(); !selectsInArray_1_1.done; selectsInArray_1_1 = selectsInArray_1.next()) {
|
|
76
|
+
var node = selectsInArray_1_1.value;
|
|
77
|
+
context.report({
|
|
78
|
+
node: node,
|
|
79
|
+
messageId: exports.messageId,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
84
|
+
finally {
|
|
85
|
+
try {
|
|
86
|
+
if (selectsInArray_1_1 && !selectsInArray_1_1.done && (_a = selectsInArray_1.return)) _a.call(selectsInArray_1);
|
|
87
|
+
}
|
|
88
|
+
finally { if (e_1) throw e_1.error; }
|
|
89
|
+
}
|
|
90
|
+
selectsInArray.length = 0;
|
|
91
|
+
},
|
|
92
|
+
_a;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=avoid-combining-component-store-selectors.js.map
|
|
@@ -0,0 +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,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;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,8BAAsB,EAAC,OAAO,CAAC,YAApC,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAAqC;QAC7D,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAM,WAAW,GAAG,oFAAoF,CAAC;QACzG,IAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAErE,IAAM,cAAc,GAA8B,EAAE,CAAC;QACrD;YACE,GAAC,gGAAyF,WAAW,gBAAM,WAAW,CAAE,IAAxH,UACE,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,GAAC,sDAA+C,YAAY,gBAAM,YAAY,CAAE,IAAhF,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 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"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var _a;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.messageId = void 0;
|
|
28
|
+
var path = __importStar(require("path"));
|
|
29
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
30
|
+
var utils_1 = require("../../utils");
|
|
31
|
+
exports.messageId = 'avoidMappingComponentStoreSelectors';
|
|
32
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
33
|
+
name: path.parse(__filename).name,
|
|
34
|
+
meta: {
|
|
35
|
+
type: 'problem',
|
|
36
|
+
ngrxModule: 'component-store',
|
|
37
|
+
docs: {
|
|
38
|
+
description: 'Avoid mapping logic outside the selector level.',
|
|
39
|
+
recommended: 'warn',
|
|
40
|
+
},
|
|
41
|
+
schema: [],
|
|
42
|
+
messages: (_a = {},
|
|
43
|
+
_a[exports.messageId] = 'Map logic at the selector level instead.',
|
|
44
|
+
_a),
|
|
45
|
+
},
|
|
46
|
+
defaultOptions: [],
|
|
47
|
+
create: function (context) {
|
|
48
|
+
var _a;
|
|
49
|
+
var _b = (0, utils_1.getNgRxComponentStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
|
|
50
|
+
var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
51
|
+
var mapOperatorSelector = "[callee.property.name=pipe] > CallExpression[callee.name=map]";
|
|
52
|
+
var selectors = [
|
|
53
|
+
"ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])".concat(mapOperatorSelector),
|
|
54
|
+
storeNames &&
|
|
55
|
+
"".concat((0, utils_1.namedCallableExpression)(storeNames)).concat(mapOperatorSelector),
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join(',');
|
|
59
|
+
return _a = {},
|
|
60
|
+
_a[selectors] = function (node) {
|
|
61
|
+
context.report({
|
|
62
|
+
node: node,
|
|
63
|
+
messageId: exports.messageId,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
_a;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=avoid-mapping-component-store-selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avoid-mapping-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-mapping-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AAER,QAAA,SAAS,GAAG,qCAAqC,CAAC;AAK/D,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;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,8BAAsB,EAAC,OAAO,CAAC,YAApC,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAAqC;QAC7D,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAM,mBAAmB,GAAG,+DAA+D,CAAC;QAC5F,IAAM,SAAS,GAAG;YAChB,0JAAmJ,mBAAmB,CAAE;YACxK,UAAU;gBACR,UAAG,IAAA,+BAAuB,EAAC,UAAU,CAAC,SAAG,mBAAmB,CAAE;SACjE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb;YACE,GAAC,SAAS,IAAV,UAAY,IAAsC;gBAChD,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 getNgRxComponentStores,\n namedCallableExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMappingComponentStoreSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n 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 = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n const mapOperatorSelector = `[callee.property.name=pipe] > CallExpression[callee.name=map]`;\n const selectors = [\n `ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])${mapOperatorSelector}`,\n storeNames &&\n `${namedCallableExpression(storeNames)}${mapOperatorSelector}`,\n ]\n .filter(Boolean)\n .join(',');\n\n return {\n [selectors](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -33,6 +33,22 @@ var __values = (this && this.__values) || function(o) {
|
|
|
33
33
|
};
|
|
34
34
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
35
|
};
|
|
36
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
+
if (!m) return o;
|
|
39
|
+
var i = m.call(o), r, ar = [], e;
|
|
40
|
+
try {
|
|
41
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) { e = { error: error }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e) throw e.error; }
|
|
49
|
+
}
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
36
52
|
var _a;
|
|
37
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
54
|
exports.noTypedStoreSuggest = exports.noTypedStore = void 0;
|
|
@@ -64,27 +80,28 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
64
80
|
Program: function () {
|
|
65
81
|
var e_1, _a;
|
|
66
82
|
var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
|
|
67
|
-
var _loop_1 = function (typeAnnotation) {
|
|
68
|
-
if (!(0, utils_1.isTSTypeReference)(typeAnnotation) ||
|
|
69
|
-
!typeAnnotation.typeParameters) {
|
|
70
|
-
return "continue";
|
|
71
|
-
}
|
|
72
|
-
var typeParameters = typeAnnotation.typeParameters;
|
|
73
|
-
context.report({
|
|
74
|
-
node: typeParameters,
|
|
75
|
-
messageId: exports.noTypedStore,
|
|
76
|
-
suggest: [
|
|
77
|
-
{
|
|
78
|
-
messageId: exports.noTypedStoreSuggest,
|
|
79
|
-
fix: function (fixer) { return fixer.remove(typeParameters); },
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
83
|
try {
|
|
85
84
|
for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
|
|
86
|
-
var
|
|
87
|
-
|
|
85
|
+
var identifier = identifiers_1_1.value;
|
|
86
|
+
// using inject()
|
|
87
|
+
if (!identifier.typeAnnotation) {
|
|
88
|
+
var parent_1 = identifier.parent;
|
|
89
|
+
if ((0, utils_1.isPropertyDefinition)(parent_1) &&
|
|
90
|
+
parent_1.value &&
|
|
91
|
+
(0, utils_1.isCallExpression)(parent_1.value) &&
|
|
92
|
+
parent_1.value.arguments.length) {
|
|
93
|
+
var _c = __read(parent_1.value.arguments, 1), storeArgument = _c[0];
|
|
94
|
+
if ((0, utils_1.isTSInstantiationExpression)(storeArgument)) {
|
|
95
|
+
report(storeArgument.typeParameters);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!(0, utils_1.isTSTypeReference)(identifier.typeAnnotation.typeAnnotation) ||
|
|
101
|
+
!identifier.typeAnnotation.typeAnnotation.typeParameters) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
report(identifier.typeAnnotation.typeAnnotation.typeParameters);
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
107
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -96,6 +113,18 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
96
113
|
}
|
|
97
114
|
},
|
|
98
115
|
};
|
|
116
|
+
function report(typeParameters) {
|
|
117
|
+
context.report({
|
|
118
|
+
node: typeParameters,
|
|
119
|
+
messageId: exports.noTypedStore,
|
|
120
|
+
suggest: [
|
|
121
|
+
{
|
|
122
|
+
messageId: exports.noTypedStoreSuggest,
|
|
123
|
+
fix: function (fixer) { return fixer.remove(typeParameters); },
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
}
|
|
99
128
|
},
|
|
100
129
|
});
|
|
101
130
|
//# sourceMappingURL=no-typed-global-store.js.map
|
|
@@ -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":"
|
|
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,qCAMq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BACF;4BAED,SAAS;yBACV;wBAED,IACE,CAAC,IAAA,yBAAiB,EAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC;4BAC5D,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,EACxD;4BACA,SAAS;yBACV;wBAED,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;qBACjE;;;;;;;;;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"]}
|
|
@@ -62,11 +62,13 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
62
62
|
create: function (context) {
|
|
63
63
|
return {
|
|
64
64
|
'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)$/]))': function (_a) {
|
|
65
|
-
var _b
|
|
65
|
+
var _b;
|
|
66
66
|
var id = _a.id;
|
|
67
67
|
var suggestedName = getSuggestedName(id.name);
|
|
68
68
|
context.report({
|
|
69
|
-
loc: __assign(__assign({}, id.loc), { end: __assign(__assign({}, id.loc.end), { column: ((
|
|
69
|
+
loc: __assign(__assign({}, id.loc), { end: __assign(__assign({}, id.loc.end), { column: ((_b = id.typeAnnotation) === null || _b === void 0 ? void 0 : _b.range[0])
|
|
70
|
+
? id.typeAnnotation.range[0] - 1
|
|
71
|
+
: id.loc.end.column }) }),
|
|
70
72
|
messageId: exports.prefixSelectorsWithSelect,
|
|
71
73
|
suggest: [
|
|
72
74
|
{
|
|
@@ -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,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,
|
|
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,qCA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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"]}
|
|
@@ -111,7 +111,8 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
111
111
|
messageId: exports.useConsistentGlobalStoreNameSuggest,
|
|
112
112
|
data: data,
|
|
113
113
|
fix: function (fixer) {
|
|
114
|
-
|
|
114
|
+
var _a;
|
|
115
|
+
return fixer.replaceTextRange([range[0], (_a = typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.range[0]) !== null && _a !== void 0 ? _a : range[1]], storeName);
|
|
115
116
|
},
|
|
116
117
|
},
|
|
117
118
|
],
|
|
@@ -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":[],"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;IACzB,MAAM,EAAE,UAAC,OAAO,EAAE,EAAW;YAAX,KAAA,aAAW,EAAV,SAAS,QAAA;QAC1B,OAAO;YACL,OAAO;;gBACG,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;wCAEvC,GAAG,EAAE,MAAI,EAAE,KAAK,EAAE,cAAc;oBAC3C,IAAI,MAAI,KAAK,SAAS,EAAE;;qBAEvB;oBAED,IAAM,IAAI,GAAG,EAAE,SAAS,WAAA,EAAE,CAAC;oBAC3B,OAAO,CAAC,MAAM,CAAC;wBACb,GAAG,wBACE,GAAG,KACN,GAAG,wBACE,GAAG,CAAC,KAAK,KACZ,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,MAAI,CAAC,MAAM,MAEzC;wBACD,SAAS,EAAE,oCAA4B;wBACvC,IAAI,MAAA;wBACJ,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,2CAAmC;gCAC9C,IAAI,MAAA;gCACJ,GAAG,EAAE,UAAC,KAAK
|
|
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,O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;;;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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCallExpressionWith = exports.isTypeReference = exports.isIdentifierOrMemberExpression = exports.isProperty = exports.isObjectExpression = exports.isTSTypeReference = exports.isTSTypeAnnotation = exports.isTSParameterProperty = exports.isThisExpression = exports.isProgram = exports.isMemberExpression = exports.isTemplateLiteral = exports.isTemplateElement = exports.isLiteral = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isIdentifier = exports.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
3
|
+
exports.isCallExpressionWith = exports.isTypeReference = exports.isIdentifierOrMemberExpression = exports.isProperty = exports.isObjectExpression = exports.isTSInstantiationExpression = exports.isTSTypeReference = exports.isTSTypeAnnotation = exports.isTSParameterProperty = exports.isThisExpression = exports.isProgram = exports.isMemberExpression = exports.isTemplateLiteral = exports.isTemplateElement = exports.isLiteral = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isIdentifier = exports.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
4
4
|
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
5
5
|
var isNodeOfType = function (nodeType) {
|
|
6
6
|
return function (node) {
|
|
@@ -28,6 +28,7 @@ exports.isThisExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.This
|
|
|
28
28
|
exports.isTSParameterProperty = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSParameterProperty);
|
|
29
29
|
exports.isTSTypeAnnotation = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSTypeAnnotation);
|
|
30
30
|
exports.isTSTypeReference = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSTypeReference);
|
|
31
|
+
exports.isTSInstantiationExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSInstantiationExpression);
|
|
31
32
|
exports.isObjectExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ObjectExpression);
|
|
32
33
|
exports.isProperty = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Property);
|
|
33
34
|
function isIdentifierOrMemberExpression(node) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAGvE,IAAM,YAAY,GAChB,UAAkC,QAAkB;IACpD,OAAA,UAAC,IAAmB;QAClB,OAAA,IAAI,CAAC,IAAI,KAAK,QAAQ;IAAtB,CAAsB;AADxB,CACwB,CAAC;AAEd,QAAA,yBAAyB,GAAG,YAAY,CACnD,mCAAc,CAAC,uBAAuB,CACvC,CAAC;AACW,QAAA,iBAAiB,GAAG,YAAY,CAAC,mCAAc,CAAC,eAAe,CAAC,CAAC;AACjE,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,gBAAgB,GAAG,YAAY,CAAC,mCAAc,CAAC,cAAc,CAAC,CAAC;AAC/D,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,YAAY,GAAG,YAAY,CAAC,mCAAc,CAAC,UAAU,CAAC,CAAC;AACvD,QAAA,mBAAmB,GAAG,YAAY,CAC7C,mCAAc,CAAC,iBAAiB,C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AACvC,CAAC;AAFD,0CAEC;AAED,SAAS,OAAO,CAAC,GAAoB,EAAE,KAAa;IAClD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,SAAgB,oBAAoB,CAClC,IAA6B,EAC7B,UAA2B,EAC3B,YAAoB;IAEpB,OAAO,CACL,IAAA,0BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;QAC1C,CAAC,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7C,CAAC,IAAA,0BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBACrC,IAAA,wBAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC3C,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACzC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC;AAhBD,oDAgBC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';\nimport type * as ts from 'typescript';\n\nconst isNodeOfType =\n <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) =>\n (node: TSESTree.Node): node is TSESTree.Node & { type: NodeType } =>\n node.type === nodeType;\n\nexport const isArrowFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.ArrowFunctionExpression\n);\nexport const isReturnStatement = isNodeOfType(AST_NODE_TYPES.ReturnStatement);\nexport const isMethodDefinition = isNodeOfType(AST_NODE_TYPES.MethodDefinition);\nexport const isCallExpression = isNodeOfType(AST_NODE_TYPES.CallExpression);\nexport const isClassDeclaration = isNodeOfType(AST_NODE_TYPES.ClassDeclaration);\nexport const isPropertyDefinition = isNodeOfType(\n AST_NODE_TYPES.PropertyDefinition\n);\nexport const isFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.FunctionExpression\n);\nexport const isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);\nexport const isImportDeclaration = isNodeOfType(\n AST_NODE_TYPES.ImportDeclaration\n);\nexport const isImportDefaultSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportDefaultSpecifier\n);\nexport const isImportNamespaceSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportNamespaceSpecifier\n);\nexport const isImportSpecifier = isNodeOfType(AST_NODE_TYPES.ImportSpecifier);\nexport const isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);\nexport const isTemplateElement = isNodeOfType(AST_NODE_TYPES.TemplateElement);\nexport const isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);\nexport const isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);\nexport const isProgram = isNodeOfType(AST_NODE_TYPES.Program);\nexport const isThisExpression = isNodeOfType(AST_NODE_TYPES.ThisExpression);\nexport const isTSParameterProperty = isNodeOfType(\n AST_NODE_TYPES.TSParameterProperty\n);\nexport const isTSTypeAnnotation = isNodeOfType(AST_NODE_TYPES.TSTypeAnnotation);\nexport const isTSTypeReference = isNodeOfType(AST_NODE_TYPES.TSTypeReference);\nexport const isObjectExpression = isNodeOfType(AST_NODE_TYPES.ObjectExpression);\nexport const isProperty = isNodeOfType(AST_NODE_TYPES.Property);\n\nexport function isIdentifierOrMemberExpression(\n node: TSESTree.Node\n): node is TSESTree.Identifier | TSESTree.MemberExpression {\n return isIdentifier(node) || isMemberExpression(node);\n}\n\nexport function isTypeReference(type: ts.Type): type is ts.TypeReference {\n return type.hasOwnProperty('target');\n}\n\nfunction equalTo(one: RegExp | string, other: string) {\n return typeof one === 'string' ? one === other : one.test(other);\n}\n\nexport function isCallExpressionWith(\n node: TSESTree.CallExpression,\n objectName: RegExp | string,\n propertyName: string\n) {\n return (\n isMemberExpression(node.callee) &&\n !node.callee.computed &&\n node.callee.property.name === propertyName &&\n ((isIdentifier(node.callee.object) &&\n equalTo(objectName, node.callee.object.name)) ||\n (isMemberExpression(node.callee.object) &&\n isThisExpression(node.callee.object.object) &&\n isIdentifier(node.callee.object.property) &&\n equalTo(objectName, node.callee.object.property.name)))\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAGvE,IAAM,YAAY,GAChB,UAAkC,QAAkB;IACpD,OAAA,UAAC,IAAmB;QAClB,OAAA,IAAI,CAAC,IAAI,KAAK,QAAQ;IAAtB,CAAsB;AADxB,CACwB,CAAC;AAEd,QAAA,yBAAyB,GAAG,YAAY,CACnD,mCAAc,CAAC,uBAAuB,CACvC,CAAC;AACW,QAAA,iBAAiB,GAAG,YAAY,CAAC,mCAAc,CAAC,eAAe,CAAC,CAAC;AACjE,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,gBAAgB,GAAG,YAAY,CAAC,mCAAc,CAAC,cAAc,CAAC,CAAC;AAC/D,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,YAAY,GAAG,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\nimport type * as ts from 'typescript';\n\nconst isNodeOfType =\n <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) =>\n (node: TSESTree.Node): node is TSESTree.Node & { type: NodeType } =>\n node.type === nodeType;\n\nexport const isArrowFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.ArrowFunctionExpression\n);\nexport const isReturnStatement = isNodeOfType(AST_NODE_TYPES.ReturnStatement);\nexport const isMethodDefinition = isNodeOfType(AST_NODE_TYPES.MethodDefinition);\nexport const isCallExpression = isNodeOfType(AST_NODE_TYPES.CallExpression);\nexport const isClassDeclaration = isNodeOfType(AST_NODE_TYPES.ClassDeclaration);\nexport const isPropertyDefinition = isNodeOfType(\n AST_NODE_TYPES.PropertyDefinition\n);\nexport const isFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.FunctionExpression\n);\nexport const isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);\nexport const isImportDeclaration = isNodeOfType(\n AST_NODE_TYPES.ImportDeclaration\n);\nexport const isImportDefaultSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportDefaultSpecifier\n);\nexport const isImportNamespaceSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportNamespaceSpecifier\n);\nexport const isImportSpecifier = isNodeOfType(AST_NODE_TYPES.ImportSpecifier);\nexport const isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);\nexport const isTemplateElement = isNodeOfType(AST_NODE_TYPES.TemplateElement);\nexport const isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);\nexport const isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);\nexport const isProgram = isNodeOfType(AST_NODE_TYPES.Program);\nexport const isThisExpression = isNodeOfType(AST_NODE_TYPES.ThisExpression);\nexport const isTSParameterProperty = isNodeOfType(\n AST_NODE_TYPES.TSParameterProperty\n);\nexport const isTSTypeAnnotation = isNodeOfType(AST_NODE_TYPES.TSTypeAnnotation);\nexport const isTSTypeReference = isNodeOfType(AST_NODE_TYPES.TSTypeReference);\nexport const isTSInstantiationExpression = isNodeOfType(\n AST_NODE_TYPES.TSInstantiationExpression\n);\nexport const isObjectExpression = isNodeOfType(AST_NODE_TYPES.ObjectExpression);\nexport const isProperty = isNodeOfType(AST_NODE_TYPES.Property);\n\nexport function isIdentifierOrMemberExpression(\n node: TSESTree.Node\n): node is TSESTree.Identifier | TSESTree.MemberExpression {\n return isIdentifier(node) || isMemberExpression(node);\n}\n\nexport function isTypeReference(type: ts.Type): type is ts.TypeReference {\n return type.hasOwnProperty('target');\n}\n\nfunction equalTo(one: RegExp | string, other: string) {\n return typeof one === 'string' ? one === other : one.test(other);\n}\n\nexport function isCallExpressionWith(\n node: TSESTree.CallExpression,\n objectName: RegExp | string,\n propertyName: string\n) {\n return (\n isMemberExpression(node.callee) &&\n !node.callee.computed &&\n node.callee.property.name === propertyName &&\n ((isIdentifier(node.callee.object) &&\n equalTo(objectName, node.callee.object.name)) ||\n (isMemberExpression(node.callee.object) &&\n isThisExpression(node.callee.object.object) &&\n isIdentifier(node.callee.object.property) &&\n equalTo(objectName, node.callee.object.property.name)))\n );\n}\n"]}
|
|
@@ -254,23 +254,28 @@ function getInjectedParametersWithSourceCode(context, moduleName, importName) {
|
|
|
254
254
|
});
|
|
255
255
|
var identifiers = (_e = typedVariable === null || typedVariable === void 0 ? void 0 : typedVariable.references) === null || _e === void 0 ? void 0 : _e.reduce(function (identifiers, _a) {
|
|
256
256
|
var parent = _a.identifier.parent;
|
|
257
|
-
if (parent
|
|
258
|
-
|
|
257
|
+
if (!parent) {
|
|
258
|
+
return identifiers;
|
|
259
|
+
}
|
|
260
|
+
if ((0, guards_1.isTSTypeReference)(parent) &&
|
|
259
261
|
parent.parent &&
|
|
260
262
|
(0, guards_1.isTSTypeAnnotation)(parent.parent) &&
|
|
261
263
|
parent.parent.parent &&
|
|
262
264
|
(0, guards_1.isIdentifier)(parent.parent.parent)) {
|
|
263
265
|
return identifiers.concat(parent.parent.parent);
|
|
264
266
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
(0, guards_1.
|
|
271
|
-
|
|
267
|
+
var parentToCheck = (0, guards_1.isTSInstantiationExpression)(parent)
|
|
268
|
+
? parent.parent
|
|
269
|
+
: parent;
|
|
270
|
+
if (parentToCheck &&
|
|
271
|
+
(0, guards_1.isCallExpression)(parentToCheck) &&
|
|
272
|
+
(0, guards_1.isIdentifier)(parentToCheck.callee) &&
|
|
273
|
+
parentToCheck.callee.name == 'inject' &&
|
|
274
|
+
parentToCheck.parent &&
|
|
275
|
+
(0, guards_1.isPropertyDefinition)(parentToCheck.parent) &&
|
|
276
|
+
(0, guards_1.isIdentifier)(parentToCheck.parent.key) &&
|
|
272
277
|
injectImportSpecifier) {
|
|
273
|
-
return identifiers.concat(
|
|
278
|
+
return identifiers.concat(parentToCheck.parent.key);
|
|
274
279
|
}
|
|
275
280
|
return identifiers;
|
|
276
281
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,mCAiBkB;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,I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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} 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 (\n parent &&\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 if (\n parent &&\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name == 'inject' &&\n parent.parent &&\n isPropertyDefinition(parent.parent) &&\n isIdentifier(parent.parent.key) &&\n injectImportSpecifier\n ) {\n return identifiers.concat(parent.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;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,EA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AAgB,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] = 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"]}
|