@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.d.ts +15 -0
- package/package.json +4 -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 +18 -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 +13 -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 +153 -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 +35 -0
- package/src/rules/index.js +74 -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 +10 -11
- 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
package/jest.config.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
displayName: string;
|
|
3
|
+
preset: string;
|
|
4
|
+
coverageDirectory: string;
|
|
5
|
+
setupFilesAfterEnv: string[];
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.(ts|mjs|js|html)$': (string | {
|
|
8
|
+
tsconfig: string;
|
|
9
|
+
stringifyContentPathRegex: string;
|
|
10
|
+
})[];
|
|
11
|
+
};
|
|
12
|
+
transformIgnorePatterns: string[];
|
|
13
|
+
snapshotSerializers: string[];
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/eslint-plugin",
|
|
3
|
-
"version": "18.0.0-
|
|
3
|
+
"version": "18.0.0-rc.1",
|
|
4
4
|
"description": "NgRx ESLint Plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,15 +40,14 @@
|
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@typescript-eslint/experimental-utils": "^5.4.0",
|
|
44
|
-
"eslint-etc": "^5.1.0",
|
|
45
43
|
"semver": "^7.3.5",
|
|
46
44
|
"strip-json-comments": "3.1.1"
|
|
47
45
|
},
|
|
48
46
|
"peerDependencies": {
|
|
49
|
-
"eslint": "
|
|
47
|
+
"eslint": "^8.57.0 || ^9.0.0",
|
|
48
|
+
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0-alpha.20",
|
|
50
49
|
"typescript": "*"
|
|
51
50
|
},
|
|
52
51
|
"main": "./src/index.js",
|
|
53
52
|
"type": "commonjs"
|
|
54
|
-
}
|
|
53
|
+
}
|
|
@@ -3,47 +3,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
7
7
|
function addNgRxESLintPlugin(schema) {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var eslint = (_a = host.read(eslintConfigPath)) === null || _a === void 0 ? void 0 : _a.toString('utf-8');
|
|
8
|
+
return (host, context) => {
|
|
9
|
+
const eslintConfigPath = '.eslintrc.json';
|
|
10
|
+
const docs = 'https://ngrx.io/guide/eslint-plugin';
|
|
11
|
+
const eslint = host.read(eslintConfigPath)?.toString('utf-8');
|
|
13
12
|
if (!eslint) {
|
|
14
|
-
context.logger.warn(
|
|
13
|
+
context.logger.warn(`
|
|
14
|
+
Could not find the ESLint config at \`${eslintConfigPath}\`.
|
|
15
|
+
The NgRx ESLint Plugin is installed but not configured.
|
|
16
|
+
|
|
17
|
+
Please see ${docs} to configure the NgRx ESLint Plugin.
|
|
18
|
+
`);
|
|
15
19
|
return host;
|
|
16
20
|
}
|
|
17
21
|
try {
|
|
18
|
-
|
|
22
|
+
const json = JSON.parse((0, strip_json_comments_1.default)(eslint));
|
|
19
23
|
if (json.overrides) {
|
|
20
|
-
if (!json.overrides.some(
|
|
21
|
-
var _a;
|
|
22
|
-
return (_a = override.extends) === null || _a === void 0 ? void 0 : _a.some(function (extend) {
|
|
23
|
-
return extend.startsWith('plugin:@ngrx');
|
|
24
|
-
});
|
|
25
|
-
})) {
|
|
24
|
+
if (!json.overrides.some((override) => override.extends?.some((extend) => extend.startsWith('plugin:@ngrx')))) {
|
|
26
25
|
json.overrides.push(configurePlugin(schema.config));
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
else if (!
|
|
28
|
+
else if (!json.extends?.some((extend) => extend.startsWith('plugin:@ngrx'))) {
|
|
30
29
|
json.overrides = [configurePlugin(schema.config)];
|
|
31
30
|
}
|
|
32
31
|
host.overwrite(eslintConfigPath, JSON.stringify(json, null, 2));
|
|
33
|
-
context.logger.info(
|
|
32
|
+
context.logger.info(`
|
|
33
|
+
The NgRx ESLint Plugin is installed and configured with the '${schema.config}' config.
|
|
34
|
+
|
|
35
|
+
Take a look at the docs at ${docs} if you want to change the default configuration.
|
|
36
|
+
`);
|
|
34
37
|
return host;
|
|
35
38
|
}
|
|
36
39
|
catch (err) {
|
|
37
|
-
|
|
38
|
-
?
|
|
40
|
+
const detailsContent = err instanceof Error
|
|
41
|
+
? `
|
|
42
|
+
Details:
|
|
43
|
+
${err.message}
|
|
44
|
+
`
|
|
39
45
|
: '';
|
|
40
|
-
context.logger.warn(
|
|
46
|
+
context.logger.warn(`
|
|
47
|
+
Something went wrong while adding the NgRx ESLint Plugin.
|
|
48
|
+
The NgRx ESLint Plugin is installed but not configured.
|
|
49
|
+
|
|
50
|
+
Please see ${docs} to configure the NgRx ESLint Plugin.
|
|
51
|
+
${detailsContent}
|
|
52
|
+
`);
|
|
41
53
|
}
|
|
42
54
|
};
|
|
43
55
|
function configurePlugin(config) {
|
|
44
56
|
return {
|
|
45
57
|
files: ['*.ts'],
|
|
46
|
-
extends: [
|
|
58
|
+
extends: [`plugin:@ngrx/${config}`],
|
|
47
59
|
};
|
|
48
60
|
}
|
|
49
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,8EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,MAAM,IAAI,GAAG,qCAAqC,CAAC;QAEnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;wCACc,gBAAgB;;;aAG3C,IAAI;CAChB,CAAC,CAAC;YACG,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,6BAAiB,EAAC,MAAM,CAAC,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IACE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE,CACrC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE,CACrC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAClC,CACF,EACD,CAAC;oBACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;iBAAM,IACL,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,EACvE,CAAC;gBACD,IAAI,CAAC,SAAS,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACpD,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAEhE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;iEACuC,MAAM,CAAC,MAAM;;+BAE/C,IAAI;GAChC,CAAC,CAAC;YACC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,cAAc,GAClB,GAAG,YAAY,KAAK;gBAClB,CAAC,CAAC;;EAEV,GAAG,CAAC,OAAO;CACZ;gBACS,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;;;;aAIb,IAAI;EACf,cAAc;CACf,CAAC,CAAC;QACC,CAAC;IACH,CAAC,CAAC;IACF,SAAS,eAAe,CAAC,MAAwB;QAC/C,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,OAAO,EAAE,CAAC,gBAAgB,MAAM,EAAE,CAAC;SACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAjED,sCAiEC","sourcesContent":["import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport stripJsonComments from 'strip-json-comments';\nimport type { Schema } from './schema';\n\nexport default function addNgRxESLintPlugin(schema: Schema): Rule {\n return (host: Tree, context: SchematicContext) => {\n const eslintConfigPath = '.eslintrc.json';\n const docs = 'https://ngrx.io/guide/eslint-plugin';\n\n const eslint = host.read(eslintConfigPath)?.toString('utf-8');\n if (!eslint) {\n context.logger.warn(`\nCould not find the ESLint config at \\`${eslintConfigPath}\\`.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n`);\n return host;\n }\n\n try {\n const json = JSON.parse(stripJsonComments(eslint));\n if (json.overrides) {\n if (\n !json.overrides.some((override: any) =>\n override.extends?.some((extend: any) =>\n extend.startsWith('plugin:@ngrx')\n )\n )\n ) {\n json.overrides.push(configurePlugin(schema.config));\n }\n } else if (\n !json.extends?.some((extend: any) => extend.startsWith('plugin:@ngrx'))\n ) {\n json.overrides = [configurePlugin(schema.config)];\n }\n\n host.overwrite(eslintConfigPath, JSON.stringify(json, null, 2));\n\n context.logger.info(`\n The NgRx ESLint Plugin is installed and configured with the '${schema.config}' config.\n\n Take a look at the docs at ${docs} if you want to change the default configuration.\n `);\n return host;\n } catch (err) {\n const detailsContent =\n err instanceof Error\n ? `\nDetails:\n${err.message}\n`\n : '';\n context.logger.warn(`\nSomething went wrong while adding the NgRx ESLint Plugin.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n${detailsContent}\n`);\n }\n };\n function configurePlugin(config: Schema['config']): Record<string, unknown> {\n return {\n files: ['*.ts'],\n extends: [`plugin:@ngrx/${config}`],\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/schema.ts"],"names":[],"mappings":"","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface Schema {\n config
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/schema.ts"],"names":[],"mappings":"","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface Schema {\n config: 'all' | 'store' | 'effects' | 'component-store' | 'signals';\n}\n"]}
|
|
@@ -7,77 +7,42 @@
|
|
|
7
7
|
"config": {
|
|
8
8
|
"description": "The config to be used.",
|
|
9
9
|
"type": "string",
|
|
10
|
-
"default": "
|
|
10
|
+
"default": "all",
|
|
11
11
|
"enum": [
|
|
12
|
-
"recommended",
|
|
13
|
-
"recommended-requiring-type-checking",
|
|
14
|
-
"strict",
|
|
15
|
-
"strict-requiring-type-checking",
|
|
16
|
-
"store",
|
|
17
|
-
"store-strict",
|
|
18
|
-
"effects",
|
|
19
|
-
"effects-requiring-type-checking",
|
|
20
|
-
"effects-strict",
|
|
21
|
-
"component-store",
|
|
22
|
-
"component-store-strict",
|
|
23
12
|
"all",
|
|
24
|
-
"
|
|
13
|
+
"component-store",
|
|
14
|
+
"effects",
|
|
15
|
+
"operators",
|
|
16
|
+
"signals",
|
|
17
|
+
"store"
|
|
25
18
|
],
|
|
26
19
|
"x-prompt": {
|
|
27
20
|
"message": "Which ESLint configuration would you like to use?",
|
|
28
21
|
"type": "list",
|
|
29
22
|
"items": [
|
|
30
23
|
{
|
|
31
|
-
"value": "
|
|
32
|
-
"label": "
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"value": "recommended-requiring-type-checking",
|
|
36
|
-
"label": "recommended with type checking"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"value": "strict",
|
|
40
|
-
"label": "strict"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"value": "strict-requiring-type-checking",
|
|
44
|
-
"label": "strict with type checking"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"value": "store",
|
|
48
|
-
"label": "store"
|
|
24
|
+
"value": "all",
|
|
25
|
+
"label": "all"
|
|
49
26
|
},
|
|
50
27
|
{
|
|
51
|
-
"value": "store
|
|
52
|
-
"label": "
|
|
28
|
+
"value": "component-store",
|
|
29
|
+
"label": "component-store"
|
|
53
30
|
},
|
|
54
31
|
{
|
|
55
32
|
"value": "effects",
|
|
56
33
|
"label": "effects"
|
|
57
34
|
},
|
|
58
35
|
{
|
|
59
|
-
"value": "
|
|
60
|
-
"label": "
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"value": "effects-strict",
|
|
64
|
-
"label": "strict effects"
|
|
36
|
+
"value": "operators",
|
|
37
|
+
"label": "operators"
|
|
65
38
|
},
|
|
66
39
|
{
|
|
67
|
-
"value": "
|
|
68
|
-
"label": "
|
|
40
|
+
"value": "signals",
|
|
41
|
+
"label": "signals"
|
|
69
42
|
},
|
|
70
43
|
{
|
|
71
|
-
"value": "
|
|
72
|
-
"label": "
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"value": "all",
|
|
76
|
-
"label": "all"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"value": "all-requiring-type-checking",
|
|
80
|
-
"label": "all with type checking"
|
|
44
|
+
"value": "store",
|
|
45
|
+
"label": "store"
|
|
81
46
|
}
|
|
82
47
|
]
|
|
83
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
writeConfig('
|
|
38
|
-
writeConfig('
|
|
39
|
-
writeConfig('
|
|
40
|
-
writeConfig('
|
|
41
|
-
writeConfig('
|
|
42
|
-
writeConfig('
|
|
43
|
-
writeConfig(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
writeConfig('effects-requiring-type-checking', function (rule) { return rule.meta.ngrxModule === 'effects'; });
|
|
48
|
-
writeConfig('effects-strict-requiring-type-checking', function (rule) { return rule.meta.ngrxModule === 'effects'; }, function () { return 'error'; });
|
|
49
|
-
writeConfig('component-store', function (rule) {
|
|
50
|
-
var _a;
|
|
51
|
-
return rule.meta.ngrxModule === 'component-store' &&
|
|
52
|
-
!((_a = rule.meta.docs) === null || _a === void 0 ? void 0 : _a.requiresTypeChecking);
|
|
53
|
-
});
|
|
54
|
-
writeConfig('component-store-strict', function (rule) {
|
|
55
|
-
var _a;
|
|
56
|
-
return rule.meta.ngrxModule === 'component-store' &&
|
|
57
|
-
!((_a = rule.meta.docs) === null || _a === void 0 ? void 0 : _a.requiresTypeChecking);
|
|
58
|
-
}, function () { return 'error'; });
|
|
59
|
-
function writeConfig(configName, predicate, setting) {
|
|
60
|
-
if (setting === void 0) { setting = function (rule) { var _a; return ((_a = rule.meta.docs) === null || _a === void 0 ? void 0 : _a.recommended) || 'warn'; }; }
|
|
61
|
-
var rulesForConfig = Object.entries(rules_1.rules).filter(function (_a) {
|
|
62
|
-
var _b = __read(_a, 2), _ = _b[0], rule = _b[1];
|
|
63
|
-
return predicate(rule);
|
|
64
|
-
});
|
|
65
|
-
var configRules = rulesForConfig.reduce(function (rules, _a) {
|
|
66
|
-
var _b = __read(_a, 2), ruleName = _b[0], rule = _b[1];
|
|
67
|
-
rules["".concat(RULE_MODULE, "/").concat(ruleName)] = setting(rule);
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const prettier_1 = require("prettier");
|
|
6
|
+
const rules_1 = require("../src/utils/helper-functions/rules");
|
|
7
|
+
const prettierConfig = prettier_1.resolveConfig.sync(__dirname);
|
|
8
|
+
const RULE_MODULE = '@ngrx';
|
|
9
|
+
const CONFIG_DIRECTORY = './modules/eslint-plugin/src/configs/';
|
|
10
|
+
writeConfig('all', (_rule) => true);
|
|
11
|
+
writeConfig('store', (rule) => rule.meta.ngrxModule === 'store');
|
|
12
|
+
writeConfig('effects', (rule) => rule.meta.ngrxModule === 'effects');
|
|
13
|
+
writeConfig('component-store', (rule) => rule.meta.ngrxModule === 'component-store');
|
|
14
|
+
writeConfig('operators', (rule) => rule.meta.ngrxModule === 'operators');
|
|
15
|
+
writeConfig('signals', (rule) => rule.meta.ngrxModule === 'signals');
|
|
16
|
+
function writeConfig(configName, predicate) {
|
|
17
|
+
const rulesForConfig = Object.entries(rules_1.rulesForGenerate).filter(([_, rule]) => predicate(rule));
|
|
18
|
+
const configRules = rulesForConfig.reduce((rules, [ruleName, _rule]) => {
|
|
19
|
+
rules[`${RULE_MODULE}/${ruleName}`] = 'error';
|
|
68
20
|
return rules;
|
|
69
21
|
}, {});
|
|
70
|
-
|
|
71
|
-
var _b;
|
|
72
|
-
var _c = __read(_a, 2), _ = _c[0], rule = _c[1];
|
|
73
|
-
return (_b = rule.meta.docs) === null || _b === void 0 ? void 0 : _b.requiresTypeChecking;
|
|
74
|
-
})
|
|
22
|
+
const requireParserOptions = rulesForConfig.some(([_, rule]) => rule.meta.docs?.requiresTypeChecking)
|
|
75
23
|
? {
|
|
76
24
|
ecmaVersion: 2020,
|
|
77
25
|
sourceType: 'module',
|
|
78
26
|
project: './tsconfig.json',
|
|
79
27
|
}
|
|
80
28
|
: null;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
29
|
+
const tsCode = `
|
|
30
|
+
/**
|
|
31
|
+
* DO NOT EDIT
|
|
32
|
+
* This file is generated
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
36
|
+
|
|
37
|
+
export default (
|
|
38
|
+
plugin: TSESLint.FlatConfig.Plugin,
|
|
39
|
+
parser: TSESLint.FlatConfig.Parser,
|
|
40
|
+
): TSESLint.FlatConfig.ConfigArray => [
|
|
41
|
+
{
|
|
42
|
+
name: 'ngrx/base',
|
|
43
|
+
languageOptions: {
|
|
44
|
+
parser,
|
|
45
|
+
sourceType: 'module',
|
|
46
|
+
},
|
|
47
|
+
plugins: {
|
|
48
|
+
'@ngrx': plugin,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'ngrx/${configName}',
|
|
53
|
+
languageOptions: {
|
|
54
|
+
parser,
|
|
55
|
+
${requireParserOptions
|
|
56
|
+
? `parserOptions: ${JSON.stringify(requireParserOptions, null, 2)},`
|
|
57
|
+
: ''}
|
|
58
|
+
},
|
|
59
|
+
rules: ${JSON.stringify(configRules, null, 2)}
|
|
60
|
+
},
|
|
61
|
+
];`;
|
|
62
|
+
const tsConfigFormatted = (0, prettier_1.format)(tsCode, {
|
|
63
|
+
parser: 'typescript',
|
|
64
|
+
...prettierConfig,
|
|
65
|
+
});
|
|
66
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(CONFIG_DIRECTORY, `${configName}.ts`), tsConfigFormatted);
|
|
67
|
+
const jsonConfig = {
|
|
68
|
+
parser: '@typescript-eslint/parser',
|
|
69
|
+
plugins: ['@ngrx'],
|
|
70
|
+
rules: configRules,
|
|
71
|
+
};
|
|
72
|
+
if (requireParserOptions) {
|
|
73
|
+
jsonConfig.parserOptions = {
|
|
74
|
+
ecmaVersion: 2020,
|
|
75
|
+
sourceType: 'module',
|
|
76
|
+
project: './tsconfig.json',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const jsonConfigFormatted = (0, prettier_1.format)(JSON.stringify(jsonConfig, null, 2), {
|
|
80
|
+
parser: 'json',
|
|
81
|
+
...prettierConfig,
|
|
82
|
+
});
|
|
83
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(CONFIG_DIRECTORY, `${configName}.json`), jsonConfigFormatted);
|
|
84
84
|
}
|
|
85
85
|
//# sourceMappingURL=generate-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-config.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-config.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-config.ts"],"names":[],"mappings":"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","sourcesContent":["import { writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { format, resolveConfig } from 'prettier';\nimport type { NgRxRuleModule } from '../src/rule-creator';\nimport { rulesForGenerate } from '../src/utils/helper-functions/rules';\n\nconst prettierConfig = resolveConfig.sync(__dirname);\n\nconst RULE_MODULE = '@ngrx';\nconst CONFIG_DIRECTORY = './modules/eslint-plugin/src/configs/';\n\nwriteConfig('all', (_rule) => true);\nwriteConfig('store', (rule) => rule.meta.ngrxModule === 'store');\nwriteConfig('effects', (rule) => rule.meta.ngrxModule === 'effects');\nwriteConfig(\n 'component-store',\n (rule) => rule.meta.ngrxModule === 'component-store'\n);\nwriteConfig('operators', (rule) => rule.meta.ngrxModule === 'operators');\nwriteConfig('signals', (rule) => rule.meta.ngrxModule === 'signals');\n\nfunction writeConfig(\n configName:\n | 'all'\n | 'store'\n | 'effects'\n | 'component-store'\n | 'operators'\n | 'signals',\n predicate: (rule: NgRxRuleModule<[], string>) => boolean\n) {\n const rulesForConfig = Object.entries(rulesForGenerate).filter(([_, rule]) =>\n predicate(rule)\n );\n const configRules = rulesForConfig.reduce<Record<string, string>>(\n (rules, [ruleName, _rule]) => {\n rules[`${RULE_MODULE}/${ruleName}`] = 'error';\n return rules;\n },\n {}\n );\n const requireParserOptions: null | Record<string, string | number> =\n rulesForConfig.some(([_, rule]) => rule.meta.docs?.requiresTypeChecking)\n ? {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n }\n : null;\n\n const tsCode = `\n /**\n * DO NOT EDIT\n * This file is generated\n */\n\n import type { TSESLint } from '@typescript-eslint/utils';\n\n export default (\n plugin: TSESLint.FlatConfig.Plugin,\n parser: TSESLint.FlatConfig.Parser,\n ): TSESLint.FlatConfig.ConfigArray => [\n {\n name: 'ngrx/base',\n languageOptions: {\n parser,\n sourceType: 'module',\n },\n plugins: {\n '@ngrx': plugin,\n },\n },\n {\n name: 'ngrx/${configName}',\n languageOptions: {\n parser,\n ${\n requireParserOptions\n ? `parserOptions: ${JSON.stringify(\n requireParserOptions,\n null,\n 2\n )},`\n : ''\n }\n },\n rules: ${JSON.stringify(configRules, null, 2)}\n },\n ];`;\n const tsConfigFormatted = format(tsCode, {\n parser: 'typescript',\n ...prettierConfig,\n });\n writeFileSync(join(CONFIG_DIRECTORY, `${configName}.ts`), tsConfigFormatted);\n\n const jsonConfig: { [key: string]: any } = {\n parser: '@typescript-eslint/parser',\n plugins: ['@ngrx'],\n rules: configRules,\n };\n if (requireParserOptions) {\n jsonConfig.parserOptions = {\n ecmaVersion: 2020,\n sourceType: 'module',\n project: './tsconfig.json',\n };\n }\n const jsonConfigFormatted = format(JSON.stringify(jsonConfig, null, 2), {\n parser: 'json',\n ...prettierConfig,\n });\n\n writeFileSync(\n join(CONFIG_DIRECTORY, `${configName}.json`),\n jsonConfigFormatted\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/scripts/generate-docs.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -33,61 +22,40 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
22
|
__setModuleDefault(result, mod);
|
|
34
23
|
return result;
|
|
35
24
|
};
|
|
36
|
-
var __values = (this && this.__values) || function(o) {
|
|
37
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
38
|
-
if (m) return m.call(o);
|
|
39
|
-
if (o && typeof o.length === "number") return {
|
|
40
|
-
next: function () {
|
|
41
|
-
if (o && i >= o.length) o = void 0;
|
|
42
|
-
return { value: o && o[i++], done: !o };
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
46
|
-
};
|
|
47
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
-
if (!m) return o;
|
|
50
|
-
var i = m.call(o), r, ar = [], e;
|
|
51
|
-
try {
|
|
52
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
-
}
|
|
54
|
-
catch (error) { e = { error: error }; }
|
|
55
|
-
finally {
|
|
56
|
-
try {
|
|
57
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
-
}
|
|
59
|
-
finally { if (e) throw e.error; }
|
|
60
|
-
}
|
|
61
|
-
return ar;
|
|
62
|
-
};
|
|
63
|
-
var e_1, _a;
|
|
64
|
-
var _b, _c, _d;
|
|
65
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!(0, fs_1.existsSync)(docPath)) {
|
|
78
|
-
(0, fs_1.writeFileSync)(docPath, "");
|
|
79
|
-
}
|
|
80
|
-
var doc = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
81
|
-
var docContent = doc.substring(doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length);
|
|
82
|
-
var newDoc = (0, prettier_1.format)("# ".concat(ruleName, "\n\n").concat(meta.version ? '> Required NgRx Version Range: ${meta.version}' : '', " \n\n").concat((_b = meta.docs) === null || _b === void 0 ? void 0 : _b.description, "\n\n- **Type**: ").concat(meta.type, "\n- **Recommended**: ").concat(((_c = meta.docs) === null || _c === void 0 ? void 0 : _c.recommended) ? 'Yes' : 'No', "\n- **Fixable**: ").concat(meta.fixable ? 'Yes' : 'No', "\n- **Suggestion**: ").concat(meta.hasSuggestions ? 'Yes' : 'No', "\n- **Requires type checking**: ").concat(((_d = meta.docs) === null || _d === void 0 ? void 0 : _d.requiresTypeChecking) ? 'Yes' : 'No', "\n- **Configurable**: ").concat(meta.schema.length ? 'Yes' : 'No', "\n\n<!-- Everything above this generated, do not edit -->\n<!-- MANUAL-DOC:START -->\n\n").concat(docContent), __assign({ parser: 'markdown' }, prettierConfig));
|
|
83
|
-
(0, fs_1.writeFileSync)(docPath, newDoc);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
87
|
-
finally {
|
|
88
|
-
try {
|
|
89
|
-
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
26
|
+
const fs_1 = require("fs");
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const prettier_1 = require("prettier");
|
|
29
|
+
const rules_1 = require("../src/utils/helper-functions/rules");
|
|
30
|
+
const prettierConfig = prettier_1.resolveConfig.sync(__dirname);
|
|
31
|
+
const PLACEHOLDER = '<!-- MANUAL-DOC:START -->';
|
|
32
|
+
const RULES_PATH = './projects/ngrx.io/content/guide/eslint-plugin/rules';
|
|
33
|
+
for (const [ruleName, { meta }] of Object.entries(rules_1.rulesForGenerate)) {
|
|
34
|
+
const docPath = path.join(RULES_PATH, `${ruleName}.md`);
|
|
35
|
+
if (!(0, fs_1.existsSync)(docPath)) {
|
|
36
|
+
(0, fs_1.writeFileSync)(docPath, ``);
|
|
90
37
|
}
|
|
91
|
-
|
|
38
|
+
const doc = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
39
|
+
const docContent = doc.substring(doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length);
|
|
40
|
+
const newDoc = (0, prettier_1.format)(`# ${ruleName}
|
|
41
|
+
|
|
42
|
+
${meta.version ? '> Required NgRx Version Range: ${meta.version}' : ''}
|
|
43
|
+
|
|
44
|
+
${meta.docs?.description}
|
|
45
|
+
|
|
46
|
+
- **Type**: ${meta.type}
|
|
47
|
+
- **Fixable**: ${meta.fixable ? 'Yes' : 'No'}
|
|
48
|
+
- **Suggestion**: ${meta.hasSuggestions ? 'Yes' : 'No'}
|
|
49
|
+
- **Requires type checking**: ${meta.docs?.requiresTypeChecking ? 'Yes' : 'No'}
|
|
50
|
+
- **Configurable**: ${Array.isArray(meta.schema) && meta.schema.length ? 'Yes' : 'No'}
|
|
51
|
+
|
|
52
|
+
<!-- Everything above this generated, do not edit -->
|
|
53
|
+
<!-- MANUAL-DOC:START -->
|
|
54
|
+
|
|
55
|
+
${docContent}`, {
|
|
56
|
+
parser: 'markdown',
|
|
57
|
+
...prettierConfig,
|
|
58
|
+
});
|
|
59
|
+
(0, fs_1.writeFileSync)(docPath, newDoc);
|
|
92
60
|
}
|
|
93
61
|
//# sourceMappingURL=generate-docs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-docs.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-docs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-docs.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/scripts/generate-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6D;AAC7D,2CAA6B;AAC7B,uCAAiD;AACjD,+DAAuE;AAEvE,MAAM,cAAc,GAAG,wBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrD,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAChD,MAAM,UAAU,GAAG,sDAAsD,CAAC;AAE1E,KAAK,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,wBAAgB,CAAC,EAAE,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAC;IACxD,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;QACzB,IAAA,kBAAa,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAC9B,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,MAAM,CAC9C,CAAC;IACF,MAAM,MAAM,GAAG,IAAA,iBAAM,EACnB,KAAK,QAAQ;;EAEf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC,EAAE;;EAEpE,IAAI,CAAC,IAAI,EAAE,WAAW;;cAEV,IAAI,CAAC,IAAI;iBACN,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;oBACxB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;gCACtB,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;sBAExE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAC7D;;;;;EAKF,UAAU,EAAE,EACV;QACE,MAAM,EAAE,UAAU;QAClB,GAAG,cAAc;KAClB,CACF,CAAC;IAEF,IAAA,kBAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { readFileSync, writeFileSync, existsSync } from 'fs';\nimport * as path from 'path';\nimport { format, resolveConfig } from 'prettier';\nimport { rulesForGenerate } from '../src/utils/helper-functions/rules';\n\nconst prettierConfig = resolveConfig.sync(__dirname);\nconst PLACEHOLDER = '<!-- MANUAL-DOC:START -->';\nconst RULES_PATH = './projects/ngrx.io/content/guide/eslint-plugin/rules';\n\nfor (const [ruleName, { meta }] of Object.entries(rulesForGenerate)) {\n const docPath = path.join(RULES_PATH, `${ruleName}.md`);\n if (!existsSync(docPath)) {\n writeFileSync(docPath, ``);\n }\n const doc = readFileSync(docPath, 'utf-8');\n const docContent = doc.substring(\n doc.indexOf(PLACEHOLDER) + PLACEHOLDER.length\n );\n const newDoc = format(\n `# ${ruleName}\n\n${meta.version ? '> Required NgRx Version Range: ${meta.version}' : ''} \n\n${meta.docs?.description}\n\n- **Type**: ${meta.type}\n- **Fixable**: ${meta.fixable ? 'Yes' : 'No'}\n- **Suggestion**: ${meta.hasSuggestions ? 'Yes' : 'No'}\n- **Requires type checking**: ${meta.docs?.requiresTypeChecking ? 'Yes' : 'No'}\n- **Configurable**: ${\n Array.isArray(meta.schema) && meta.schema.length ? 'Yes' : 'No'\n }\n\n<!-- Everything above this generated, do not edit -->\n<!-- MANUAL-DOC:START -->\n\n${docContent}`,\n {\n parser: 'markdown',\n ...prettierConfig,\n }\n );\n\n writeFileSync(docPath, newDoc);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|