@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.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.d.ts +15 -0
- package/package.json +3 -5
- package/schematics/ng-add/index.d.ts +3 -0
- package/schematics/ng-add/index.js +32 -20
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +3 -0
- package/schematics/ng-add/schema.js.map +1 -1
- package/schematics/ng-add/schema.json +16 -51
- package/scripts/generate-config.d.ts +1 -0
- package/scripts/generate-config.js +73 -73
- package/scripts/generate-config.js.map +1 -1
- package/scripts/generate-docs.d.ts +1 -0
- package/scripts/generate-docs.js +33 -65
- package/scripts/generate-docs.js.map +1 -1
- package/scripts/generate-overview.d.ts +1 -0
- package/scripts/generate-overview.js +43 -75
- package/scripts/generate-overview.js.map +1 -1
- package/spec/utils/from-fixture.d.ts +8 -0
- package/spec/utils/from-fixture.js +62 -0
- package/spec/utils/from-fixture.js.map +1 -0
- package/spec/utils/index.d.ts +2 -0
- package/spec/utils/index.js +16 -19
- package/spec/utils/index.js.map +1 -1
- package/spec/utils/rule-tester.d.ts +5 -0
- package/spec/utils/rule-tester.js +23 -0
- package/spec/utils/rule-tester.js.map +1 -0
- package/src/configs/all.d.ts +7 -0
- package/src/configs/all.js +56 -32
- package/src/configs/all.js.map +1 -1
- package/src/configs/all.json +42 -0
- package/src/configs/component-store.d.ts +7 -0
- package/src/configs/component-store.js +23 -8
- package/src/configs/component-store.js.map +1 -1
- package/src/configs/component-store.json +9 -0
- package/src/configs/effects.d.ts +7 -0
- package/src/configs/effects.js +32 -11
- package/src/configs/effects.js.map +1 -1
- package/src/configs/effects.json +13 -0
- package/src/configs/operators.d.ts +7 -0
- package/src/configs/operators.js +28 -0
- package/src/configs/operators.js.map +1 -0
- package/src/configs/operators.json +7 -0
- package/src/configs/signals.d.ts +7 -0
- package/src/configs/signals.js +34 -0
- package/src/configs/signals.js.map +1 -0
- package/src/configs/signals.json +8 -0
- package/src/configs/store.d.ts +7 -0
- package/src/configs/store.js +38 -23
- package/src/configs/store.js.map +1 -1
- package/src/configs/store.json +24 -0
- package/src/index.d.ts +141 -0
- package/src/index.js +18 -3
- package/src/index.js.map +1 -1
- package/src/rule-creator.d.ts +24 -0
- package/src/rule-creator.js +12 -58
- package/src/rule-creator.js.map +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.d.ts +3 -0
- package/src/rules/component-store/avoid-combining-component-store-selectors.js +22 -47
- package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.d.ts +3 -0
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js +17 -20
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/updater-explicit-return-type.d.ts +3 -0
- package/src/rules/component-store/updater-explicit-return-type.js +17 -20
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/avoid-cyclic-effects.d.ts +4 -0
- package/src/rules/effects/avoid-cyclic-effects.js +47 -109
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
- package/src/rules/effects/no-dispatch-in-effects.d.ts +5 -0
- package/src/rules/effects/no-dispatch-in-effects.js +17 -21
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.d.ts +3 -0
- package/src/rules/effects/no-effects-in-providers.js +18 -49
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.d.ts +5 -0
- package/src/rules/effects/no-multiple-actions-in-effects.js +31 -24
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.d.ts +3 -0
- package/src/rules/effects/prefer-action-creator-in-of-type.js +10 -13
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.d.ts +4 -0
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +24 -43
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.d.ts +3 -0
- package/src/rules/effects/use-effects-lifecycle-interface.js +21 -24
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
- package/src/rules/index.d.ts +33 -0
- package/src/rules/index.js +69 -53
- package/src/rules/index.js.map +1 -1
- package/src/rules/operators/prefer-concat-latest-from.d.ts +7 -0
- package/src/rules/operators/prefer-concat-latest-from.js +123 -0
- package/src/rules/operators/prefer-concat-latest-from.js.map +1 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.d.ts +3 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js +59 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js.map +1 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.d.ts +4 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.js +72 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.js.map +1 -0
- package/src/rules/store/avoid-combining-selectors.d.ts +3 -0
- package/src/rules/store/avoid-combining-selectors.js +20 -45
- package/src/rules/store/avoid-combining-selectors.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.d.ts +3 -0
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +20 -47
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.d.ts +5 -0
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +33 -101
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/avoid-mapping-selectors.d.ts +3 -0
- package/src/rules/store/avoid-mapping-selectors.js +24 -30
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
- package/src/rules/store/good-action-hygiene.d.ts +3 -0
- package/src/rules/store/good-action-hygiene.js +14 -34
- package/src/rules/store/good-action-hygiene.js.map +1 -1
- package/src/rules/store/no-multiple-global-stores.d.ts +6 -0
- package/src/rules/store/no-multiple-global-stores.js +34 -96
- package/src/rules/store/no-multiple-global-stores.js.map +1 -1
- package/src/rules/store/no-reducer-in-key-names.d.ts +5 -0
- package/src/rules/store/no-reducer-in-key-names.js +16 -20
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
- package/src/rules/store/no-store-subscription.d.ts +3 -0
- package/src/rules/store/no-store-subscription.js +13 -16
- package/src/rules/store/no-store-subscription.js.map +1 -1
- package/src/rules/store/no-typed-global-store.d.ts +5 -0
- package/src/rules/store/no-typed-global-store.js +29 -70
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.d.ts +6 -0
- package/src/rules/store/on-function-explicit-return-type.js +23 -43
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.d.ts +3 -0
- package/src/rules/store/prefer-action-creator-in-dispatch.js +15 -18
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
- package/src/rules/store/prefer-action-creator.d.ts +3 -0
- package/src/rules/store/prefer-action-creator.js +10 -13
- package/src/rules/store/prefer-action-creator.js.map +1 -1
- package/src/rules/store/prefer-inline-action-props.d.ts +5 -0
- package/src/rules/store/prefer-inline-action-props.js +14 -18
- package/src/rules/store/prefer-inline-action-props.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.d.ts +5 -0
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +16 -37
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/rules/store/prefer-selector-in-select.d.ts +3 -0
- package/src/rules/store/prefer-selector-in-select.js +21 -46
- package/src/rules/store/prefer-selector-in-select.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.d.ts +5 -0
- package/src/rules/store/prefix-selectors-with-select.js +26 -39
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/select-style.d.ts +11 -0
- package/src/rules/store/select-style.js +53 -108
- package/src/rules/store/select-style.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.d.ts +6 -0
- package/src/rules/store/use-consistent-global-store-name.js +24 -80
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/docs.d.ts +1 -0
- package/src/utils/helper-functions/docs.js +1 -3
- package/src/utils/helper-functions/docs.js.map +1 -1
- package/src/utils/helper-functions/folder.d.ts +5 -0
- package/src/utils/helper-functions/folder.js +16 -88
- package/src/utils/helper-functions/folder.js.map +1 -1
- package/src/utils/helper-functions/guards.d.ts +97 -0
- package/src/utils/helper-functions/guards.js +27 -31
- package/src/utils/helper-functions/guards.js.map +1 -1
- package/src/utils/helper-functions/index.d.ts +6 -0
- package/src/utils/helper-functions/ngrx-modules.d.ts +8 -0
- package/src/utils/helper-functions/ngrx-modules.js +7 -6
- package/src/utils/helper-functions/ngrx-modules.js.map +1 -1
- package/src/utils/helper-functions/rules.d.ts +3 -0
- package/src/utils/helper-functions/rules.js +47 -0
- package/src/utils/helper-functions/rules.js.map +1 -0
- package/src/utils/helper-functions/utils.d.ts +48 -0
- package/src/utils/helper-functions/utils.js +68 -143
- package/src/utils/helper-functions/utils.js.map +1 -1
- package/src/utils/helper-functions/versions.d.ts +1 -0
- package/src/utils/helper-functions/versions.js +9 -10
- package/src/utils/helper-functions/versions.js.map +1 -1
- package/src/utils/index.d.ts +2 -0
- package/src/utils/selectors/index.d.ts +29 -0
- package/src/utils/selectors/index.js +30 -44
- package/src/utils/selectors/index.js.map +1 -1
- package/v9/index.d.ts +29 -0
- package/v9/index.js +38 -0
- package/v9/index.js.map +1 -0
- package/src/configs/all-requiring-type-checking.js +0 -46
- package/src/configs/all-requiring-type-checking.js.map +0 -1
- package/src/configs/component-store-strict.js +0 -15
- package/src/configs/component-store-strict.js.map +0 -1
- package/src/configs/effects-requiring-type-checking.js +0 -25
- package/src/configs/effects-requiring-type-checking.js.map +0 -1
- package/src/configs/effects-strict-requiring-type-checking.js +0 -25
- package/src/configs/effects-strict-requiring-type-checking.js.map +0 -1
- package/src/configs/effects-strict.js +0 -18
- package/src/configs/effects-strict.js.map +0 -1
- package/src/configs/index.js +0 -33
- package/src/configs/index.js.map +0 -1
- package/src/configs/recommended-requiring-type-checking.js +0 -46
- package/src/configs/recommended-requiring-type-checking.js.map +0 -1
- package/src/configs/recommended.js +0 -39
- package/src/configs/recommended.js.map +0 -1
- package/src/configs/store-strict.js +0 -30
- package/src/configs/store-strict.js.map +0 -1
- package/src/configs/strict-requiring-type-checking.js +0 -46
- package/src/configs/strict-requiring-type-checking.js.map +0 -1
- package/src/configs/strict.js +0 -39
- package/src/configs/strict.js.map +0 -1
- package/src/rules/effects/prefer-concat-latest-from.js +0 -153
- package/src/rules/effects/prefer-concat-latest-from.js.map +0 -1
|
@@ -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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAMqB;AAGR,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;SACrD;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,oBAAY,CAAC,EACZ,qEAAqE;YACvE,CAAC,2BAAmB,CAAC,EAAE,8BAA8B;SACtD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,OAAO;gBACL,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;gBAEpD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;oBACrC,iBAAiB;oBACjB,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;wBAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;wBAC9B,IACE,IAAA,4BAAoB,EAAC,MAAM,CAAC;4BAC5B,MAAM,CAAC,KAAK;4BACZ,IAAA,wBAAgB,EAAC,MAAM,CAAC,KAAK,CAAC;4BAC9B,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAC7B,CAAC;4BACD,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;4BAC/C,IAAI,IAAA,mCAA2B,EAAC,aAAa,CAAC,EAAE,CAAC;gCAC/C,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;4BACtC,CAAC;wBACH,CAAC;wBAED,SAAS;oBACX,CAAC;oBAED,IACE,CAAC,IAAA,yBAAiB,EAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC;wBAC5D,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,aAAa,EACvD,CAAC;wBACD,SAAS;oBACX,CAAC;oBAED,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;SACF,CAAC;QAEF,SAAS,MAAM,CAAC,aAAoD;YAClE,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,oBAAY;gBACvB,OAAO,EAAE;oBACP;wBACE,SAAS,EAAE,2BAAmB;wBAC9B,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;qBAC5C;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/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 },\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.typeArguments);\n }\n }\n\n continue;\n }\n\n if (\n !isTSTypeReference(identifier.typeAnnotation.typeAnnotation) ||\n !identifier.typeAnnotation.typeAnnotation.typeArguments\n ) {\n continue;\n }\n\n report(identifier.typeAnnotation.typeAnnotation.typeArguments);\n }\n },\n };\n\n function report(typeArguments: TSESTree.TSTypeParameterInstantiation) {\n context.report({\n node: typeArguments,\n messageId: noTypedStore,\n suggest: [\n {\n messageId: noTypedStoreSuggest,\n fix: (fixer) => fixer.remove(typeArguments),\n },\n ],\n });\n }\n },\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const onFunctionExplicitReturnType = "onFunctionExplicitReturnType";
|
|
3
|
+
export declare const onFunctionExplicitReturnTypeSuggest = "onFunctionExplicitReturnTypeSuggest";
|
|
4
|
+
type MessageIds = typeof onFunctionExplicitReturnType | typeof onFunctionExplicitReturnTypeSuggest;
|
|
5
|
+
declare const _default: TSESLint.RuleModule<MessageIds, readonly [], TSESLint.RuleListener>;
|
|
6
|
+
export default _default;
|
|
@@ -22,29 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
-
if (!m) return o;
|
|
28
|
-
var i = m.call(o), r, ar = [], e;
|
|
29
|
-
try {
|
|
30
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
-
}
|
|
32
|
-
catch (error) { e = { error: error }; }
|
|
33
|
-
finally {
|
|
34
|
-
try {
|
|
35
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
-
}
|
|
37
|
-
finally { if (e) throw e.error; }
|
|
38
|
-
}
|
|
39
|
-
return ar;
|
|
40
|
-
};
|
|
41
|
-
var _a;
|
|
42
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
26
|
exports.onFunctionExplicitReturnTypeSuggest = exports.onFunctionExplicitReturnType = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
30
|
+
const utils_2 = require("../../utils");
|
|
48
31
|
exports.onFunctionExplicitReturnType = 'onFunctionExplicitReturnType';
|
|
49
32
|
exports.onFunctionExplicitReturnTypeSuggest = 'onFunctionExplicitReturnTypeSuggest';
|
|
50
33
|
exports.default = (0, rule_creator_1.createRule)({
|
|
@@ -55,48 +38,45 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
55
38
|
ngrxModule: 'store',
|
|
56
39
|
docs: {
|
|
57
40
|
description: '`On` function should have an explicit return type.',
|
|
58
|
-
recommended: 'warn',
|
|
59
|
-
suggestion: true,
|
|
60
41
|
},
|
|
61
42
|
schema: [],
|
|
62
|
-
messages:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
43
|
+
messages: {
|
|
44
|
+
[exports.onFunctionExplicitReturnType]: '`On` functions should have an explicit return type when using arrow functions: `on(action, (state): State => {}`.',
|
|
45
|
+
[exports.onFunctionExplicitReturnTypeSuggest]: 'Add the explicit return type `State` (if the interface/type is named differently you need to manually correct the return type).',
|
|
46
|
+
},
|
|
66
47
|
},
|
|
67
48
|
defaultOptions: [],
|
|
68
|
-
create:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_a[utils_1.onFunctionWithoutType] = function (node) {
|
|
49
|
+
create: (context) => {
|
|
50
|
+
const sourceCode = context.getSourceCode();
|
|
51
|
+
return {
|
|
52
|
+
[utils_2.onFunctionWithoutType](node) {
|
|
73
53
|
context.report({
|
|
74
|
-
node
|
|
54
|
+
node,
|
|
75
55
|
messageId: exports.onFunctionExplicitReturnType,
|
|
76
56
|
suggest: [
|
|
77
57
|
{
|
|
78
58
|
messageId: exports.onFunctionExplicitReturnTypeSuggest,
|
|
79
|
-
fix:
|
|
59
|
+
fix: (fixer) => getFixes(node, sourceCode, fixer),
|
|
80
60
|
},
|
|
81
61
|
],
|
|
82
62
|
});
|
|
83
63
|
},
|
|
84
|
-
|
|
64
|
+
};
|
|
85
65
|
},
|
|
86
66
|
});
|
|
87
67
|
function getFixes(node, sourceCode, fixer) {
|
|
88
|
-
|
|
68
|
+
const { params } = node;
|
|
89
69
|
if (params.length === 0) {
|
|
90
|
-
|
|
70
|
+
const [, closingParen] = sourceCode.getTokens(node);
|
|
91
71
|
return fixer.insertTextAfter(closingParen, ': State');
|
|
92
72
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
73
|
+
const [firstParam] = params;
|
|
74
|
+
const lastParam = (0, utils_2.getLast)(params);
|
|
75
|
+
const previousToken = sourceCode.getTokenBefore(firstParam);
|
|
76
|
+
const isParenthesized = previousToken && utils_1.ASTUtils.isOpeningParenToken(previousToken);
|
|
97
77
|
if (isParenthesized) {
|
|
98
|
-
|
|
99
|
-
return fixer.insertTextAfter(nextToken
|
|
78
|
+
const nextToken = sourceCode.getTokenAfter(lastParam);
|
|
79
|
+
return fixer.insertTextAfter(nextToken ?? lastParam, ': State');
|
|
100
80
|
}
|
|
101
81
|
return [
|
|
102
82
|
fixer.insertTextBefore(firstParam, '('),
|
|
@@ -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":"
|
|
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,oDAAoD;AACpD,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA6D;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;SAClE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,oCAA4B,CAAC,EAC5B,mHAAmH;YACrH,CAAC,2CAAmC,CAAC,EACnC,iIAAiI;SACpI;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C,OAAO;YACL,CAAC,6BAAqB,CAAC,CAAC,IAAsC;gBAC5D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,oCAA4B;oBACvC,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,2CAAmC;4BAC9C,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC;yBAClD;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,QAAQ,CACf,IAAsC,EACtC,UAAyC,EACzC,KAAyB;IAEzB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAExB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,EAAE,YAAY,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,eAAe,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,MAAM,CAAC,CAAC;IAClC,MAAM,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,eAAe,GACnB,aAAa,IAAI,gBAAQ,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAE/D,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,IAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC;QACvC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;KACpC,CAAC;AACb,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/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 },\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"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const messageId = "preferActionCreatorInDispatch";
|
|
2
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferActionCreatorInDispatch", readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export default _default;
|
|
@@ -22,12 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var _a;
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
26
|
exports.messageId = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
31
30
|
exports.messageId = 'preferActionCreatorInDispatch';
|
|
32
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
33
32
|
name: path.parse(__filename).name,
|
|
@@ -36,35 +35,33 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
36
35
|
ngrxModule: 'store',
|
|
37
36
|
docs: {
|
|
38
37
|
description: 'Using `action creator` in `dispatch` is preferred over `object` or old `Action`.',
|
|
39
|
-
recommended: 'warn',
|
|
40
38
|
},
|
|
41
39
|
schema: [],
|
|
42
|
-
messages:
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: 'Using `object` or old `Action` is forbidden. Use `action creator` instead.',
|
|
42
|
+
},
|
|
45
43
|
},
|
|
46
44
|
defaultOptions: [],
|
|
47
|
-
create:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
|
|
47
|
+
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
51
48
|
if (!storeNames) {
|
|
52
49
|
return {};
|
|
53
50
|
}
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
return {
|
|
52
|
+
[`${(0, utils_1.dispatchExpression)(storeNames)} :matches(NewExpression, :not(NewExpression) > ObjectExpression)`](node) {
|
|
53
|
+
const nearestUpperCallExpression = (0, utils_1.getNearestUpperNodeFrom)(node, utils_1.isCallExpression);
|
|
54
|
+
const isStoreDispatchImmediateParent = nearestUpperCallExpression !== undefined &&
|
|
58
55
|
(0, utils_1.isCallExpressionWith)(nearestUpperCallExpression, storeNames, 'dispatch');
|
|
59
56
|
if (!isStoreDispatchImmediateParent) {
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
62
59
|
context.report({
|
|
63
|
-
node
|
|
60
|
+
node,
|
|
64
61
|
messageId: exports.messageId,
|
|
65
62
|
});
|
|
66
63
|
},
|
|
67
|
-
|
|
64
|
+
};
|
|
68
65
|
},
|
|
69
66
|
});
|
|
70
67
|
//# 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":"
|
|
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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAOqB;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;SACrF;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,4EAA4E;SAC/E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,CAAC,GAAG,IAAA,0BAAkB,EACpB,UAAU,CACX,kEAAkE,CAAC,CAClE,IAAwD;gBAExD,MAAM,0BAA0B,GAAG,IAAA,+BAAuB,EACxD,IAAI,EACJ,wBAAgB,CACjB,CAAC;gBACF,MAAM,8BAA8B,GAClC,0BAA0B,KAAK,SAAS;oBACxC,IAAA,4BAAoB,EAClB,0BAA0B,EAC1B,UAAU,EACV,UAAU,CACX,CAAC;gBAEJ,IAAI,CAAC,8BAA8B,EAAE,CAAC;oBACpC,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\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 },\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"]}
|
|
@@ -22,11 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var _a;
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
26
|
exports.messageId = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
30
29
|
exports.messageId = 'preferActionCreator';
|
|
31
30
|
exports.default = (0, rule_creator_1.createRule)({
|
|
32
31
|
name: path.parse(__filename).name,
|
|
@@ -35,24 +34,22 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
35
34
|
ngrxModule: 'store',
|
|
36
35
|
docs: {
|
|
37
36
|
description: 'Using `action creator` is preferred over `Action class`.',
|
|
38
|
-
recommended: 'warn',
|
|
39
37
|
},
|
|
40
38
|
schema: [],
|
|
41
|
-
messages:
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
messages: {
|
|
40
|
+
[exports.messageId]: 'Using `Action class` is forbidden. Use `action creator` instead.',
|
|
41
|
+
},
|
|
44
42
|
},
|
|
45
43
|
defaultOptions: [],
|
|
46
|
-
create:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_a["ClassDeclaration:has(TSClassImplements:matches([expression.name='Action'], [expression.property.name='Action'])):has(PropertyDefinition[key.name='type'])"] = function (node) {
|
|
44
|
+
create: (context) => {
|
|
45
|
+
return {
|
|
46
|
+
[`ClassDeclaration:has(TSClassImplements:matches([expression.name='Action'], [expression.property.name='Action'])):has(PropertyDefinition[key.name='type'])`](node) {
|
|
50
47
|
context.report({
|
|
51
|
-
node
|
|
48
|
+
node,
|
|
52
49
|
messageId: exports.messageId,
|
|
53
50
|
});
|
|
54
51
|
},
|
|
55
|
-
|
|
52
|
+
};
|
|
56
53
|
},
|
|
57
54
|
});
|
|
58
55
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"prefer-action-creator.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefer-action-creator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;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;SACxE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,kEAAkE;SACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,2JAA2J,CAAC,CAC3J,IAA+B;gBAE/B,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\n\nexport const 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 },\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"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const preferInlineActionProps = "preferInlineActionProps";
|
|
2
|
+
export declare const preferInlineActionPropsSuggest = "preferInlineActionPropsSuggest";
|
|
3
|
+
type MessageIds = typeof preferInlineActionProps | typeof preferInlineActionPropsSuggest;
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
@@ -22,12 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var _a;
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
26
|
exports.preferInlineActionPropsSuggest = exports.preferInlineActionProps = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
31
30
|
exports.preferInlineActionProps = 'preferInlineActionProps';
|
|
32
31
|
exports.preferInlineActionPropsSuggest = 'preferInlineActionPropsSuggest';
|
|
33
32
|
exports.default = (0, rule_creator_1.createRule)({
|
|
@@ -38,35 +37,32 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
38
37
|
ngrxModule: 'store',
|
|
39
38
|
docs: {
|
|
40
39
|
description: 'Prefer using inline types instead of interfaces, types or classes.',
|
|
41
|
-
recommended: 'warn',
|
|
42
|
-
suggestion: true,
|
|
43
40
|
},
|
|
44
41
|
schema: [],
|
|
45
|
-
messages:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
messages: {
|
|
43
|
+
[exports.preferInlineActionProps]: 'Use inline types instead of interfaces, types or classes.',
|
|
44
|
+
[exports.preferInlineActionPropsSuggest]: 'Change to inline types.',
|
|
45
|
+
},
|
|
49
46
|
},
|
|
50
47
|
defaultOptions: [],
|
|
51
|
-
create:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_a[utils_1.actionCreatorPropsComputed] = function (node) {
|
|
48
|
+
create: (context) => {
|
|
49
|
+
return {
|
|
50
|
+
[utils_1.actionCreatorPropsComputed](node) {
|
|
55
51
|
context.report({
|
|
56
|
-
node
|
|
52
|
+
node,
|
|
57
53
|
messageId: exports.preferInlineActionProps,
|
|
58
54
|
suggest: [
|
|
59
55
|
{
|
|
60
56
|
messageId: exports.preferInlineActionPropsSuggest,
|
|
61
|
-
fix:
|
|
57
|
+
fix: (fixer) => [
|
|
62
58
|
fixer.insertTextBefore(node, '{name: '),
|
|
63
59
|
fixer.insertTextAfter(node, '}'),
|
|
64
|
-
]
|
|
60
|
+
],
|
|
65
61
|
},
|
|
66
62
|
],
|
|
67
63
|
});
|
|
68
64
|
},
|
|
69
|
-
|
|
65
|
+
};
|
|
70
66
|
},
|
|
71
67
|
});
|
|
72
68
|
//# 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":"
|
|
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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAyD;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;SACvE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,+BAAuB,CAAC,EACvB,2DAA2D;YAC7D,CAAC,sCAA8B,CAAC,EAAE,yBAAyB;SAC5D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,kCAA0B,CAAC,CAAC,IAA8B;gBACzD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,+BAAuB;oBAClC,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,sCAA8B;4BACzC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;gCACd,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC;gCACvC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC;6BACjC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\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 },\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"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const preferOneGenericInCreateForFeatureSelector = "preferOneGenericInCreateForFeatureSelector";
|
|
2
|
+
export declare const preferOneGenericInCreateForFeatureSelectorSuggest = "preferOneGenericInCreateForFeatureSelectorSuggest";
|
|
3
|
+
type MessageIds = typeof preferOneGenericInCreateForFeatureSelector | typeof preferOneGenericInCreateForFeatureSelectorSuggest;
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
@@ -22,27 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
-
if (!m) return o;
|
|
28
|
-
var i = m.call(o), r, ar = [], e;
|
|
29
|
-
try {
|
|
30
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
-
}
|
|
32
|
-
catch (error) { e = { error: error }; }
|
|
33
|
-
finally {
|
|
34
|
-
try {
|
|
35
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
-
}
|
|
37
|
-
finally { if (e) throw e.error; }
|
|
38
|
-
}
|
|
39
|
-
return ar;
|
|
40
|
-
};
|
|
41
|
-
var _a;
|
|
42
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
26
|
exports.preferOneGenericInCreateForFeatureSelectorSuggest = exports.preferOneGenericInCreateForFeatureSelector = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
46
29
|
exports.preferOneGenericInCreateForFeatureSelector = 'preferOneGenericInCreateForFeatureSelector';
|
|
47
30
|
exports.preferOneGenericInCreateForFeatureSelectorSuggest = 'preferOneGenericInCreateForFeatureSelectorSuggest';
|
|
48
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
@@ -53,41 +36,37 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
53
36
|
ngrxModule: 'store',
|
|
54
37
|
docs: {
|
|
55
38
|
description: 'Prefer using a single generic to define the feature state.',
|
|
56
|
-
recommended: 'warn',
|
|
57
|
-
suggestion: true,
|
|
58
39
|
},
|
|
59
40
|
schema: [],
|
|
60
|
-
messages:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
messages: {
|
|
42
|
+
[exports.preferOneGenericInCreateForFeatureSelector]: 'Use a single generic to define the feature state.',
|
|
43
|
+
[exports.preferOneGenericInCreateForFeatureSelectorSuggest]: 'Remove the global state generic.',
|
|
44
|
+
},
|
|
64
45
|
},
|
|
65
46
|
defaultOptions: [],
|
|
66
|
-
create:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
_a["CallExpression[callee.name='createFeatureSelector'] > TSTypeParameterInstantiation[params.length>1]"] = function (node) {
|
|
47
|
+
create: (context) => {
|
|
48
|
+
const sourceCode = context.getSourceCode();
|
|
49
|
+
return {
|
|
50
|
+
[`CallExpression[callee.name='createFeatureSelector'] > TSTypeParameterInstantiation[params.length>1]`](node) {
|
|
71
51
|
context.report({
|
|
72
|
-
node
|
|
52
|
+
node,
|
|
73
53
|
messageId: exports.preferOneGenericInCreateForFeatureSelector,
|
|
74
54
|
suggest: [
|
|
75
55
|
{
|
|
76
56
|
messageId: exports.preferOneGenericInCreateForFeatureSelectorSuggest,
|
|
77
|
-
fix:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var nextToken = sourceCode.getTokenAfter(globalState);
|
|
57
|
+
fix: (fixer) => {
|
|
58
|
+
const [globalState] = node.params;
|
|
59
|
+
const nextToken = sourceCode.getTokenAfter(globalState);
|
|
81
60
|
return fixer.removeRange([
|
|
82
61
|
globalState.range[0],
|
|
83
|
-
|
|
62
|
+
nextToken?.range[1] ?? globalState.range[1] + 1,
|
|
84
63
|
]);
|
|
85
64
|
},
|
|
86
65
|
},
|
|
87
66
|
],
|
|
88
67
|
});
|
|
89
68
|
},
|
|
90
|
-
|
|
69
|
+
};
|
|
91
70
|
},
|
|
92
71
|
});
|
|
93
72
|
//# 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":"
|
|
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,2CAA6B;AAC7B,qDAAgD;AAEnC,QAAA,0CAA0C,GACrD,4CAA4C,CAAC;AAClC,QAAA,iDAAiD,GAC5D,mDAAmD,CAAC;AAOtD,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,4DAA4D;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,kDAA0C,CAAC,EAC1C,mDAAmD;YACrD,CAAC,yDAAiD,CAAC,EACjD,kCAAkC;SACrC;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C,OAAO;YACL,CAAC,qGAAqG,CAAC,CACrG,IAA2C;gBAE3C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,kDAA0C;oBACrD,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,yDAAiD;4BAC5D,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gCACb,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;gCAClC,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gCACxD,OAAO,KAAK,CAAC,WAAW,CAAC;oCACvB,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;oCACpB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;iCAChD,CAAC,CAAC;4BACL,CAAC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\n\nexport const 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 },\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"]}
|