@ngrx/eslint-plugin 15.4.0 → 16.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +17 -14
- package/jest.config.js.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +6 -6
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +1 -1
- package/scripts/generate-config.js +2 -2
- package/scripts/generate-docs.js +2 -2
- package/scripts/generate-overview.js +1 -1
- package/spec/utils/index.js +3 -3
- package/src/configs/all-requiring-type-checking.js +3 -3
- package/src/configs/all.js +2 -2
- package/src/configs/component-store-strict.js +1 -1
- package/src/configs/component-store.js +1 -1
- package/src/configs/effects-requiring-type-checking.js +3 -3
- package/src/configs/effects-strict-requiring-type-checking.js +3 -3
- package/src/configs/effects-strict.js +2 -2
- package/src/configs/effects.js +2 -2
- package/src/configs/index.js +3 -3
- package/src/configs/index.js.map +1 -1
- package/src/configs/recommended-requiring-type-checking.js +3 -3
- package/src/configs/recommended.js +2 -2
- package/src/configs/store-strict.js +2 -2
- package/src/configs/store.js +2 -2
- package/src/configs/strict-requiring-type-checking.js +3 -3
- package/src/configs/strict.js +2 -2
- package/src/index.js +1 -1
- package/src/rule-creator.js +1 -1
- package/src/rules/component-store/updater-explicit-return-type.js +6 -6
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/avoid-cyclic-effects.js +8 -8
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
- package/src/rules/effects/no-dispatch-in-effects.js +7 -7
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.js +7 -7
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.js +6 -6
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.js +6 -6
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
- package/src/rules/effects/prefer-concat-latest-from.js +13 -13
- package/src/rules/effects/prefer-concat-latest-from.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +6 -6
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.js +9 -9
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
- package/src/rules/index.js +3 -3
- package/src/rules/index.js.map +1 -1
- package/src/rules/store/avoid-combining-selectors.js +7 -7
- package/src/rules/store/avoid-combining-selectors.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +7 -7
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +10 -10
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/avoid-mapping-selectors.js +6 -6
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
- package/src/rules/store/good-action-hygiene.js +7 -7
- package/src/rules/store/good-action-hygiene.js.map +1 -1
- package/src/rules/store/no-multiple-global-stores.js +10 -10
- package/src/rules/store/no-multiple-global-stores.js.map +1 -1
- package/src/rules/store/no-reducer-in-key-names.js +7 -7
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
- package/src/rules/store/no-store-subscription.js +6 -6
- package/src/rules/store/no-store-subscription.js.map +1 -1
- package/src/rules/store/no-typed-global-store.js +9 -9
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.js +7 -7
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.js +6 -6
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
- package/src/rules/store/prefer-action-creator.js +6 -6
- package/src/rules/store/prefer-action-creator.js.map +1 -1
- package/src/rules/store/prefer-inline-action-props.js +7 -7
- package/src/rules/store/prefer-inline-action-props.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +7 -7
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/rules/store/prefer-selector-in-select.js +7 -7
- package/src/rules/store/prefer-selector-in-select.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.js +9 -9
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/select-style.js +12 -12
- package/src/rules/store/select-style.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.js +10 -10
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/docs.js +1 -1
- package/src/utils/helper-functions/folder.js +4 -4
- package/src/utils/helper-functions/guards.js +1 -1
- package/src/utils/helper-functions/index.js +1 -1
- package/src/utils/helper-functions/ngrx-modules.js +1 -1
- package/src/utils/helper-functions/utils.js +3 -3
- package/src/utils/helper-functions/versions.js +1 -1
- package/src/utils/index.js +1 -1
- package/src/utils/selectors/index.js +1 -1
|
@@ -34,14 +34,14 @@ var __values = (this && this.__values) || function(o) {
|
|
|
34
34
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
35
|
};
|
|
36
36
|
var _a;
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.noTypedStoreSuggest = exports.noTypedStore = void 0;
|
|
39
39
|
var path = __importStar(require("path"));
|
|
40
40
|
var rule_creator_1 = require("../../rule-creator");
|
|
41
41
|
var utils_1 = require("../../utils");
|
|
42
42
|
exports.noTypedStore = 'noTypedStore';
|
|
43
43
|
exports.noTypedStoreSuggest = 'noTypedStoreSuggest';
|
|
44
|
-
exports
|
|
44
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
45
45
|
name: path.parse(__filename).name,
|
|
46
46
|
meta: {
|
|
47
47
|
type: 'suggestion',
|
|
@@ -50,13 +50,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
50
50
|
docs: {
|
|
51
51
|
description: 'The global store should not be typed.',
|
|
52
52
|
recommended: 'warn',
|
|
53
|
-
suggestion: true
|
|
53
|
+
suggestion: true,
|
|
54
54
|
},
|
|
55
55
|
schema: [],
|
|
56
56
|
messages: (_a = {},
|
|
57
57
|
_a[exports.noTypedStore] = '`Store` should not be typed, use `Store` (without generic) instead.',
|
|
58
58
|
_a[exports.noTypedStoreSuggest] = 'Remove generic from `Store`.',
|
|
59
|
-
_a)
|
|
59
|
+
_a),
|
|
60
60
|
},
|
|
61
61
|
defaultOptions: [],
|
|
62
62
|
create: function (context) {
|
|
@@ -76,9 +76,9 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
76
76
|
suggest: [
|
|
77
77
|
{
|
|
78
78
|
messageId: exports.noTypedStoreSuggest,
|
|
79
|
-
fix: function (fixer) { return fixer.remove(typeParameters); }
|
|
79
|
+
fix: function (fixer) { return fixer.remove(typeParameters); },
|
|
80
80
|
},
|
|
81
|
-
]
|
|
81
|
+
],
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
84
|
try {
|
|
@@ -90,12 +90,12 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
90
90
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
91
|
finally {
|
|
92
92
|
try {
|
|
93
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1
|
|
93
|
+
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1.return)) _a.call(identifiers_1);
|
|
94
94
|
}
|
|
95
95
|
finally { if (e_1) throw e_1.error; }
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
},
|
|
98
98
|
};
|
|
99
|
-
}
|
|
99
|
+
},
|
|
100
100
|
});
|
|
101
101
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA+D;AAElD,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,
|
|
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,qCAA+D;AAElD,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,oBAAY,IACX,qEAAqE;YACvE,GAAC,2BAAmB,IAAG,8BAA8B;eACtD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,OAAO;;gBACG,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;wCAGhC,cAAc;oBAEhC,IACE,CAAC,IAAA,yBAAiB,EAAC,cAAc,CAAC;wBAClC,CAAC,cAAc,CAAC,cAAc,EAC9B;;qBAED;oBAEO,IAAA,cAAc,GAAK,cAAc,eAAnB,CAAoB;oBAE1C,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,cAAc;wBACpB,SAAS,EAAE,oBAAY;wBACvB,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,2BAAmB;gCAC9B,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,EAA5B,CAA4B;6BAC7C;yBACF;qBACF,CAAC,CAAC;;;oBArBL,KAEK,IAAA,gBAAA,SAAA,WAAW,CAAA,wCAAA;wBADI,IAAA,cAAc,sDAAA;gCAAd,cAAc;qBAqBjC;;;;;;;;;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgRxStores, isTSTypeReference } from '../../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 {\n typeAnnotation: { typeAnnotation },\n } of identifiers) {\n if (\n !isTSTypeReference(typeAnnotation) ||\n !typeAnnotation.typeParameters\n ) {\n continue;\n }\n\n const { typeParameters } = typeAnnotation;\n\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 },\n});\n"]}
|
|
@@ -39,7 +39,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
39
39
|
return ar;
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
|
-
exports
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.onFunctionExplicitReturnTypeSuggest = exports.onFunctionExplicitReturnType = void 0;
|
|
44
44
|
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
45
45
|
var path = __importStar(require("path"));
|
|
@@ -47,7 +47,7 @@ var rule_creator_1 = require("../../rule-creator");
|
|
|
47
47
|
var utils_1 = require("../../utils");
|
|
48
48
|
exports.onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';
|
|
49
49
|
exports.onFunctionExplicitReturnTypeSuggest = 'onFunctionExplicitReturnTypeSuggest';
|
|
50
|
-
exports
|
|
50
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
51
51
|
name: path.parse(__filename).name,
|
|
52
52
|
meta: {
|
|
53
53
|
type: 'suggestion',
|
|
@@ -56,13 +56,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
56
56
|
docs: {
|
|
57
57
|
description: '`On` function should have an explicit return type.',
|
|
58
58
|
recommended: 'warn',
|
|
59
|
-
suggestion: true
|
|
59
|
+
suggestion: true,
|
|
60
60
|
},
|
|
61
61
|
schema: [],
|
|
62
62
|
messages: (_a = {},
|
|
63
63
|
_a[exports.onFunctionExplicitReturnType] = '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',
|
|
64
64
|
_a[exports.onFunctionExplicitReturnTypeSuggest] = 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',
|
|
65
|
-
_a)
|
|
65
|
+
_a),
|
|
66
66
|
},
|
|
67
67
|
defaultOptions: [],
|
|
68
68
|
create: function (context) {
|
|
@@ -76,13 +76,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
76
76
|
suggest: [
|
|
77
77
|
{
|
|
78
78
|
messageId: exports.onFunctionExplicitReturnTypeSuggest,
|
|
79
|
-
fix: function (fixer) { return getFixes(node, sourceCode, fixer); }
|
|
79
|
+
fix: function (fixer) { return getFixes(node, sourceCode, fixer); },
|
|
80
80
|
},
|
|
81
|
-
]
|
|
81
|
+
],
|
|
82
82
|
});
|
|
83
83
|
},
|
|
84
84
|
_a;
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
});
|
|
87
87
|
function getFixes(node, sourceCode, fixer) {
|
|
88
88
|
var params = node.params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,
|
|
1
|
+
{"version":3,"file":"on-function-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/on-function-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA6D;AAEhD,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;YACjE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SAC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AAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS,EAAE,SAAS,CAAC,CAAC;KACjE;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC;QACvC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;KACpC,CAAC;AACb,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getLast, onFunctionWithoutType } from '../../utils';\n\nexport const onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';\nexport const onFunctionExplicitReturnTypeSuggest =\n 'onFunctionExplicitReturnTypeSuggest';\n\ntype MessageIds =\n | typeof onFunctionExplicitReturnType\n | typeof onFunctionExplicitReturnTypeSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: '`On` function should have an explicit return type.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [onFunctionExplicitReturnType]:\n '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',\n [onFunctionExplicitReturnTypeSuggest]:\n 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n\n return {\n [onFunctionWithoutType](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId: onFunctionExplicitReturnType,\n suggest: [\n {\n messageId: onFunctionExplicitReturnTypeSuggest,\n fix: (fixer) => getFixes(node, sourceCode, fixer),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getFixes(\n node: TSESTree.ArrowFunctionExpression,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n) {\n const { params } = node;\n\n if (params.length === 0) {\n const [, closingParen] = sourceCode.getTokens(node);\n return fixer.insertTextAfter(closingParen, ': State');\n }\n\n const [firstParam] = params;\n const lastParam = getLast(params);\n const previousToken = sourceCode.getTokenBefore(firstParam);\n const isParenthesized =\n previousToken && ASTUtils.isOpeningParenToken(previousToken);\n\n if (isParenthesized) {\n const nextToken = sourceCode.getTokenAfter(lastParam);\n return fixer.insertTextAfter(nextToken ?? lastParam, ': State');\n }\n\n return [\n fixer.insertTextBefore(firstParam, '('),\n fixer.insertTextAfter(lastParam, '): State'),\n ] as const;\n}\n"]}
|
|
@@ -23,25 +23,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.messageId = void 0;
|
|
28
28
|
var path = __importStar(require("path"));
|
|
29
29
|
var rule_creator_1 = require("../../rule-creator");
|
|
30
30
|
var utils_1 = require("../../utils");
|
|
31
31
|
exports.messageId = 'preferActionCreatorInDispatch';
|
|
32
|
-
exports
|
|
32
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
33
33
|
name: path.parse(__filename).name,
|
|
34
34
|
meta: {
|
|
35
35
|
type: 'suggestion',
|
|
36
36
|
ngrxModule: 'store',
|
|
37
37
|
docs: {
|
|
38
38
|
description: 'Using `action creator` in `dispatch` is preferred over `object` or old `Action`.',
|
|
39
|
-
recommended: 'warn'
|
|
39
|
+
recommended: 'warn',
|
|
40
40
|
},
|
|
41
41
|
schema: [],
|
|
42
42
|
messages: (_a = {},
|
|
43
43
|
_a[exports.messageId] = 'Using `object` or old `Action` is forbidden. Use `action creator` instead.',
|
|
44
|
-
_a)
|
|
44
|
+
_a),
|
|
45
45
|
},
|
|
46
46
|
defaultOptions: [],
|
|
47
47
|
create: function (context) {
|
|
@@ -61,10 +61,10 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
61
61
|
}
|
|
62
62
|
context.report({
|
|
63
63
|
node: node,
|
|
64
|
-
messageId: exports.messageId
|
|
64
|
+
messageId: exports.messageId,
|
|
65
65
|
});
|
|
66
66
|
},
|
|
67
67
|
_a;
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
69
|
});
|
|
70
70
|
//# sourceMappingURL=prefer-action-creator-in-dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-action-creator-in-dispatch.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator-in-dispatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,+BAA+B,CAAC;AAKzD,
|
|
1
|
+
{"version":3,"file":"prefer-action-creator-in-dispatch.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator-in-dispatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,+BAA+B,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,4EAA4E;eAC/E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,0BAAkB,EACpB,UAAU,CACX,qEAAkE,IAFnE,UAGE,IAAwD;gBAExD,IAAM,0BAA0B,GAAG,IAAA,+BAAuB,EACxD,IAAI,EACJ,wBAAgB,CACjB,CAAC;gBACF,IAAM,8BAA8B,GAClC,0BAA0B,KAAK,SAAS;oBACxC,IAAA,4BAAoB,EAClB,0BAA0B,EAC1B,UAAU,EACV,UAAU,CACX,CAAC;gBAEJ,IAAI,CAAC,8BAA8B,EAAE;oBACnC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n dispatchExpression,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isCallExpressionWith,\n} from '../../utils';\n\nexport const messageId = 'preferActionCreatorInDispatch';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using `action creator` in `dispatch` is preferred over `object` or old `Action`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `object` or old `Action` is forbidden. Use `action creator` instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${dispatchExpression(\n storeNames\n )} :matches(NewExpression, :not(NewExpression) > ObjectExpression)`](\n node: TSESTree.NewExpression | TSESTree.ObjectExpression\n ) {\n const nearestUpperCallExpression = getNearestUpperNodeFrom(\n node,\n isCallExpression\n );\n const isStoreDispatchImmediateParent =\n nearestUpperCallExpression !== undefined &&\n isCallExpressionWith(\n nearestUpperCallExpression,\n storeNames,\n 'dispatch'\n );\n\n if (!isStoreDispatchImmediateParent) {\n return;\n }\n\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -23,24 +23,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.messageId = void 0;
|
|
28
28
|
var path = __importStar(require("path"));
|
|
29
29
|
var rule_creator_1 = require("../../rule-creator");
|
|
30
30
|
exports.messageId = 'preferActionCreator';
|
|
31
|
-
exports
|
|
31
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
32
32
|
name: path.parse(__filename).name,
|
|
33
33
|
meta: {
|
|
34
34
|
type: 'suggestion',
|
|
35
35
|
ngrxModule: 'store',
|
|
36
36
|
docs: {
|
|
37
37
|
description: 'Using `action creator` is preferred over `Action class`.',
|
|
38
|
-
recommended: 'warn'
|
|
38
|
+
recommended: 'warn',
|
|
39
39
|
},
|
|
40
40
|
schema: [],
|
|
41
41
|
messages: (_a = {},
|
|
42
42
|
_a[exports.messageId] = 'Using `Action class` is forbidden. Use `action creator` instead.',
|
|
43
|
-
_a)
|
|
43
|
+
_a),
|
|
44
44
|
},
|
|
45
45
|
defaultOptions: [],
|
|
46
46
|
create: function (context) {
|
|
@@ -49,10 +49,10 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
49
49
|
_a["ClassDeclaration:has(TSClassImplements:matches([expression.name='Action'], [expression.property.name='Action'])):has(PropertyDefinition[key.name='type'])"] = function (node) {
|
|
50
50
|
context.report({
|
|
51
51
|
node: node,
|
|
52
|
-
messageId: exports.messageId
|
|
52
|
+
messageId: exports.messageId,
|
|
53
53
|
});
|
|
54
54
|
},
|
|
55
55
|
_a;
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
57
|
});
|
|
58
58
|
//# sourceMappingURL=prefer-action-creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-action-creator.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAEnC,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAK/C,
|
|
1
|
+
{"version":3,"file":"prefer-action-creator.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAEnC,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAK/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;YACvE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,kEAAkE;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,2JAA2J,IAA5J,UACE,IAA+B;gBAE/B,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';\n\nexport const messageId = 'preferActionCreator';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Using `action creator` is preferred over `Action class`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `Action class` is forbidden. Use `action creator` instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`ClassDeclaration:has(TSClassImplements:matches([expression.name='Action'], [expression.property.name='Action'])):has(PropertyDefinition[key.name='type'])`](\n node: TSESTree.ClassDeclaration\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -23,14 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.preferInlineActionPropsSuggest = exports.preferInlineActionProps = void 0;
|
|
28
28
|
var path = __importStar(require("path"));
|
|
29
29
|
var rule_creator_1 = require("../../rule-creator");
|
|
30
30
|
var utils_1 = require("../../utils");
|
|
31
31
|
exports.preferInlineActionProps = 'preferInlineActionProps';
|
|
32
32
|
exports.preferInlineActionPropsSuggest = 'preferInlineActionPropsSuggest';
|
|
33
|
-
exports
|
|
33
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
34
34
|
name: path.parse(__filename).name,
|
|
35
35
|
meta: {
|
|
36
36
|
type: 'suggestion',
|
|
@@ -39,13 +39,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
39
39
|
docs: {
|
|
40
40
|
description: 'Prefer using inline types instead of interfaces, types or classes.',
|
|
41
41
|
recommended: 'warn',
|
|
42
|
-
suggestion: true
|
|
42
|
+
suggestion: true,
|
|
43
43
|
},
|
|
44
44
|
schema: [],
|
|
45
45
|
messages: (_a = {},
|
|
46
46
|
_a[exports.preferInlineActionProps] = 'Use inline types instead of interfaces, types or classes.',
|
|
47
47
|
_a[exports.preferInlineActionPropsSuggest] = 'Change to inline types.',
|
|
48
|
-
_a)
|
|
48
|
+
_a),
|
|
49
49
|
},
|
|
50
50
|
defaultOptions: [],
|
|
51
51
|
create: function (context) {
|
|
@@ -61,12 +61,12 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
61
61
|
fix: function (fixer) { return [
|
|
62
62
|
fixer.insertTextBefore(node, '{name: '),
|
|
63
63
|
fixer.insertTextAfter(node, '}'),
|
|
64
|
-
]; }
|
|
64
|
+
]; },
|
|
65
65
|
},
|
|
66
|
-
]
|
|
66
|
+
],
|
|
67
67
|
});
|
|
68
68
|
},
|
|
69
69
|
_a;
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
71
|
});
|
|
72
72
|
//# sourceMappingURL=prefer-inline-action-props.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-inline-action-props.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-inline-action-props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAyD;AAE5C,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAO/E,
|
|
1
|
+
{"version":3,"file":"prefer-inline-action-props.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-inline-action-props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAyD;AAE5C,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAO/E,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,oEAAoE;YACtE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,+BAAuB,IACtB,2DAA2D;YAC7D,GAAC,sCAA8B,IAAG,yBAAyB;eAC5D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,kCAA0B,IAA3B,UAA6B,IAA8B;gBACzD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,EAAE,+BAAuB;oBAClC,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,sCAA8B;4BACzC,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA;gCACd,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC;gCACvC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC;6BACjC,EAHe,CAGf;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { actionCreatorPropsComputed } from '../../utils';\n\nexport const preferInlineActionProps = 'preferInlineActionProps';\nexport const preferInlineActionPropsSuggest = 'preferInlineActionPropsSuggest';\n\ntype MessageIds =\n | typeof preferInlineActionProps\n | typeof preferInlineActionPropsSuggest;\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 'Prefer using inline types instead of interfaces, types or classes.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [preferInlineActionProps]:\n 'Use inline types instead of interfaces, types or classes.',\n [preferInlineActionPropsSuggest]: 'Change to inline types.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [actionCreatorPropsComputed](node: TSESTree.TSTypeReference) {\n context.report({\n node,\n messageId: preferInlineActionProps,\n suggest: [\n {\n messageId: preferInlineActionPropsSuggest,\n fix: (fixer) => [\n fixer.insertTextBefore(node, '{name: '),\n fixer.insertTextAfter(node, '}'),\n ],\n },\n ],\n });\n },\n };\n },\n});\n"]}
|
|
@@ -39,13 +39,13 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
39
39
|
return ar;
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
|
-
exports
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.preferOneGenericInCreateForFeatureSelectorSuggest = exports.preferOneGenericInCreateForFeatureSelector = void 0;
|
|
44
44
|
var path = __importStar(require("path"));
|
|
45
45
|
var rule_creator_1 = require("../../rule-creator");
|
|
46
46
|
exports.preferOneGenericInCreateForFeatureSelector = 'preferOneGenericInCreateForFeatureSelector';
|
|
47
47
|
exports.preferOneGenericInCreateForFeatureSelectorSuggest = 'preferOneGenericInCreateForFeatureSelectorSuggest';
|
|
48
|
-
exports
|
|
48
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
49
49
|
name: path.parse(__filename).name,
|
|
50
50
|
meta: {
|
|
51
51
|
type: 'suggestion',
|
|
@@ -54,13 +54,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
54
54
|
docs: {
|
|
55
55
|
description: 'Prefer using a single generic to define the feature state.',
|
|
56
56
|
recommended: 'warn',
|
|
57
|
-
suggestion: true
|
|
57
|
+
suggestion: true,
|
|
58
58
|
},
|
|
59
59
|
schema: [],
|
|
60
60
|
messages: (_a = {},
|
|
61
61
|
_a[exports.preferOneGenericInCreateForFeatureSelector] = 'Use a single generic to define the feature state.',
|
|
62
62
|
_a[exports.preferOneGenericInCreateForFeatureSelectorSuggest] = 'Remove the global state generic.',
|
|
63
|
-
_a)
|
|
63
|
+
_a),
|
|
64
64
|
},
|
|
65
65
|
defaultOptions: [],
|
|
66
66
|
create: function (context) {
|
|
@@ -82,12 +82,12 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
82
82
|
globalState.range[0],
|
|
83
83
|
(_a = nextToken === null || nextToken === void 0 ? void 0 : nextToken.range[1]) !== null && _a !== void 0 ? _a : globalState.range[1] + 1,
|
|
84
84
|
]);
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
},
|
|
87
|
-
]
|
|
87
|
+
],
|
|
88
88
|
});
|
|
89
89
|
},
|
|
90
90
|
_a;
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
92
|
});
|
|
93
93
|
//# sourceMappingURL=prefer-one-generic-in-create-for-feature-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-one-generic-in-create-for-feature-selector.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-one-generic-in-create-for-feature-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAEnC,QAAA,0CAA0C,GACrD,4CAA4C,CAAC;AAClC,QAAA,iDAAiD,GAC5D,mDAAmD,CAAC;AAOtD,
|
|
1
|
+
{"version":3,"file":"prefer-one-generic-in-create-for-feature-selector.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-one-generic-in-create-for-feature-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;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ACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\n\nexport const preferOneGenericInCreateForFeatureSelector =\n 'preferOneGenericInCreateForFeatureSelector';\nexport const preferOneGenericInCreateForFeatureSelectorSuggest =\n 'preferOneGenericInCreateForFeatureSelectorSuggest';\n\ntype MessageIds =\n | typeof preferOneGenericInCreateForFeatureSelector\n | typeof preferOneGenericInCreateForFeatureSelectorSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'Prefer using a single generic to define the feature state.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [preferOneGenericInCreateForFeatureSelector]:\n 'Use a single generic to define the feature state.',\n [preferOneGenericInCreateForFeatureSelectorSuggest]:\n 'Remove the global state generic.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n\n return {\n [`CallExpression[callee.name='createFeatureSelector'] > TSTypeParameterInstantiation[params.length>1]`](\n node: TSESTree.TSTypeParameterInstantiation\n ) {\n context.report({\n node,\n messageId: preferOneGenericInCreateForFeatureSelector,\n suggest: [\n {\n messageId: preferOneGenericInCreateForFeatureSelectorSuggest,\n fix: (fixer) => {\n const [globalState] = node.params;\n const nextToken = sourceCode.getTokenAfter(globalState);\n return fixer.removeRange([\n globalState.range[0],\n nextToken?.range[1] ?? globalState.range[1] + 1,\n ]);\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
|
|
@@ -34,25 +34,25 @@ var __values = (this && this.__values) || function(o) {
|
|
|
34
34
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
35
|
};
|
|
36
36
|
var _a;
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.messageId = void 0;
|
|
39
39
|
var path = __importStar(require("path"));
|
|
40
40
|
var rule_creator_1 = require("../../rule-creator");
|
|
41
41
|
var utils_1 = require("../../utils");
|
|
42
42
|
exports.messageId = 'preferSelectorInSelect';
|
|
43
|
-
exports
|
|
43
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
44
44
|
name: path.parse(__filename).name,
|
|
45
45
|
meta: {
|
|
46
46
|
type: 'suggestion',
|
|
47
47
|
ngrxModule: 'store',
|
|
48
48
|
docs: {
|
|
49
49
|
description: 'Using a selector in the `select` is preferred over `string` or `props drilling`.',
|
|
50
|
-
recommended: 'warn'
|
|
50
|
+
recommended: 'warn',
|
|
51
51
|
},
|
|
52
52
|
schema: [],
|
|
53
53
|
messages: (_a = {},
|
|
54
54
|
_a[exports.messageId] = 'Using `string` or `props drilling` is forbidden. Use a selector instead.',
|
|
55
|
-
_a)
|
|
55
|
+
_a),
|
|
56
56
|
},
|
|
57
57
|
defaultOptions: [],
|
|
58
58
|
create: function (context) {
|
|
@@ -75,19 +75,19 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
75
75
|
}
|
|
76
76
|
context.report({
|
|
77
77
|
node: argument,
|
|
78
|
-
messageId: exports.messageId
|
|
78
|
+
messageId: exports.messageId,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
83
|
finally {
|
|
84
84
|
try {
|
|
85
|
-
if (_c && !_c.done && (_a = _b
|
|
85
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
86
86
|
}
|
|
87
87
|
finally { if (e_1) throw e_1.error; }
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
_a;
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
92
|
});
|
|
93
93
|
//# sourceMappingURL=prefer-selector-in-select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-selector-in-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-selector-in-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAQqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,
|
|
1
|
+
{"version":3,"file":"prefer-selector-in-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-selector-in-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAQqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0EAA0E;eAC7E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,sBAAc,EAAC,UAAU,CAAC,eAAK,IAAA,wBAAgB,EAAC,UAAU,CAAC,CAAE,IAAjE,UACE,IAA6B;;;oBAE7B,KAAuB,IAAA,KAAA,SAAA,IAAI,CAAC,SAAS,CAAA,gBAAA,4BAAE;wBAAlC,IAAM,QAAQ,WAAA;wBACjB,IACE,CAAC,IAAA,iBAAS,EAAC,QAAQ,CAAC;4BACpB,CAAC,IAAA,iCAAyB,EAAC,QAAQ,CAAC;4BACpC,CAAC,IAAA,4BAAoB,EAAC,QAAQ,CAAC,EAC/B;4BACA,MAAM;yBACP;wBAED,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,QAAQ;4BACd,SAAS,mBAAA;yBACV,CAAC,CAAC;qBACJ;;;;;;;;;YACH,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isArrowFunctionExpression,\n isFunctionExpression,\n isLiteral,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'preferSelectorInSelect';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Using a selector in the `select` is preferred over `string` or `props drilling`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Using `string` or `props drilling` is forbidden. Use a selector instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n return {\n [`${pipeableSelect(storeNames)}, ${selectExpression(storeNames)}`](\n node: TSESTree.CallExpression\n ) {\n for (const argument of node.arguments) {\n if (\n !isLiteral(argument) &&\n !isArrowFunctionExpression(argument) &&\n !isFunctionExpression(argument)\n ) {\n break;\n }\n\n context.report({\n node: argument,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -34,14 +34,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
36
|
var _a;
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.prefixSelectorsWithSelectSuggest = exports.prefixSelectorsWithSelect = void 0;
|
|
39
39
|
var path = __importStar(require("path"));
|
|
40
40
|
var rule_creator_1 = require("../../rule-creator");
|
|
41
41
|
var utils_1 = require("../../utils");
|
|
42
42
|
exports.prefixSelectorsWithSelect = 'prefixSelectorsWithSelect';
|
|
43
43
|
exports.prefixSelectorsWithSelectSuggest = 'prefixSelectorsWithSelectSuggest';
|
|
44
|
-
exports
|
|
44
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
45
45
|
name: path.parse(__filename).name,
|
|
46
46
|
meta: {
|
|
47
47
|
type: 'suggestion',
|
|
@@ -50,13 +50,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
50
50
|
docs: {
|
|
51
51
|
description: 'The selector should start with "select", for example "selectThing".',
|
|
52
52
|
recommended: 'warn',
|
|
53
|
-
suggestion: true
|
|
53
|
+
suggestion: true,
|
|
54
54
|
},
|
|
55
55
|
schema: [],
|
|
56
56
|
messages: (_a = {},
|
|
57
57
|
_a[exports.prefixSelectorsWithSelect] = 'The selector should start with "select".',
|
|
58
58
|
_a[exports.prefixSelectorsWithSelectSuggest] = 'Prefix the selector with "select": `{{ name }}`.',
|
|
59
|
-
_a)
|
|
59
|
+
_a),
|
|
60
60
|
},
|
|
61
61
|
defaultOptions: [],
|
|
62
62
|
create: function (context) {
|
|
@@ -72,18 +72,18 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
72
72
|
{
|
|
73
73
|
messageId: exports.prefixSelectorsWithSelectSuggest,
|
|
74
74
|
data: {
|
|
75
|
-
name: suggestedName
|
|
75
|
+
name: suggestedName,
|
|
76
76
|
},
|
|
77
77
|
fix: function (fixer) {
|
|
78
78
|
var _a, _b;
|
|
79
79
|
return fixer.replaceTextRange([id.range[0], (_b = (_a = id.typeAnnotation) === null || _a === void 0 ? void 0 : _a.range[0]) !== null && _b !== void 0 ? _b : id.range[1]], suggestedName);
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
81
|
},
|
|
82
|
-
]
|
|
82
|
+
],
|
|
83
83
|
});
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
85
|
};
|
|
86
|
-
}
|
|
86
|
+
},
|
|
87
87
|
});
|
|
88
88
|
function getSuggestedName(name) {
|
|
89
89
|
var selectWord = 'select';
|
|
@@ -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,
|
|
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,MAA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,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] ?? id.range[1]) - 1,\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"]}
|