@webpieces/eslint-rules 0.0.1 → 0.2.113
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 +3 -2
- package/src/index.d.ts +29 -0
- package/src/index.js +39 -0
- package/src/index.js.map +1 -0
- package/src/rules/catch-error-pattern.d.ts +11 -0
- package/src/rules/{catch-error-pattern.ts → catch-error-pattern.js} +30 -142
- package/src/rules/catch-error-pattern.js.map +1 -0
- package/src/rules/enforce-architecture.d.ts +15 -0
- package/src/rules/{enforce-architecture.ts → enforce-architecture.js} +61 -128
- package/src/rules/enforce-architecture.js.map +1 -0
- package/src/rules/max-file-lines.d.ts +12 -0
- package/src/rules/{max-file-lines.ts → max-file-lines.js} +22 -37
- package/src/rules/max-file-lines.js.map +1 -0
- package/src/rules/max-method-lines.d.ts +12 -0
- package/src/rules/{max-method-lines.ts → max-method-lines.js} +31 -81
- package/src/rules/max-method-lines.js.map +1 -0
- package/src/rules/no-json-property-primitive-type.d.ts +17 -0
- package/src/rules/no-json-property-primitive-type.js +57 -0
- package/src/rules/no-json-property-primitive-type.js.map +1 -0
- package/src/rules/no-mat-cell-def.d.ts +15 -0
- package/src/rules/{no-mat-cell-def.ts → no-mat-cell-def.js} +8 -21
- package/src/rules/no-mat-cell-def.js.map +1 -0
- package/src/rules/no-unmanaged-exceptions.d.ts +22 -0
- package/src/rules/{no-unmanaged-exceptions.ts → no-unmanaged-exceptions.js} +27 -52
- package/src/rules/no-unmanaged-exceptions.js.map +1 -0
- package/src/rules/require-typed-template.d.ts +17 -0
- package/src/rules/{require-typed-template.ts → require-typed-template.js} +11 -31
- package/src/rules/require-typed-template.js.map +1 -0
- package/src/toError.d.ts +5 -0
- package/src/{toError.ts → toError.js} +7 -6
- package/src/toError.js.map +1 -0
- package/.webpieces/instruct-ai/webpieces.exceptions.md +0 -5
- package/.webpieces/instruct-ai/webpieces.filesize.md +0 -146
- package/.webpieces/instruct-ai/webpieces.methods.md +0 -97
- package/LICENSE +0 -373
- package/jest.config.ts +0 -16
- package/project.json +0 -22
- package/src/__tests__/catch-error-pattern.test.ts +0 -374
- package/src/__tests__/max-file-lines.test.ts +0 -207
- package/src/__tests__/max-method-lines.test.ts +0 -258
- package/src/__tests__/no-unmanaged-exceptions.test.ts +0 -359
- package/src/index.ts +0 -38
- package/src/rules/no-json-property-primitive-type.ts +0 -85
- package/tmp/webpieces/webpieces.exceptions.md +0 -5
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ESLint rule: no-json-property-primitive-type
|
|
3
|
-
*
|
|
4
|
-
* Bans @JsonProperty({ type: String }), @JsonProperty({ type: Number }),
|
|
5
|
-
* and @JsonProperty({ type: Boolean }).
|
|
6
|
-
*
|
|
7
|
-
* These pass the TypeScript build but break production deserialization.
|
|
8
|
-
* The typescript-json-serializer `type` option expects class constructors,
|
|
9
|
-
* not JavaScript primitive constructors.
|
|
10
|
-
*
|
|
11
|
-
* Correct usage:
|
|
12
|
-
* @JsonProperty() - for primitive arrays (string[], number[], boolean[])
|
|
13
|
-
* @JsonProperty({ type: MyDtoClass }) - for class types only
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { Rule } from 'eslint';
|
|
17
|
-
|
|
18
|
-
// webpieces-disable no-any-unknown -- ESTree AST node interfaces require any for dynamic properties
|
|
19
|
-
interface CallExpressionNode {
|
|
20
|
-
type: 'CallExpression';
|
|
21
|
-
// webpieces-disable no-any-unknown -- ESTree AST dynamic callee
|
|
22
|
-
callee: { name?: string; [key: string]: any };
|
|
23
|
-
// webpieces-disable no-any-unknown -- ESTree AST dynamic arguments array
|
|
24
|
-
arguments: any[];
|
|
25
|
-
// webpieces-disable no-any-unknown -- ESTree AST index signature
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface ObjectExpressionNode {
|
|
30
|
-
type: 'ObjectExpression';
|
|
31
|
-
properties: PropertyNode[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface PropertyNode {
|
|
35
|
-
key?: { name?: string };
|
|
36
|
-
value?: { type?: string; name?: string };
|
|
37
|
-
// webpieces-disable no-any-unknown -- ESTree AST index signature
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const BANNED_PRIMITIVES = ['String', 'Number', 'Boolean'];
|
|
42
|
-
|
|
43
|
-
const rule: Rule.RuleModule = {
|
|
44
|
-
meta: {
|
|
45
|
-
type: 'problem',
|
|
46
|
-
docs: {
|
|
47
|
-
description:
|
|
48
|
-
'Ban @JsonProperty({ type: String/Number/Boolean }) — breaks production deserialization',
|
|
49
|
-
},
|
|
50
|
-
messages: {
|
|
51
|
-
noPrimitiveType:
|
|
52
|
-
'@JsonProperty({ type: {{ primitive }} }) breaks production deserialization. ' +
|
|
53
|
-
'For primitive arrays (string[], number[], boolean[]), use @JsonProperty() with ' +
|
|
54
|
-
'no type parameter. The type option is only for class types: ' +
|
|
55
|
-
'@JsonProperty({ type: MyDtoClass }).',
|
|
56
|
-
},
|
|
57
|
-
schema: [],
|
|
58
|
-
},
|
|
59
|
-
create(context: Rule.RuleContext): Rule.RuleListener {
|
|
60
|
-
return {
|
|
61
|
-
CallExpression(node: CallExpressionNode): void {
|
|
62
|
-
if (node.callee.name !== 'JsonProperty') return;
|
|
63
|
-
const arg = node.arguments[0];
|
|
64
|
-
if (!arg || arg.type !== 'ObjectExpression') return;
|
|
65
|
-
const objArg = arg as ObjectExpressionNode;
|
|
66
|
-
for (const prop of objArg.properties) {
|
|
67
|
-
if (
|
|
68
|
-
prop.key?.name === 'type' &&
|
|
69
|
-
prop.value?.type === 'Identifier' &&
|
|
70
|
-
BANNED_PRIMITIVES.includes(prop.value.name!)
|
|
71
|
-
) {
|
|
72
|
-
context.report({
|
|
73
|
-
// webpieces-disable no-any-unknown -- ESTree AST cast for ESLint report
|
|
74
|
-
node: prop as unknown as Rule.Node,
|
|
75
|
-
messageId: 'noPrimitiveType',
|
|
76
|
-
data: { primitive: prop.value.name! },
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export = rule;
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"forceConsistentCasingInFileNames": true,
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noImplicitOverride": true,
|
|
8
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noFallthroughCasesInSwitch": true
|
|
11
|
-
},
|
|
12
|
-
"files": [],
|
|
13
|
-
"include": [],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": "./tsconfig.lib.json"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"path": "./tsconfig.spec.json"
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"jest.config.ts",
|
|
10
|
-
"src/**/*.test.ts",
|
|
11
|
-
"src/**/*.spec.ts",
|
|
12
|
-
"src/__tests__/**/*.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|