eslint-cdk-plugin 3.0.2 → 3.0.3
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/dist/index.cjs +105 -91
- package/dist/index.mjs +105 -91
- package/package.json +3 -2
- package/src/rules/construct-constructor-property.ts +34 -36
- package/src/rules/no-construct-in-interface.ts +3 -2
- package/src/rules/no-construct-in-public-property-of-construct.ts +45 -45
- package/src/rules/no-construct-stack-suffix.ts +3 -2
- package/src/rules/no-import-private.ts +1 -1
- package/src/rules/no-mutable-property-of-props-interface.ts +49 -49
- package/src/rules/no-mutable-public-property-of-construct.ts +60 -60
- package/src/rules/no-parent-name-construct-id-match.ts +60 -61
- package/src/rules/no-variable-construct-id.ts +3 -1
- package/src/rules/pascal-case-construct-id.ts +3 -2
- package/src/rules/props-name-convention.ts +3 -2
- package/src/rules/require-jsdoc.ts +3 -2
- package/src/rules/require-passing-this.ts +3 -2
- package/src/rules/require-props-default-doc.ts +5 -7
- package/src/utils/createRule.ts +5 -0
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,11 @@ function _interopNamespaceDefault(e) {
|
|
|
26
26
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
27
27
|
|
|
28
28
|
var name = "eslint-cdk-plugin";
|
|
29
|
-
var version = "3.0.
|
|
29
|
+
var version = "3.0.3";
|
|
30
|
+
|
|
31
|
+
const createRule = utils.ESLintUtils.RuleCreator(
|
|
32
|
+
(name) => `https://eslint-cdk-plugin.dev/rules/${name}`
|
|
33
|
+
);
|
|
30
34
|
|
|
31
35
|
const isConstructOrStackType = (type, ignoredClasses = ["App", "Stage"]) => {
|
|
32
36
|
if (ignoredClasses.includes(type.symbol?.name ?? "")) return false;
|
|
@@ -49,35 +53,34 @@ const isTargetSuperClassType = (type, targetSuperClasses, typeCheckFunction) =>
|
|
|
49
53
|
return baseTypes.some((baseType) => typeCheckFunction(baseType));
|
|
50
54
|
};
|
|
51
55
|
|
|
52
|
-
const constructConstructorProperty =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
messages: {
|
|
60
|
-
invalidConstructorProperty: "Constructor of a class extending Construct must have the property names 'scope, id' or 'scope, id, props'"
|
|
61
|
-
},
|
|
62
|
-
schema: []
|
|
56
|
+
const constructConstructorProperty = createRule({
|
|
57
|
+
name: "construct-constructor-property",
|
|
58
|
+
meta: {
|
|
59
|
+
type: "problem",
|
|
60
|
+
docs: {
|
|
61
|
+
description: "Enforces that constructors of classes extending Construct have the property names 'scope, id' or 'scope, id, props'"
|
|
63
62
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
messages: {
|
|
64
|
+
invalidConstructorProperty: "Constructor of a class extending Construct must have the property names 'scope, id' or 'scope, id, props'"
|
|
65
|
+
},
|
|
66
|
+
schema: []
|
|
67
|
+
},
|
|
68
|
+
defaultOptions: [],
|
|
69
|
+
create(context) {
|
|
70
|
+
const parserServices = utils.ESLintUtils.getParserServices(context);
|
|
71
|
+
return {
|
|
72
|
+
ClassDeclaration(node) {
|
|
73
|
+
const type = parserServices.getTypeAtLocation(node);
|
|
74
|
+
if (!isConstructType(type)) return;
|
|
75
|
+
const constructor = node.body.body.find(
|
|
76
|
+
(member) => member.type === utils.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
77
|
+
);
|
|
78
|
+
if (!constructor) return;
|
|
79
|
+
validateConstructorProperty(constructor, context);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
79
82
|
}
|
|
80
|
-
);
|
|
83
|
+
});
|
|
81
84
|
const validateConstructorProperty = (constructor, context) => {
|
|
82
85
|
const params = constructor.value.params;
|
|
83
86
|
if (params.length < 2) {
|
|
@@ -122,7 +125,8 @@ const SYNTAX_KIND = {
|
|
|
122
125
|
CONSTRUCTOR: 176
|
|
123
126
|
};
|
|
124
127
|
|
|
125
|
-
const noConstructInInterface =
|
|
128
|
+
const noConstructInInterface = createRule({
|
|
129
|
+
name: "no-construct-in-interface",
|
|
126
130
|
meta: {
|
|
127
131
|
type: "problem",
|
|
128
132
|
docs: {
|
|
@@ -160,7 +164,8 @@ const noConstructInInterface = utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
160
164
|
}
|
|
161
165
|
});
|
|
162
166
|
|
|
163
|
-
const noConstructInPublicPropertyOfConstruct =
|
|
167
|
+
const noConstructInPublicPropertyOfConstruct = createRule({
|
|
168
|
+
name: "no-construct-in-public-property-of-construct",
|
|
164
169
|
meta: {
|
|
165
170
|
type: "problem",
|
|
166
171
|
docs: {
|
|
@@ -271,7 +276,8 @@ const SUFFIX_TYPE = {
|
|
|
271
276
|
CONSTRUCT: "Construct",
|
|
272
277
|
STACK: "Stack"
|
|
273
278
|
};
|
|
274
|
-
const noConstructStackSuffix =
|
|
279
|
+
const noConstructStackSuffix = createRule({
|
|
280
|
+
name: "no-construct-stack-suffix",
|
|
275
281
|
meta: {
|
|
276
282
|
type: "problem",
|
|
277
283
|
docs: {
|
|
@@ -354,6 +360,7 @@ const noImportPrivate = {
|
|
|
354
360
|
meta: {
|
|
355
361
|
type: "problem",
|
|
356
362
|
docs: {
|
|
363
|
+
url: "https://eslint-cdk-plugin.dev/rules/no-import-private",
|
|
357
364
|
description: "Cannot import modules from private dir at different levels of the hierarchy."
|
|
358
365
|
},
|
|
359
366
|
messages: {
|
|
@@ -386,7 +393,8 @@ const getDirSegments = (dirPath) => {
|
|
|
386
393
|
return dirPath.split(path__namespace.sep).filter((segment) => segment !== "");
|
|
387
394
|
};
|
|
388
395
|
|
|
389
|
-
const noMutablePropertyOfPropsInterface =
|
|
396
|
+
const noMutablePropertyOfPropsInterface = createRule({
|
|
397
|
+
name: "no-mutable-property-of-props-interface",
|
|
390
398
|
meta: {
|
|
391
399
|
type: "problem",
|
|
392
400
|
docs: {
|
|
@@ -426,7 +434,8 @@ const noMutablePropertyOfPropsInterface = utils.ESLintUtils.RuleCreator.withoutD
|
|
|
426
434
|
}
|
|
427
435
|
});
|
|
428
436
|
|
|
429
|
-
const noMutablePublicPropertyOfConstruct =
|
|
437
|
+
const noMutablePublicPropertyOfConstruct = createRule({
|
|
438
|
+
name: "no-mutable-public-property-of-construct",
|
|
430
439
|
meta: {
|
|
431
440
|
type: "problem",
|
|
432
441
|
docs: {
|
|
@@ -477,64 +486,63 @@ const noMutablePublicPropertyOfConstruct = utils.ESLintUtils.RuleCreator.without
|
|
|
477
486
|
}
|
|
478
487
|
});
|
|
479
488
|
|
|
480
|
-
const noParentNameConstructIdMatch =
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
},
|
|
490
|
-
schema: [
|
|
491
|
-
{
|
|
492
|
-
type: "object",
|
|
493
|
-
properties: {
|
|
494
|
-
disallowContainingParentName: {
|
|
495
|
-
type: "boolean",
|
|
496
|
-
default: false
|
|
497
|
-
}
|
|
498
|
-
},
|
|
499
|
-
additionalProperties: false
|
|
500
|
-
}
|
|
501
|
-
]
|
|
489
|
+
const noParentNameConstructIdMatch = createRule({
|
|
490
|
+
name: "no-parent-name-construct-id-match",
|
|
491
|
+
meta: {
|
|
492
|
+
type: "problem",
|
|
493
|
+
docs: {
|
|
494
|
+
description: "Enforce that construct IDs does not match the parent construct name."
|
|
495
|
+
},
|
|
496
|
+
messages: {
|
|
497
|
+
invalidConstructId: "Construct ID '{{ constructId }}' should not match parent construct name '{{ parentConstructName }}'. Use a more specific identifier."
|
|
502
498
|
},
|
|
503
|
-
|
|
499
|
+
schema: [
|
|
504
500
|
{
|
|
505
|
-
|
|
501
|
+
type: "object",
|
|
502
|
+
properties: {
|
|
503
|
+
disallowContainingParentName: {
|
|
504
|
+
type: "boolean",
|
|
505
|
+
default: false
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
additionalProperties: false
|
|
506
509
|
}
|
|
507
|
-
]
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
option
|
|
531
|
-
});
|
|
510
|
+
]
|
|
511
|
+
},
|
|
512
|
+
defaultOptions: [
|
|
513
|
+
{
|
|
514
|
+
disallowContainingParentName: false
|
|
515
|
+
}
|
|
516
|
+
],
|
|
517
|
+
create(context) {
|
|
518
|
+
const option = context.options[0] || {
|
|
519
|
+
disallowContainingParentName: false
|
|
520
|
+
};
|
|
521
|
+
const parserServices = utils.ESLintUtils.getParserServices(context);
|
|
522
|
+
return {
|
|
523
|
+
ClassBody(node) {
|
|
524
|
+
const type = parserServices.getTypeAtLocation(node);
|
|
525
|
+
if (!isConstructOrStackType(type)) return;
|
|
526
|
+
const parent = node.parent;
|
|
527
|
+
if (parent?.type !== utils.AST_NODE_TYPES.ClassDeclaration) return;
|
|
528
|
+
const parentClassName = parent.id?.name;
|
|
529
|
+
if (!parentClassName) return;
|
|
530
|
+
for (const body of node.body) {
|
|
531
|
+
if (body.type !== utils.AST_NODE_TYPES.MethodDefinition || !["method", "constructor"].includes(body.kind) || body.value.type !== utils.AST_NODE_TYPES.FunctionExpression) {
|
|
532
|
+
continue;
|
|
532
533
|
}
|
|
534
|
+
validateConstructorBody({
|
|
535
|
+
expression: body.value,
|
|
536
|
+
parentClassName,
|
|
537
|
+
context,
|
|
538
|
+
parserServices,
|
|
539
|
+
option
|
|
540
|
+
});
|
|
533
541
|
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
542
|
+
}
|
|
543
|
+
};
|
|
536
544
|
}
|
|
537
|
-
);
|
|
545
|
+
});
|
|
538
546
|
const validateConstructorBody = ({
|
|
539
547
|
expression,
|
|
540
548
|
parentClassName,
|
|
@@ -767,7 +775,8 @@ const validateConstructId$2 = ({
|
|
|
767
775
|
}
|
|
768
776
|
};
|
|
769
777
|
|
|
770
|
-
const noVariableConstructId =
|
|
778
|
+
const noVariableConstructId = createRule({
|
|
779
|
+
name: "no-variable-construct-id",
|
|
771
780
|
meta: {
|
|
772
781
|
type: "problem",
|
|
773
782
|
docs: {
|
|
@@ -832,7 +841,8 @@ const QUOTE_TYPE = {
|
|
|
832
841
|
SINGLE: "'",
|
|
833
842
|
DOUBLE: '"'
|
|
834
843
|
};
|
|
835
|
-
const pascalCaseConstructId =
|
|
844
|
+
const pascalCaseConstructId = createRule({
|
|
845
|
+
name: "pascal-case-construct-id",
|
|
836
846
|
meta: {
|
|
837
847
|
type: "problem",
|
|
838
848
|
docs: {
|
|
@@ -881,7 +891,8 @@ const validateConstructId = (node, context) => {
|
|
|
881
891
|
});
|
|
882
892
|
};
|
|
883
893
|
|
|
884
|
-
const propsNameConvention =
|
|
894
|
+
const propsNameConvention = createRule({
|
|
895
|
+
name: "props-name-convention",
|
|
885
896
|
meta: {
|
|
886
897
|
type: "problem",
|
|
887
898
|
docs: {
|
|
@@ -928,7 +939,8 @@ const propsNameConvention = utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
928
939
|
}
|
|
929
940
|
});
|
|
930
941
|
|
|
931
|
-
const requireJSDoc =
|
|
942
|
+
const requireJSDoc = createRule({
|
|
943
|
+
name: "require-jsdoc",
|
|
932
944
|
meta: {
|
|
933
945
|
type: "problem",
|
|
934
946
|
docs: {
|
|
@@ -993,7 +1005,8 @@ const requireJSDoc = utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
993
1005
|
}
|
|
994
1006
|
});
|
|
995
1007
|
|
|
996
|
-
const requirePassingThis =
|
|
1008
|
+
const requirePassingThis = createRule({
|
|
1009
|
+
name: "require-passing-this",
|
|
997
1010
|
meta: {
|
|
998
1011
|
type: "problem",
|
|
999
1012
|
docs: {
|
|
@@ -1058,7 +1071,8 @@ const requirePassingThis = utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
1058
1071
|
}
|
|
1059
1072
|
});
|
|
1060
1073
|
|
|
1061
|
-
const requirePropsDefaultDoc =
|
|
1074
|
+
const requirePropsDefaultDoc = createRule({
|
|
1075
|
+
name: "require-props-default-doc",
|
|
1062
1076
|
meta: {
|
|
1063
1077
|
type: "problem",
|
|
1064
1078
|
docs: {
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,11 @@ import { ESLintUtils, AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
5
5
|
var name = "eslint-cdk-plugin";
|
|
6
|
-
var version = "3.0.
|
|
6
|
+
var version = "3.0.3";
|
|
7
|
+
|
|
8
|
+
const createRule = ESLintUtils.RuleCreator(
|
|
9
|
+
(name) => `https://eslint-cdk-plugin.dev/rules/${name}`
|
|
10
|
+
);
|
|
7
11
|
|
|
8
12
|
const isConstructOrStackType = (type, ignoredClasses = ["App", "Stage"]) => {
|
|
9
13
|
if (ignoredClasses.includes(type.symbol?.name ?? "")) return false;
|
|
@@ -26,35 +30,34 @@ const isTargetSuperClassType = (type, targetSuperClasses, typeCheckFunction) =>
|
|
|
26
30
|
return baseTypes.some((baseType) => typeCheckFunction(baseType));
|
|
27
31
|
};
|
|
28
32
|
|
|
29
|
-
const constructConstructorProperty =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
messages: {
|
|
37
|
-
invalidConstructorProperty: "Constructor of a class extending Construct must have the property names 'scope, id' or 'scope, id, props'"
|
|
38
|
-
},
|
|
39
|
-
schema: []
|
|
33
|
+
const constructConstructorProperty = createRule({
|
|
34
|
+
name: "construct-constructor-property",
|
|
35
|
+
meta: {
|
|
36
|
+
type: "problem",
|
|
37
|
+
docs: {
|
|
38
|
+
description: "Enforces that constructors of classes extending Construct have the property names 'scope, id' or 'scope, id, props'"
|
|
40
39
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
invalidConstructorProperty: "Constructor of a class extending Construct must have the property names 'scope, id' or 'scope, id, props'"
|
|
42
|
+
},
|
|
43
|
+
schema: []
|
|
44
|
+
},
|
|
45
|
+
defaultOptions: [],
|
|
46
|
+
create(context) {
|
|
47
|
+
const parserServices = ESLintUtils.getParserServices(context);
|
|
48
|
+
return {
|
|
49
|
+
ClassDeclaration(node) {
|
|
50
|
+
const type = parserServices.getTypeAtLocation(node);
|
|
51
|
+
if (!isConstructType(type)) return;
|
|
52
|
+
const constructor = node.body.body.find(
|
|
53
|
+
(member) => member.type === AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
54
|
+
);
|
|
55
|
+
if (!constructor) return;
|
|
56
|
+
validateConstructorProperty(constructor, context);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
56
59
|
}
|
|
57
|
-
);
|
|
60
|
+
});
|
|
58
61
|
const validateConstructorProperty = (constructor, context) => {
|
|
59
62
|
const params = constructor.value.params;
|
|
60
63
|
if (params.length < 2) {
|
|
@@ -99,7 +102,8 @@ const SYNTAX_KIND = {
|
|
|
99
102
|
CONSTRUCTOR: 176
|
|
100
103
|
};
|
|
101
104
|
|
|
102
|
-
const noConstructInInterface =
|
|
105
|
+
const noConstructInInterface = createRule({
|
|
106
|
+
name: "no-construct-in-interface",
|
|
103
107
|
meta: {
|
|
104
108
|
type: "problem",
|
|
105
109
|
docs: {
|
|
@@ -137,7 +141,8 @@ const noConstructInInterface = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
137
141
|
}
|
|
138
142
|
});
|
|
139
143
|
|
|
140
|
-
const noConstructInPublicPropertyOfConstruct =
|
|
144
|
+
const noConstructInPublicPropertyOfConstruct = createRule({
|
|
145
|
+
name: "no-construct-in-public-property-of-construct",
|
|
141
146
|
meta: {
|
|
142
147
|
type: "problem",
|
|
143
148
|
docs: {
|
|
@@ -248,7 +253,8 @@ const SUFFIX_TYPE = {
|
|
|
248
253
|
CONSTRUCT: "Construct",
|
|
249
254
|
STACK: "Stack"
|
|
250
255
|
};
|
|
251
|
-
const noConstructStackSuffix =
|
|
256
|
+
const noConstructStackSuffix = createRule({
|
|
257
|
+
name: "no-construct-stack-suffix",
|
|
252
258
|
meta: {
|
|
253
259
|
type: "problem",
|
|
254
260
|
docs: {
|
|
@@ -331,6 +337,7 @@ const noImportPrivate = {
|
|
|
331
337
|
meta: {
|
|
332
338
|
type: "problem",
|
|
333
339
|
docs: {
|
|
340
|
+
url: "https://eslint-cdk-plugin.dev/rules/no-import-private",
|
|
334
341
|
description: "Cannot import modules from private dir at different levels of the hierarchy."
|
|
335
342
|
},
|
|
336
343
|
messages: {
|
|
@@ -363,7 +370,8 @@ const getDirSegments = (dirPath) => {
|
|
|
363
370
|
return dirPath.split(path.sep).filter((segment) => segment !== "");
|
|
364
371
|
};
|
|
365
372
|
|
|
366
|
-
const noMutablePropertyOfPropsInterface =
|
|
373
|
+
const noMutablePropertyOfPropsInterface = createRule({
|
|
374
|
+
name: "no-mutable-property-of-props-interface",
|
|
367
375
|
meta: {
|
|
368
376
|
type: "problem",
|
|
369
377
|
docs: {
|
|
@@ -403,7 +411,8 @@ const noMutablePropertyOfPropsInterface = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
403
411
|
}
|
|
404
412
|
});
|
|
405
413
|
|
|
406
|
-
const noMutablePublicPropertyOfConstruct =
|
|
414
|
+
const noMutablePublicPropertyOfConstruct = createRule({
|
|
415
|
+
name: "no-mutable-public-property-of-construct",
|
|
407
416
|
meta: {
|
|
408
417
|
type: "problem",
|
|
409
418
|
docs: {
|
|
@@ -454,64 +463,63 @@ const noMutablePublicPropertyOfConstruct = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
454
463
|
}
|
|
455
464
|
});
|
|
456
465
|
|
|
457
|
-
const noParentNameConstructIdMatch =
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
},
|
|
467
|
-
schema: [
|
|
468
|
-
{
|
|
469
|
-
type: "object",
|
|
470
|
-
properties: {
|
|
471
|
-
disallowContainingParentName: {
|
|
472
|
-
type: "boolean",
|
|
473
|
-
default: false
|
|
474
|
-
}
|
|
475
|
-
},
|
|
476
|
-
additionalProperties: false
|
|
477
|
-
}
|
|
478
|
-
]
|
|
466
|
+
const noParentNameConstructIdMatch = createRule({
|
|
467
|
+
name: "no-parent-name-construct-id-match",
|
|
468
|
+
meta: {
|
|
469
|
+
type: "problem",
|
|
470
|
+
docs: {
|
|
471
|
+
description: "Enforce that construct IDs does not match the parent construct name."
|
|
472
|
+
},
|
|
473
|
+
messages: {
|
|
474
|
+
invalidConstructId: "Construct ID '{{ constructId }}' should not match parent construct name '{{ parentConstructName }}'. Use a more specific identifier."
|
|
479
475
|
},
|
|
480
|
-
|
|
476
|
+
schema: [
|
|
481
477
|
{
|
|
482
|
-
|
|
478
|
+
type: "object",
|
|
479
|
+
properties: {
|
|
480
|
+
disallowContainingParentName: {
|
|
481
|
+
type: "boolean",
|
|
482
|
+
default: false
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
additionalProperties: false
|
|
483
486
|
}
|
|
484
|
-
]
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
option
|
|
508
|
-
});
|
|
487
|
+
]
|
|
488
|
+
},
|
|
489
|
+
defaultOptions: [
|
|
490
|
+
{
|
|
491
|
+
disallowContainingParentName: false
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
create(context) {
|
|
495
|
+
const option = context.options[0] || {
|
|
496
|
+
disallowContainingParentName: false
|
|
497
|
+
};
|
|
498
|
+
const parserServices = ESLintUtils.getParserServices(context);
|
|
499
|
+
return {
|
|
500
|
+
ClassBody(node) {
|
|
501
|
+
const type = parserServices.getTypeAtLocation(node);
|
|
502
|
+
if (!isConstructOrStackType(type)) return;
|
|
503
|
+
const parent = node.parent;
|
|
504
|
+
if (parent?.type !== AST_NODE_TYPES.ClassDeclaration) return;
|
|
505
|
+
const parentClassName = parent.id?.name;
|
|
506
|
+
if (!parentClassName) return;
|
|
507
|
+
for (const body of node.body) {
|
|
508
|
+
if (body.type !== AST_NODE_TYPES.MethodDefinition || !["method", "constructor"].includes(body.kind) || body.value.type !== AST_NODE_TYPES.FunctionExpression) {
|
|
509
|
+
continue;
|
|
509
510
|
}
|
|
511
|
+
validateConstructorBody({
|
|
512
|
+
expression: body.value,
|
|
513
|
+
parentClassName,
|
|
514
|
+
context,
|
|
515
|
+
parserServices,
|
|
516
|
+
option
|
|
517
|
+
});
|
|
510
518
|
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
513
521
|
}
|
|
514
|
-
);
|
|
522
|
+
});
|
|
515
523
|
const validateConstructorBody = ({
|
|
516
524
|
expression,
|
|
517
525
|
parentClassName,
|
|
@@ -744,7 +752,8 @@ const validateConstructId$2 = ({
|
|
|
744
752
|
}
|
|
745
753
|
};
|
|
746
754
|
|
|
747
|
-
const noVariableConstructId =
|
|
755
|
+
const noVariableConstructId = createRule({
|
|
756
|
+
name: "no-variable-construct-id",
|
|
748
757
|
meta: {
|
|
749
758
|
type: "problem",
|
|
750
759
|
docs: {
|
|
@@ -809,7 +818,8 @@ const QUOTE_TYPE = {
|
|
|
809
818
|
SINGLE: "'",
|
|
810
819
|
DOUBLE: '"'
|
|
811
820
|
};
|
|
812
|
-
const pascalCaseConstructId =
|
|
821
|
+
const pascalCaseConstructId = createRule({
|
|
822
|
+
name: "pascal-case-construct-id",
|
|
813
823
|
meta: {
|
|
814
824
|
type: "problem",
|
|
815
825
|
docs: {
|
|
@@ -858,7 +868,8 @@ const validateConstructId = (node, context) => {
|
|
|
858
868
|
});
|
|
859
869
|
};
|
|
860
870
|
|
|
861
|
-
const propsNameConvention =
|
|
871
|
+
const propsNameConvention = createRule({
|
|
872
|
+
name: "props-name-convention",
|
|
862
873
|
meta: {
|
|
863
874
|
type: "problem",
|
|
864
875
|
docs: {
|
|
@@ -905,7 +916,8 @@ const propsNameConvention = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
905
916
|
}
|
|
906
917
|
});
|
|
907
918
|
|
|
908
|
-
const requireJSDoc =
|
|
919
|
+
const requireJSDoc = createRule({
|
|
920
|
+
name: "require-jsdoc",
|
|
909
921
|
meta: {
|
|
910
922
|
type: "problem",
|
|
911
923
|
docs: {
|
|
@@ -970,7 +982,8 @@ const requireJSDoc = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
970
982
|
}
|
|
971
983
|
});
|
|
972
984
|
|
|
973
|
-
const requirePassingThis =
|
|
985
|
+
const requirePassingThis = createRule({
|
|
986
|
+
name: "require-passing-this",
|
|
974
987
|
meta: {
|
|
975
988
|
type: "problem",
|
|
976
989
|
docs: {
|
|
@@ -1035,7 +1048,8 @@ const requirePassingThis = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
1035
1048
|
}
|
|
1036
1049
|
});
|
|
1037
1050
|
|
|
1038
|
-
const requirePropsDefaultDoc =
|
|
1051
|
+
const requirePropsDefaultDoc = createRule({
|
|
1052
|
+
name: "require-props-default-doc",
|
|
1039
1053
|
meta: {
|
|
1040
1054
|
type: "problem",
|
|
1041
1055
|
docs: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-cdk-plugin",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "eslint plugin for AWS CDK projects",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"@typescript-eslint/utils": "^8.32.1"
|
|
48
48
|
},
|
|
49
49
|
"volta": {
|
|
50
|
-
"node": "22.15.0"
|
|
50
|
+
"node": "22.15.0",
|
|
51
|
+
"pnpm": "10.10.0"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
53
54
|
"dist",
|