@webpieces/code-rules 0.2.126 → 0.3.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/code-rules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.128",
|
|
4
4
|
"description": "Standalone code validation rules extracted from architecture-validators, no Nx dependency required",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "packages/tooling/code-rules"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@webpieces/rules-config": "0.
|
|
22
|
+
"@webpieces/rules-config": "0.3.128"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* no-unmanaged-exceptions -> noUnmanagedExceptions
|
|
21
21
|
* no-direct-api-in-resolver -> noDirectApiInResolver
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* downstream executor short-circuits
|
|
23
|
+
* On/off is driven entirely by `mode`: a `mode:'OFF'` entry flows straight
|
|
24
|
+
* through to the downstream executor, which short-circuits on it.
|
|
25
25
|
*/
|
|
26
26
|
import type { ResolvedConfig } from '@webpieces/rules-config';
|
|
27
27
|
import type { ValidateCodeOptions } from './validate-code';
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* no-unmanaged-exceptions -> noUnmanagedExceptions
|
|
22
22
|
* no-direct-api-in-resolver -> noDirectApiInResolver
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
* downstream executor short-circuits
|
|
24
|
+
* On/off is driven entirely by `mode`: a `mode:'OFF'` entry flows straight
|
|
25
|
+
* through to the downstream executor, which short-circuits on it.
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.toValidateCodeOptions = toValidateCodeOptions;
|
|
@@ -38,8 +38,6 @@ function opt(rule, key) {
|
|
|
38
38
|
function modeOrOff(rule) {
|
|
39
39
|
if (!rule)
|
|
40
40
|
return undefined;
|
|
41
|
-
if (rule.enabled === false)
|
|
42
|
-
return 'OFF';
|
|
43
41
|
const mode = rule.options['mode'];
|
|
44
42
|
return mode ?? undefined;
|
|
45
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-shared-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/from-shared-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;
|
|
1
|
+
{"version":3,"file":"from-shared-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/from-shared-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;AAmBH,sDAyEC;AAvFD,oFAAoF;AACpF,SAAS,GAAG,CAAI,IAAoC,EAAE,GAAW;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,KAAU,CAAC;AACtB,CAAC;AAED,SAAS,SAAS,CAAmB,IAAoC;IACrE,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,OAAQ,IAAU,IAAI,SAAS,CAAC;AACpC,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAsB;IACxD,MAAM,CAAC,GAAG,CAAC,IAAY,EAAkC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEnF,OAAO;QACH,cAAc,EAAE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X,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;YACpC,cAAc,EAAE,GAAG,CAAU,CAAC,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;YACnE,wBAAwB,EAAE,GAAG,CAAS,CAAC,CAAC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;SACzF;QACD,iBAAiB,EAAE;YACf,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;YACzC,cAAc,EAAE,GAAG,CAAU,CAAC,CAAC,qBAAqB,CAAC,EAAE,gBAAgB,CAAC;YACxE,wBAAwB,EAAE,GAAG,CAAS,CAAC,CAAC,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;SAC9F;QACD,qBAAqB,EAAE;YACnB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC;YAC7C,cAAc,EAAE,GAAG,CAAU,CAAC,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,CAAC;YAC5E,wBAAwB,EAAE,GAAG,CAAS,CAAC,CAAC,yBAAyB,CAAC,EAAE,0BAA0B,CAAC;SAClG;QACD,qBAAqB,EAAE;YACnB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC;YAC/C,cAAc,EAAE,GAAG,CAAU,CAAC,CAAC,2BAA2B,CAAC,EAAE,gBAAgB,CAAC;YAC9E,wBAAwB,EAAE,GAAG,CAAS,CAAC,CAAC,2BAA2B,CAAC,EAAE,0BAA0B,CAAC;YACjG,YAAY,EAAE,GAAG,CAAW,CAAC,CAAC,2BAA2B,CAAC,EAAE,cAAc,CAAC;SAC9E;KACJ,CAAC;AACN,CAAC","sourcesContent":["/**\n * Adapter: map @webpieces/rules-config ResolvedConfig -> legacy ValidateCodeOptions.\n *\n * We don't want to rewrite the 11 sub-executors in this PR, so this file\n * takes the shared webpieces.config.json entries (kebab-case rule names)\n * and reconstructs the camelCase ValidateCodeOptions shape the executor\n * already understands.\n *\n * Mapping of canonical kebab-case rule name -> ValidateCodeOptions field:\n * max-method-lines -> methodMaxLimit\n * max-file-lines -> fileMaxLimit\n * require-return-type -> requireReturnType\n * no-inline-type-literals -> noInlineTypeLiterals\n * no-any-unknown -> noAnyUnknown\n * no-implicit-any -> noImplicitAny\n * validate-dtos -> validateDtos\n * prisma-converter -> prismaConverter\n * no-destructure -> noDestructure\n * catch-error-pattern -> catchErrorPattern\n * no-unmanaged-exceptions -> noUnmanagedExceptions\n * no-direct-api-in-resolver -> noDirectApiInResolver\n *\n * On/off is driven entirely by `mode`: a `mode:'OFF'` entry flows straight\n * through to the downstream executor, which short-circuits on it.\n */\n\nimport type { ResolvedConfig, ResolvedRuleConfig } from '@webpieces/rules-config';\nimport type { ValidateCodeOptions } from './validate-code';\n\n// webpieces-disable no-any-unknown -- coerces opaque option values pulled from JSON\nfunction opt<T>(rule: ResolvedRuleConfig | undefined, key: string): T | undefined {\n if (!rule) return undefined;\n const value = rule.options[key];\n if (value === undefined) return undefined;\n return value as T;\n}\n\nfunction modeOrOff<T extends string>(rule: ResolvedRuleConfig | undefined): T | undefined {\n if (!rule) return undefined;\n const mode = rule.options['mode'];\n return (mode as T) ?? undefined;\n}\n\nexport function toValidateCodeOptions(shared: ResolvedConfig): ValidateCodeOptions {\n const r = (name: string): ResolvedRuleConfig | undefined => shared.rules.get(name);\n\n return {\n methodMaxLimit: {\n limit: opt<number>(r('max-method-lines'), 'limit'),\n mode: modeOrOff(r('max-method-lines')),\n disableAllowed: opt<boolean>(r('max-method-lines'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('max-method-lines'), 'ignoreModifiedUntilEpoch'),\n },\n fileMaxLimit: {\n limit: opt<number>(r('max-file-lines'), 'limit'),\n mode: modeOrOff(r('max-file-lines')),\n disableAllowed: opt<boolean>(r('max-file-lines'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('max-file-lines'), 'ignoreModifiedUntilEpoch'),\n },\n requireReturnType: {\n mode: modeOrOff(r('require-return-type')),\n disableAllowed: opt<boolean>(r('require-return-type'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('require-return-type'), 'ignoreModifiedUntilEpoch'),\n },\n noInlineTypeLiterals: {\n mode: modeOrOff(r('no-inline-type-literals')),\n disableAllowed: opt<boolean>(r('no-inline-type-literals'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-inline-type-literals'), 'ignoreModifiedUntilEpoch'),\n },\n noAnyUnknown: {\n mode: modeOrOff(r('no-any-unknown')),\n disableAllowed: opt<boolean>(r('no-any-unknown'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-any-unknown'), 'ignoreModifiedUntilEpoch'),\n },\n noImplicitAny: {\n mode: modeOrOff(r('no-implicit-any')),\n disableAllowed: opt<boolean>(r('no-implicit-any'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-implicit-any'), 'ignoreModifiedUntilEpoch'),\n },\n validateDtos: {\n mode: modeOrOff(r('validate-dtos')),\n disableAllowed: opt<boolean>(r('validate-dtos'), 'disableAllowed'),\n prismaSchemaPath: opt<string>(r('validate-dtos'), 'prismaSchemaPath'),\n dtoSourcePaths: opt<string[]>(r('validate-dtos'), 'dtoSourcePaths'),\n ignoreModifiedUntilEpoch: opt<number>(r('validate-dtos'), 'ignoreModifiedUntilEpoch'),\n },\n prismaConverter: {\n mode: modeOrOff(r('prisma-converter')),\n disableAllowed: opt<boolean>(r('prisma-converter'), 'disableAllowed'),\n schemaPath: opt<string>(r('prisma-converter'), 'schemaPath'),\n convertersPaths: opt<string[]>(r('prisma-converter'), 'convertersPaths'),\n enforcePaths: opt<string[]>(r('prisma-converter'), 'enforcePaths'),\n ignoreModifiedUntilEpoch: opt<number>(r('prisma-converter'), 'ignoreModifiedUntilEpoch'),\n },\n noDestructure: {\n mode: modeOrOff(r('no-destructure')),\n disableAllowed: opt<boolean>(r('no-destructure'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-destructure'), 'ignoreModifiedUntilEpoch'),\n },\n catchErrorPattern: {\n mode: modeOrOff(r('catch-error-pattern')),\n disableAllowed: opt<boolean>(r('catch-error-pattern'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('catch-error-pattern'), 'ignoreModifiedUntilEpoch'),\n },\n noUnmanagedExceptions: {\n mode: modeOrOff(r('no-unmanaged-exceptions')),\n disableAllowed: opt<boolean>(r('no-unmanaged-exceptions'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-unmanaged-exceptions'), 'ignoreModifiedUntilEpoch'),\n },\n noDirectApiInResolver: {\n mode: modeOrOff(r('no-direct-api-in-resolver')),\n disableAllowed: opt<boolean>(r('no-direct-api-in-resolver'), 'disableAllowed'),\n ignoreModifiedUntilEpoch: opt<number>(r('no-direct-api-in-resolver'), 'ignoreModifiedUntilEpoch'),\n enforcePaths: opt<string[]>(r('no-direct-api-in-resolver'), 'enforcePaths'),\n },\n };\n}\n"]}
|