@futdevpro/dynamo-eslint 1.15.28 → 1.20.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/README.md +13 -16
- package/__documentations/2026-08-22-angular-20-phase2-release.md +83 -0
- package/build/configs/base.d.ts +8 -9
- package/build/configs/base.d.ts.map +1 -1
- package/build/configs/base.js +149 -150
- package/build/configs/base.js.map +1 -1
- package/build/configs/fsm.d.ts +1 -1
- package/build/configs/fsm.js +7 -7
- package/build/configs/ngx-package.d.ts +1 -1
- package/build/configs/ngx-package.js +7 -7
- package/build/configs/ngx.d.ts +2 -4
- package/build/configs/ngx.d.ts.map +1 -1
- package/build/configs/ngx.js +88 -91
- package/build/configs/ngx.js.map +1 -1
- package/build/configs/nts-package.d.ts +1 -1
- package/build/configs/nts-package.js +17 -17
- package/build/configs/nts.d.ts +1 -1
- package/build/configs/nts.js +31 -31
- package/build/index.d.ts +1 -1
- package/build/index.js +2 -2
- package/build/plugin/index.d.ts +52 -52
- package/build/plugin/index.js +80 -80
- package/build/plugin/rules/angular/angular-for-track-logic.d.ts +7 -7
- package/build/plugin/rules/angular/angular-for-track-logic.js +81 -81
- package/build/plugin/rules/angular/effect-signal-loop.d.ts +9 -9
- package/build/plugin/rules/angular/effect-signal-loop.js +112 -112
- package/build/plugin/rules/angular/no-async-ngoninit.d.ts +8 -8
- package/build/plugin/rules/angular/no-async-ngoninit.js +42 -42
- package/build/plugin/rules/angular/no-component-direct-api.d.ts +9 -9
- package/build/plugin/rules/angular/no-component-direct-api.js +75 -75
- package/build/plugin/rules/angular/no-method-call-in-template.d.ts +8 -8
- package/build/plugin/rules/angular/no-method-call-in-template.js +79 -79
- package/build/plugin/rules/angular/no-ngfor-directive.d.ts +7 -7
- package/build/plugin/rules/angular/no-ngfor-directive.js +59 -59
- package/build/plugin/rules/angular/no-ngif-directive.d.ts +7 -7
- package/build/plugin/rules/angular/no-ngif-directive.js +59 -59
- package/build/plugin/rules/explicit-types.d.ts +3 -3
- package/build/plugin/rules/explicit-types.js +178 -178
- package/build/plugin/rules/import/import-order.d.ts +3 -3
- package/build/plugin/rules/import/import-order.js +154 -154
- package/build/plugin/rules/import/no-import-type.d.ts +3 -3
- package/build/plugin/rules/import/no-import-type.js +45 -45
- package/build/plugin/rules/import/no-js-import.d.ts +3 -3
- package/build/plugin/rules/import/no-js-import.js +40 -40
- package/build/plugin/rules/naming-patterns.d.ts +7 -7
- package/build/plugin/rules/naming-patterns.js +366 -366
- package/build/plugin/rules/no-getter-logic.d.ts +3 -3
- package/build/plugin/rules/no-getter-logic.js +194 -194
- package/build/plugin/rules/no-getter-logic.js.map +1 -1
- package/build/plugin/rules/prefer-enum-over-string-union.d.ts +3 -3
- package/build/plugin/rules/prefer-enum-over-string-union.js +289 -289
- package/build/plugin/rules/prefer-enum-over-string-union.js.map +1 -1
- package/build/plugin/rules/prefer-interface-over-duplicate-types.d.ts +3 -3
- package/build/plugin/rules/prefer-interface-over-duplicate-types.js +264 -264
- package/build/plugin/rules/prefer-interface-over-duplicate-types.js.map +1 -1
- package/build/plugin/rules/require-jsdoc-description.d.ts +3 -3
- package/build/plugin/rules/require-jsdoc-description.js +496 -496
- package/build/plugin/rules/require-jsdoc-description.js.map +1 -1
- package/build/plugin/rules/require-test-description-prefix.d.ts +3 -3
- package/build/plugin/rules/require-test-description-prefix.js +135 -135
- package/build/plugin/rules/ts/data-model-extends.d.ts +8 -8
- package/build/plugin/rules/ts/data-model-extends.js +94 -94
- package/build/plugin/rules/ts/no-any-type.d.ts +8 -8
- package/build/plugin/rules/ts/no-any-type.js +36 -36
- package/build/plugin/rules/ts/no-as-cast.d.ts +8 -8
- package/build/plugin/rules/ts/no-as-cast.js +49 -49
- package/build/plugin/rules/ts/no-dynamic-imports.d.ts +8 -8
- package/build/plugin/rules/ts/no-dynamic-imports.js +50 -50
- package/build/plugin/rules/ts/no-native-browser-dialogs.d.ts +8 -8
- package/build/plugin/rules/ts/no-native-browser-dialogs.js +78 -78
- package/build/plugin/rules/ts/no-plain-function-export.d.ts +9 -9
- package/build/plugin/rules/ts/no-plain-function-export.js +69 -69
- package/build/plugin/rules/ts/one-export-per-file.d.ts +8 -8
- package/build/plugin/rules/ts/one-export-per-file.js +73 -73
- package/build/scripts/dynamo-fix.d.ts +26 -26
- package/build/scripts/dynamo-fix.js +146 -146
- package/build/scripts/dynamo-fix.js.map +1 -1
- package/build/scripts/eslintrc-audit.d.ts +26 -26
- package/build/scripts/eslintrc-audit.js +100 -100
- package/build/scripts/fix-return-types.d.ts +74 -74
- package/build/scripts/fix-return-types.d.ts.map +1 -1
- package/build/scripts/fix-return-types.js +226 -226
- package/build/scripts/fix-return-types.js.map +1 -1
- package/build/scripts/validate-imports.d.ts +26 -26
- package/build/scripts/validate-imports.js +170 -157
- package/build/scripts/validate-imports.js.map +1 -1
- package/build/scripts/validate-naming.d.ts +26 -26
- package/build/scripts/validate-naming.js +170 -157
- package/build/scripts/validate-naming.js.map +1 -1
- package/eslint.config.js +1 -1
- package/package.json +104 -105
- package/pnpm-workspace.yaml +2 -0
- package/samples/package.json.example +5 -9
- package/src/configs/angular20-compatibility.spec.ts +73 -0
- package/src/configs/base.ts +3 -4
- package/src/configs/ngx.ts +7 -10
- package/src/plugin/rules/no-getter-logic.ts +1 -1
- package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +9 -9
- package/src/plugin/rules/prefer-enum-over-string-union.ts +7 -8
- package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +22 -22
- package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +2 -2
- package/src/plugin/rules/require-jsdoc-description.spec.ts +2 -2
- package/src/plugin/rules/require-jsdoc-description.ts +7 -7
- package/src/scripts/dynamo-fix.ts +1 -1
- package/src/scripts/fix-return-types.ts +4 -3
- package/src/scripts/validate-imports.ts +29 -15
- package/src/scripts/validate-naming.ts +29 -20
- package/src/scripts/validator-cli.integration.spec.ts +11 -8
|
@@ -1,367 +1,367 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const path = tslib_1.__importStar(require("path"));
|
|
5
|
-
/**
|
|
6
|
-
* Fájlminta → kötelező class postfix leképezés (CCAP file-class-postfix).
|
|
7
|
-
*/
|
|
8
|
-
const FILE_POSTFIX_MAP = [
|
|
9
|
-
{ pattern: /\.data-model\.ts$/, classPostfix: '_DataModel', entitySuffix: '.data-model.ts' },
|
|
10
|
-
{ pattern: /\.control-model\.ts$/, classPostfix: '_ControlModel', entitySuffix: '.control-model.ts' },
|
|
11
|
-
{ pattern: /\.control-service\.ts$/, classPostfix: '_ControlService', entitySuffix: '.control-service.ts' },
|
|
12
|
-
{ pattern: /\.data-service\.ts$/, classPostfix: '_DataService', entitySuffix: '.data-service.ts' },
|
|
13
|
-
{ pattern: /\.api-service\.ts$/, classPostfix: '_ApiService', entitySuffix: '.api-service.ts' },
|
|
14
|
-
{ pattern: /\.util-service\.ts$/, classPostfix: '_Util', entitySuffix: '.util-service.ts' },
|
|
15
|
-
{ pattern: /\.service-base\.ts$/, classPostfix: '_ServiceBase', entitySuffix: '.service-base.ts' },
|
|
16
|
-
{ pattern: /\.controller\.ts$/, classPostfix: '_Controller', entitySuffix: '.controller.ts' },
|
|
17
|
-
{ pattern: /\.component\.ts$/, classPostfix: '_Component', entitySuffix: '.component.ts' },
|
|
18
|
-
{ pattern: /\.pipe\.ts$/, classPostfix: '_Pipe', entitySuffix: '.pipe.ts' },
|
|
19
|
-
{ pattern: /\.directive\.ts$/, classPostfix: '_Directive', entitySuffix: '.directive.ts' },
|
|
20
|
-
{ pattern: /\.module\.ts$/, classPostfix: '_Module', entitySuffix: '.module.ts' },
|
|
21
|
-
];
|
|
22
|
-
/**
|
|
23
|
-
* BFR-ADVENTOR-018: kanonikus, a service-property-postfix kényszer ALÓL KIVETT property-nevek.
|
|
24
|
-
* Az `ls` a flotta bevett nyelv-service mintája (`readonly ls = inject(A_Language_ControlService)`;
|
|
25
|
-
* a template-ekben `{{ ls.llt.… }}`) — a szabály eddig a bedrock SAJÁT dokumentált
|
|
26
|
-
* konzumens-mintáját flagelte. Projekt-szinten bővíthető az `allowedPropertyNames` opcióval.
|
|
27
|
-
*/
|
|
28
|
-
const DEFAULT_ALLOWED_PROPERTY_NAMES = ['ls'];
|
|
29
|
-
/** Service class postfix → kötelező inject property postfix leképezés (CCAP service-property-postfix). */
|
|
30
|
-
const SERVICE_INJECT_POSTFIX_MAP = [
|
|
31
|
-
{ classPostfix: '_DataService', propertyPostfix: '_DS' },
|
|
32
|
-
{ classPostfix: '_ControlService', propertyPostfix: '_CS' },
|
|
33
|
-
{ classPostfix: '_ApiService', propertyPostfix: '_AS' },
|
|
34
|
-
{ classPostfix: '_MasterService', propertyPostfix: '_MS' },
|
|
35
|
-
];
|
|
36
|
-
/** Signal factory függvény nevek (CCAP signal-postfix). */
|
|
37
|
-
const SIGNAL_FACTORY_NAMES = new Set(['signal', 'computed', 'toSignal']);
|
|
38
|
-
/** RxJS típusnevek detektáláshoz. */
|
|
39
|
-
const RXJS_BEHAVIOR_SUBJECT_NAME = 'BehaviorSubject';
|
|
40
|
-
const RXJS_SUBJECT_NAME = 'Subject';
|
|
41
|
-
const RXJS_OBSERVABLE_NAME = 'Observable';
|
|
42
|
-
/** camelCase enum kulcs regex. */
|
|
43
|
-
const CAMEL_CASE_KEY_REGEX = /^[a-z][a-zA-Z0-9]*$/;
|
|
44
|
-
/** kebab-case enum érték regex. */
|
|
45
|
-
const KEBAB_CASE_VALUE_REGEX = /^[a-z0-9][a-z0-9-]*$/;
|
|
46
|
-
/**
|
|
47
|
-
* PascalCase szót kebab-case-re konvertál (CCAP file-class-name-consistency).
|
|
48
|
-
*/
|
|
49
|
-
function pascalPartToKebab(str) {
|
|
50
|
-
if (str === str.toUpperCase() && str.length > 1) {
|
|
51
|
-
return str.toLowerCase();
|
|
52
|
-
}
|
|
53
|
-
return str
|
|
54
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
55
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
56
|
-
.toLowerCase();
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Class entity nevet kebab-case fájlnév entity részére konvertál.
|
|
60
|
-
*/
|
|
61
|
-
function classEntityToKebab(classEntity) {
|
|
62
|
-
const parts = classEntity.split('_').filter((p) => p.length > 0);
|
|
63
|
-
return parts.map(pascalPartToKebab).join('-');
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Megnézi, hogy a property type-annotation `boolean`-e.
|
|
67
|
-
*/
|
|
68
|
-
function isBooleanType(typeAnnotation) {
|
|
69
|
-
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return typeAnnotation.typeAnnotation.type === 'TSBooleanKeyword';
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Megnézi, hogy a property init signal/computed/toSignal hívás-e.
|
|
76
|
-
*/
|
|
77
|
-
function isSignalFactoryCall(init) {
|
|
78
|
-
if (!init || init.type !== 'CallExpression') {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
const callee = init.callee;
|
|
82
|
-
if (!callee || callee.type !== 'Identifier') {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return SIGNAL_FACTORY_NAMES.has(callee.name);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Detektálja az RxJS típust property type-annotation vagy `new XSubject()` init alapján.
|
|
89
|
-
*/
|
|
90
|
-
function detectRxjsKind(typeAnnotation, init) {
|
|
91
|
-
const typeName = (() => {
|
|
92
|
-
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
const t = typeAnnotation.typeAnnotation;
|
|
96
|
-
if (t.type !== 'TSTypeReference' || !t.typeName) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
if (t.typeName.type === 'Identifier') {
|
|
100
|
-
return t.typeName.name;
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
})();
|
|
104
|
-
const newName = (() => {
|
|
105
|
-
if (!init || init.type !== 'NewExpression' || !init.callee || init.callee.type !== 'Identifier') {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
return init.callee.name;
|
|
109
|
-
})();
|
|
110
|
-
const candidate = typeName ?? newName;
|
|
111
|
-
if (candidate === null) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
if (candidate === RXJS_BEHAVIOR_SUBJECT_NAME) {
|
|
115
|
-
return 'BS';
|
|
116
|
-
}
|
|
117
|
-
if (candidate === RXJS_SUBJECT_NAME) {
|
|
118
|
-
return 'S';
|
|
119
|
-
}
|
|
120
|
-
if (candidate === RXJS_OBSERVABLE_NAME) {
|
|
121
|
-
return 'OBS';
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Detektálja, hogy az init `inject(SomeService)` hívás-e — visszaadja a service nevet.
|
|
127
|
-
*/
|
|
128
|
-
function detectInjectedService(init) {
|
|
129
|
-
if (!init || init.type !== 'CallExpression') {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
if (!init.callee || init.callee.type !== 'Identifier' || init.callee.name !== 'inject') {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const arg = init.arguments && init.arguments[0];
|
|
136
|
-
if (!arg || arg.type !== 'Identifier') {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return arg.name;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Property kulcs név szöveggé alakítása.
|
|
143
|
-
*/
|
|
144
|
-
function getPropertyKeyName(node) {
|
|
145
|
-
if (node.key && node.key.type === 'Identifier' && node.key.name) {
|
|
146
|
-
return node.key.name;
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Naming-patterns szabály (CCAP-megerősített): 7 al-ellenőrzés a CCAP "naming/*" review-kből.
|
|
152
|
-
* Minden al-ellenőrzés külön-külön kapcsolható a `checks` schema option-nel.
|
|
153
|
-
*/
|
|
154
|
-
const rule = {
|
|
155
|
-
meta: {
|
|
156
|
-
type: 'suggestion',
|
|
157
|
-
docs: {
|
|
158
|
-
description: 'Enforce Dynamo naming conventions (CCAP-derived sub-checks).',
|
|
159
|
-
recommended: true,
|
|
160
|
-
},
|
|
161
|
-
schema: [
|
|
162
|
-
{
|
|
163
|
-
type: 'object',
|
|
164
|
-
properties: {
|
|
165
|
-
checks: {
|
|
166
|
-
type: 'object',
|
|
167
|
-
properties: {
|
|
168
|
-
booleanIsPrefix: { type: 'boolean' },
|
|
169
|
-
signalPostfix: { type: 'boolean' },
|
|
170
|
-
rxjsPostfix: { type: 'boolean' },
|
|
171
|
-
fileClassPostfix: { type: 'boolean' },
|
|
172
|
-
enumValueFormat: { type: 'boolean' },
|
|
173
|
-
servicePropertyPostfix: { type: 'boolean' },
|
|
174
|
-
fileClassNameConsistency: { type: 'boolean' },
|
|
175
|
-
},
|
|
176
|
-
additionalProperties: false,
|
|
177
|
-
},
|
|
178
|
-
allowedPropertyNames: {
|
|
179
|
-
type: 'array',
|
|
180
|
-
items: { type: 'string' },
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
additionalProperties: false,
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
messages: {
|
|
187
|
-
booleanIsPrefix: 'Boolean property `{{name}}` nem `is`-sel kezdődik.',
|
|
188
|
-
signalPostfix: 'Signal változó `{{name}}` nem végződik `_$`-re.',
|
|
189
|
-
rxjsBsPostfix: '`BehaviorSubject` mező `{{name}}` nem végződik `_BS`-re.',
|
|
190
|
-
rxjsSPostfix: '`Subject` mező `{{name}}` nem végződik `_S`-re.',
|
|
191
|
-
rxjsObsPostfix: '`Observable` mező `{{name}}` nem végződik `$`-re.',
|
|
192
|
-
fileClassPostfix: 'Osztály `{{className}}` nem végződik `{{requiredPostfix}}`-re (fájlminta: {{fileName}}).',
|
|
193
|
-
enumKeyCamel: 'Enum kulcs `{{keyName}}` nem camelCase.',
|
|
194
|
-
enumValueKebab: 'Enum érték `{{value}}` nem kebab-case.',
|
|
195
|
-
servicePropertyPostfix: 'Property `{{property}}` `{{service}}`-t inject-el, de nem végződik `{{requiredPostfix}}`-re.',
|
|
196
|
-
fileClassNameConsistency: 'Osztály `{{className}}` entity része `{{classEntity}}` → '
|
|
197
|
-
+ 'elvárt fájlnév entity: `{{expected}}`, de a tényleges: `{{actual}}`.',
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
create(context) {
|
|
201
|
-
const filename = context.filename ?? '';
|
|
202
|
-
const baseName = path.basename(filename);
|
|
203
|
-
if (baseName.endsWith('.spec.ts') || baseName.endsWith('.test.ts') || baseName.endsWith('.d.ts')) {
|
|
204
|
-
return {};
|
|
205
|
-
}
|
|
206
|
-
const userOptions = (context.options[0] ?? {});
|
|
207
|
-
const checks = userOptions.checks ?? {};
|
|
208
|
-
const isOn = (key) => checks[key] !== false;
|
|
209
|
-
// BFR-ADVENTOR-018: beépített kanonikus kivételek + projekt-szintű bővítés
|
|
210
|
-
const allowedPropertyNames = [
|
|
211
|
-
...DEFAULT_ALLOWED_PROPERTY_NAMES,
|
|
212
|
-
...(userOptions.allowedPropertyNames ?? []),
|
|
213
|
-
];
|
|
214
|
-
const filePostfixRule = FILE_POSTFIX_MAP.find((r) => r.pattern.test(baseName));
|
|
215
|
-
return {
|
|
216
|
-
PropertyDefinition(node) {
|
|
217
|
-
try {
|
|
218
|
-
const propName = getPropertyKeyName(node);
|
|
219
|
-
if (propName === null) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
if (isOn('booleanIsPrefix')
|
|
223
|
-
&& isBooleanType(node.typeAnnotation)
|
|
224
|
-
&& !propName.startsWith('is')
|
|
225
|
-
&& !propName.endsWith('_$')) {
|
|
226
|
-
context.report({
|
|
227
|
-
node: node.key,
|
|
228
|
-
messageId: 'booleanIsPrefix',
|
|
229
|
-
data: { name: propName },
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if (isOn('signalPostfix')
|
|
233
|
-
&& isSignalFactoryCall(node.value)
|
|
234
|
-
&& !propName.endsWith('_$')) {
|
|
235
|
-
context.report({
|
|
236
|
-
node: node.key,
|
|
237
|
-
messageId: 'signalPostfix',
|
|
238
|
-
data: { name: propName },
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
if (isOn('rxjsPostfix')) {
|
|
242
|
-
const rxKind = detectRxjsKind(node.typeAnnotation, node.value);
|
|
243
|
-
if (rxKind === 'BS' && !propName.endsWith('_BS')) {
|
|
244
|
-
context.report({ node: node.key, messageId: 'rxjsBsPostfix', data: { name: propName } });
|
|
245
|
-
}
|
|
246
|
-
else if (rxKind === 'S' && !propName.endsWith('_S') && !propName.endsWith('_BS')) {
|
|
247
|
-
context.report({ node: node.key, messageId: 'rxjsSPostfix', data: { name: propName } });
|
|
248
|
-
}
|
|
249
|
-
else if (rxKind === 'OBS' && !propName.endsWith('$')) {
|
|
250
|
-
context.report({ node: node.key, messageId: 'rxjsObsPostfix', data: { name: propName } });
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (isOn('servicePropertyPostfix') && !allowedPropertyNames.includes(propName)) {
|
|
254
|
-
const injectedService = detectInjectedService(node.value);
|
|
255
|
-
if (injectedService !== null) {
|
|
256
|
-
for (const mapping of SERVICE_INJECT_POSTFIX_MAP) {
|
|
257
|
-
if (injectedService.endsWith(mapping.classPostfix)
|
|
258
|
-
&& !propName.endsWith(mapping.propertyPostfix)) {
|
|
259
|
-
context.report({
|
|
260
|
-
node: node.key,
|
|
261
|
-
messageId: 'servicePropertyPostfix',
|
|
262
|
-
data: {
|
|
263
|
-
property: propName,
|
|
264
|
-
service: injectedService,
|
|
265
|
-
requiredPostfix: mapping.propertyPostfix,
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
console.error('[naming-patterns] Error in PropertyDefinition visitor:', error);
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
ClassDeclaration(node) {
|
|
279
|
-
try {
|
|
280
|
-
if (!node.id || !node.id.name || !filePostfixRule) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const className = node.id.name;
|
|
284
|
-
if (isOn('fileClassPostfix') && !className.endsWith(filePostfixRule.classPostfix)) {
|
|
285
|
-
context.report({
|
|
286
|
-
node: node.id,
|
|
287
|
-
messageId: 'fileClassPostfix',
|
|
288
|
-
data: {
|
|
289
|
-
className: className,
|
|
290
|
-
requiredPostfix: filePostfixRule.classPostfix,
|
|
291
|
-
fileName: baseName,
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
if (isOn('fileClassNameConsistency') && className.endsWith(filePostfixRule.classPostfix)) {
|
|
296
|
-
const fileEntity = baseName.slice(0, baseName.length - filePostfixRule.entitySuffix.length);
|
|
297
|
-
const classEntity = className.slice(0, className.length - filePostfixRule.classPostfix.length);
|
|
298
|
-
const expectedFull = classEntityToKebab(classEntity);
|
|
299
|
-
const firstUnderscoreIdx = classEntity.indexOf('_');
|
|
300
|
-
const expectedWithoutPrefix = firstUnderscoreIdx > 0
|
|
301
|
-
? classEntityToKebab(classEntity.slice(firstUnderscoreIdx + 1))
|
|
302
|
-
: '';
|
|
303
|
-
const isMatch = expectedFull === fileEntity || expectedWithoutPrefix === fileEntity;
|
|
304
|
-
if (!isMatch && classEntity.length > 0) {
|
|
305
|
-
context.report({
|
|
306
|
-
node: node.id,
|
|
307
|
-
messageId: 'fileClassNameConsistency',
|
|
308
|
-
data: {
|
|
309
|
-
className: className,
|
|
310
|
-
classEntity: classEntity,
|
|
311
|
-
expected: expectedFull + (expectedWithoutPrefix ? ` vagy ${expectedWithoutPrefix}` : ''),
|
|
312
|
-
actual: fileEntity,
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
catch (error) {
|
|
319
|
-
console.error('[naming-patterns] Error in ClassDeclaration visitor:', error);
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
TSEnumDeclaration(node) {
|
|
323
|
-
try {
|
|
324
|
-
if (!isOn('enumValueFormat')) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (!baseName.endsWith('.type-enum.ts')) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
const members = node.members ?? [];
|
|
331
|
-
for (const member of members) {
|
|
332
|
-
const keyName = (member.id && member.id.name) ? member.id.name : null;
|
|
333
|
-
const initializer = member.initializer;
|
|
334
|
-
if (keyName === null) {
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (!CAMEL_CASE_KEY_REGEX.test(keyName)) {
|
|
338
|
-
context.report({
|
|
339
|
-
node: member.id,
|
|
340
|
-
messageId: 'enumKeyCamel',
|
|
341
|
-
data: { keyName: keyName },
|
|
342
|
-
});
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
if (initializer
|
|
346
|
-
&& initializer.type === 'Literal'
|
|
347
|
-
&& typeof initializer.value === 'string') {
|
|
348
|
-
const value = initializer.value;
|
|
349
|
-
if (!KEBAB_CASE_VALUE_REGEX.test(value)) {
|
|
350
|
-
context.report({
|
|
351
|
-
node: initializer,
|
|
352
|
-
messageId: 'enumValueKebab',
|
|
353
|
-
data: { value: value },
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
catch (error) {
|
|
360
|
-
console.error('[naming-patterns] Error in TSEnumDeclaration visitor:', error);
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
};
|
|
364
|
-
},
|
|
365
|
-
};
|
|
366
|
-
exports.default = rule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const path = tslib_1.__importStar(require("path"));
|
|
5
|
+
/**
|
|
6
|
+
* Fájlminta → kötelező class postfix leképezés (CCAP file-class-postfix).
|
|
7
|
+
*/
|
|
8
|
+
const FILE_POSTFIX_MAP = [
|
|
9
|
+
{ pattern: /\.data-model\.ts$/, classPostfix: '_DataModel', entitySuffix: '.data-model.ts' },
|
|
10
|
+
{ pattern: /\.control-model\.ts$/, classPostfix: '_ControlModel', entitySuffix: '.control-model.ts' },
|
|
11
|
+
{ pattern: /\.control-service\.ts$/, classPostfix: '_ControlService', entitySuffix: '.control-service.ts' },
|
|
12
|
+
{ pattern: /\.data-service\.ts$/, classPostfix: '_DataService', entitySuffix: '.data-service.ts' },
|
|
13
|
+
{ pattern: /\.api-service\.ts$/, classPostfix: '_ApiService', entitySuffix: '.api-service.ts' },
|
|
14
|
+
{ pattern: /\.util-service\.ts$/, classPostfix: '_Util', entitySuffix: '.util-service.ts' },
|
|
15
|
+
{ pattern: /\.service-base\.ts$/, classPostfix: '_ServiceBase', entitySuffix: '.service-base.ts' },
|
|
16
|
+
{ pattern: /\.controller\.ts$/, classPostfix: '_Controller', entitySuffix: '.controller.ts' },
|
|
17
|
+
{ pattern: /\.component\.ts$/, classPostfix: '_Component', entitySuffix: '.component.ts' },
|
|
18
|
+
{ pattern: /\.pipe\.ts$/, classPostfix: '_Pipe', entitySuffix: '.pipe.ts' },
|
|
19
|
+
{ pattern: /\.directive\.ts$/, classPostfix: '_Directive', entitySuffix: '.directive.ts' },
|
|
20
|
+
{ pattern: /\.module\.ts$/, classPostfix: '_Module', entitySuffix: '.module.ts' },
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* BFR-ADVENTOR-018: kanonikus, a service-property-postfix kényszer ALÓL KIVETT property-nevek.
|
|
24
|
+
* Az `ls` a flotta bevett nyelv-service mintája (`readonly ls = inject(A_Language_ControlService)`;
|
|
25
|
+
* a template-ekben `{{ ls.llt.… }}`) — a szabály eddig a bedrock SAJÁT dokumentált
|
|
26
|
+
* konzumens-mintáját flagelte. Projekt-szinten bővíthető az `allowedPropertyNames` opcióval.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_ALLOWED_PROPERTY_NAMES = ['ls'];
|
|
29
|
+
/** Service class postfix → kötelező inject property postfix leképezés (CCAP service-property-postfix). */
|
|
30
|
+
const SERVICE_INJECT_POSTFIX_MAP = [
|
|
31
|
+
{ classPostfix: '_DataService', propertyPostfix: '_DS' },
|
|
32
|
+
{ classPostfix: '_ControlService', propertyPostfix: '_CS' },
|
|
33
|
+
{ classPostfix: '_ApiService', propertyPostfix: '_AS' },
|
|
34
|
+
{ classPostfix: '_MasterService', propertyPostfix: '_MS' },
|
|
35
|
+
];
|
|
36
|
+
/** Signal factory függvény nevek (CCAP signal-postfix). */
|
|
37
|
+
const SIGNAL_FACTORY_NAMES = new Set(['signal', 'computed', 'toSignal']);
|
|
38
|
+
/** RxJS típusnevek detektáláshoz. */
|
|
39
|
+
const RXJS_BEHAVIOR_SUBJECT_NAME = 'BehaviorSubject';
|
|
40
|
+
const RXJS_SUBJECT_NAME = 'Subject';
|
|
41
|
+
const RXJS_OBSERVABLE_NAME = 'Observable';
|
|
42
|
+
/** camelCase enum kulcs regex. */
|
|
43
|
+
const CAMEL_CASE_KEY_REGEX = /^[a-z][a-zA-Z0-9]*$/;
|
|
44
|
+
/** kebab-case enum érték regex. */
|
|
45
|
+
const KEBAB_CASE_VALUE_REGEX = /^[a-z0-9][a-z0-9-]*$/;
|
|
46
|
+
/**
|
|
47
|
+
* PascalCase szót kebab-case-re konvertál (CCAP file-class-name-consistency).
|
|
48
|
+
*/
|
|
49
|
+
function pascalPartToKebab(str) {
|
|
50
|
+
if (str === str.toUpperCase() && str.length > 1) {
|
|
51
|
+
return str.toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
return str
|
|
54
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
55
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
56
|
+
.toLowerCase();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Class entity nevet kebab-case fájlnév entity részére konvertál.
|
|
60
|
+
*/
|
|
61
|
+
function classEntityToKebab(classEntity) {
|
|
62
|
+
const parts = classEntity.split('_').filter((p) => p.length > 0);
|
|
63
|
+
return parts.map(pascalPartToKebab).join('-');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Megnézi, hogy a property type-annotation `boolean`-e.
|
|
67
|
+
*/
|
|
68
|
+
function isBooleanType(typeAnnotation) {
|
|
69
|
+
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return typeAnnotation.typeAnnotation.type === 'TSBooleanKeyword';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Megnézi, hogy a property init signal/computed/toSignal hívás-e.
|
|
76
|
+
*/
|
|
77
|
+
function isSignalFactoryCall(init) {
|
|
78
|
+
if (!init || init.type !== 'CallExpression') {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const callee = init.callee;
|
|
82
|
+
if (!callee || callee.type !== 'Identifier') {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return SIGNAL_FACTORY_NAMES.has(callee.name);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Detektálja az RxJS típust property type-annotation vagy `new XSubject()` init alapján.
|
|
89
|
+
*/
|
|
90
|
+
function detectRxjsKind(typeAnnotation, init) {
|
|
91
|
+
const typeName = (() => {
|
|
92
|
+
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const t = typeAnnotation.typeAnnotation;
|
|
96
|
+
if (t.type !== 'TSTypeReference' || !t.typeName) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (t.typeName.type === 'Identifier') {
|
|
100
|
+
return t.typeName.name;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
})();
|
|
104
|
+
const newName = (() => {
|
|
105
|
+
if (!init || init.type !== 'NewExpression' || !init.callee || init.callee.type !== 'Identifier') {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return init.callee.name;
|
|
109
|
+
})();
|
|
110
|
+
const candidate = typeName ?? newName;
|
|
111
|
+
if (candidate === null) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
if (candidate === RXJS_BEHAVIOR_SUBJECT_NAME) {
|
|
115
|
+
return 'BS';
|
|
116
|
+
}
|
|
117
|
+
if (candidate === RXJS_SUBJECT_NAME) {
|
|
118
|
+
return 'S';
|
|
119
|
+
}
|
|
120
|
+
if (candidate === RXJS_OBSERVABLE_NAME) {
|
|
121
|
+
return 'OBS';
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Detektálja, hogy az init `inject(SomeService)` hívás-e — visszaadja a service nevet.
|
|
127
|
+
*/
|
|
128
|
+
function detectInjectedService(init) {
|
|
129
|
+
if (!init || init.type !== 'CallExpression') {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
if (!init.callee || init.callee.type !== 'Identifier' || init.callee.name !== 'inject') {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const arg = init.arguments && init.arguments[0];
|
|
136
|
+
if (!arg || arg.type !== 'Identifier') {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return arg.name;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Property kulcs név szöveggé alakítása.
|
|
143
|
+
*/
|
|
144
|
+
function getPropertyKeyName(node) {
|
|
145
|
+
if (node.key && node.key.type === 'Identifier' && node.key.name) {
|
|
146
|
+
return node.key.name;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Naming-patterns szabály (CCAP-megerősített): 7 al-ellenőrzés a CCAP "naming/*" review-kből.
|
|
152
|
+
* Minden al-ellenőrzés külön-külön kapcsolható a `checks` schema option-nel.
|
|
153
|
+
*/
|
|
154
|
+
const rule = {
|
|
155
|
+
meta: {
|
|
156
|
+
type: 'suggestion',
|
|
157
|
+
docs: {
|
|
158
|
+
description: 'Enforce Dynamo naming conventions (CCAP-derived sub-checks).',
|
|
159
|
+
recommended: true,
|
|
160
|
+
},
|
|
161
|
+
schema: [
|
|
162
|
+
{
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
checks: {
|
|
166
|
+
type: 'object',
|
|
167
|
+
properties: {
|
|
168
|
+
booleanIsPrefix: { type: 'boolean' },
|
|
169
|
+
signalPostfix: { type: 'boolean' },
|
|
170
|
+
rxjsPostfix: { type: 'boolean' },
|
|
171
|
+
fileClassPostfix: { type: 'boolean' },
|
|
172
|
+
enumValueFormat: { type: 'boolean' },
|
|
173
|
+
servicePropertyPostfix: { type: 'boolean' },
|
|
174
|
+
fileClassNameConsistency: { type: 'boolean' },
|
|
175
|
+
},
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
},
|
|
178
|
+
allowedPropertyNames: {
|
|
179
|
+
type: 'array',
|
|
180
|
+
items: { type: 'string' },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
additionalProperties: false,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
messages: {
|
|
187
|
+
booleanIsPrefix: 'Boolean property `{{name}}` nem `is`-sel kezdődik.',
|
|
188
|
+
signalPostfix: 'Signal változó `{{name}}` nem végződik `_$`-re.',
|
|
189
|
+
rxjsBsPostfix: '`BehaviorSubject` mező `{{name}}` nem végződik `_BS`-re.',
|
|
190
|
+
rxjsSPostfix: '`Subject` mező `{{name}}` nem végződik `_S`-re.',
|
|
191
|
+
rxjsObsPostfix: '`Observable` mező `{{name}}` nem végződik `$`-re.',
|
|
192
|
+
fileClassPostfix: 'Osztály `{{className}}` nem végződik `{{requiredPostfix}}`-re (fájlminta: {{fileName}}).',
|
|
193
|
+
enumKeyCamel: 'Enum kulcs `{{keyName}}` nem camelCase.',
|
|
194
|
+
enumValueKebab: 'Enum érték `{{value}}` nem kebab-case.',
|
|
195
|
+
servicePropertyPostfix: 'Property `{{property}}` `{{service}}`-t inject-el, de nem végződik `{{requiredPostfix}}`-re.',
|
|
196
|
+
fileClassNameConsistency: 'Osztály `{{className}}` entity része `{{classEntity}}` → '
|
|
197
|
+
+ 'elvárt fájlnév entity: `{{expected}}`, de a tényleges: `{{actual}}`.',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
create(context) {
|
|
201
|
+
const filename = context.filename ?? '';
|
|
202
|
+
const baseName = path.basename(filename);
|
|
203
|
+
if (baseName.endsWith('.spec.ts') || baseName.endsWith('.test.ts') || baseName.endsWith('.d.ts')) {
|
|
204
|
+
return {};
|
|
205
|
+
}
|
|
206
|
+
const userOptions = (context.options[0] ?? {});
|
|
207
|
+
const checks = userOptions.checks ?? {};
|
|
208
|
+
const isOn = (key) => checks[key] !== false;
|
|
209
|
+
// BFR-ADVENTOR-018: beépített kanonikus kivételek + projekt-szintű bővítés
|
|
210
|
+
const allowedPropertyNames = [
|
|
211
|
+
...DEFAULT_ALLOWED_PROPERTY_NAMES,
|
|
212
|
+
...(userOptions.allowedPropertyNames ?? []),
|
|
213
|
+
];
|
|
214
|
+
const filePostfixRule = FILE_POSTFIX_MAP.find((r) => r.pattern.test(baseName));
|
|
215
|
+
return {
|
|
216
|
+
PropertyDefinition(node) {
|
|
217
|
+
try {
|
|
218
|
+
const propName = getPropertyKeyName(node);
|
|
219
|
+
if (propName === null) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (isOn('booleanIsPrefix')
|
|
223
|
+
&& isBooleanType(node.typeAnnotation)
|
|
224
|
+
&& !propName.startsWith('is')
|
|
225
|
+
&& !propName.endsWith('_$')) {
|
|
226
|
+
context.report({
|
|
227
|
+
node: node.key,
|
|
228
|
+
messageId: 'booleanIsPrefix',
|
|
229
|
+
data: { name: propName },
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (isOn('signalPostfix')
|
|
233
|
+
&& isSignalFactoryCall(node.value)
|
|
234
|
+
&& !propName.endsWith('_$')) {
|
|
235
|
+
context.report({
|
|
236
|
+
node: node.key,
|
|
237
|
+
messageId: 'signalPostfix',
|
|
238
|
+
data: { name: propName },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (isOn('rxjsPostfix')) {
|
|
242
|
+
const rxKind = detectRxjsKind(node.typeAnnotation, node.value);
|
|
243
|
+
if (rxKind === 'BS' && !propName.endsWith('_BS')) {
|
|
244
|
+
context.report({ node: node.key, messageId: 'rxjsBsPostfix', data: { name: propName } });
|
|
245
|
+
}
|
|
246
|
+
else if (rxKind === 'S' && !propName.endsWith('_S') && !propName.endsWith('_BS')) {
|
|
247
|
+
context.report({ node: node.key, messageId: 'rxjsSPostfix', data: { name: propName } });
|
|
248
|
+
}
|
|
249
|
+
else if (rxKind === 'OBS' && !propName.endsWith('$')) {
|
|
250
|
+
context.report({ node: node.key, messageId: 'rxjsObsPostfix', data: { name: propName } });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (isOn('servicePropertyPostfix') && !allowedPropertyNames.includes(propName)) {
|
|
254
|
+
const injectedService = detectInjectedService(node.value);
|
|
255
|
+
if (injectedService !== null) {
|
|
256
|
+
for (const mapping of SERVICE_INJECT_POSTFIX_MAP) {
|
|
257
|
+
if (injectedService.endsWith(mapping.classPostfix)
|
|
258
|
+
&& !propName.endsWith(mapping.propertyPostfix)) {
|
|
259
|
+
context.report({
|
|
260
|
+
node: node.key,
|
|
261
|
+
messageId: 'servicePropertyPostfix',
|
|
262
|
+
data: {
|
|
263
|
+
property: propName,
|
|
264
|
+
service: injectedService,
|
|
265
|
+
requiredPostfix: mapping.propertyPostfix,
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
console.error('[naming-patterns] Error in PropertyDefinition visitor:', error);
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
ClassDeclaration(node) {
|
|
279
|
+
try {
|
|
280
|
+
if (!node.id || !node.id.name || !filePostfixRule) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const className = node.id.name;
|
|
284
|
+
if (isOn('fileClassPostfix') && !className.endsWith(filePostfixRule.classPostfix)) {
|
|
285
|
+
context.report({
|
|
286
|
+
node: node.id,
|
|
287
|
+
messageId: 'fileClassPostfix',
|
|
288
|
+
data: {
|
|
289
|
+
className: className,
|
|
290
|
+
requiredPostfix: filePostfixRule.classPostfix,
|
|
291
|
+
fileName: baseName,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (isOn('fileClassNameConsistency') && className.endsWith(filePostfixRule.classPostfix)) {
|
|
296
|
+
const fileEntity = baseName.slice(0, baseName.length - filePostfixRule.entitySuffix.length);
|
|
297
|
+
const classEntity = className.slice(0, className.length - filePostfixRule.classPostfix.length);
|
|
298
|
+
const expectedFull = classEntityToKebab(classEntity);
|
|
299
|
+
const firstUnderscoreIdx = classEntity.indexOf('_');
|
|
300
|
+
const expectedWithoutPrefix = firstUnderscoreIdx > 0
|
|
301
|
+
? classEntityToKebab(classEntity.slice(firstUnderscoreIdx + 1))
|
|
302
|
+
: '';
|
|
303
|
+
const isMatch = expectedFull === fileEntity || expectedWithoutPrefix === fileEntity;
|
|
304
|
+
if (!isMatch && classEntity.length > 0) {
|
|
305
|
+
context.report({
|
|
306
|
+
node: node.id,
|
|
307
|
+
messageId: 'fileClassNameConsistency',
|
|
308
|
+
data: {
|
|
309
|
+
className: className,
|
|
310
|
+
classEntity: classEntity,
|
|
311
|
+
expected: expectedFull + (expectedWithoutPrefix ? ` vagy ${expectedWithoutPrefix}` : ''),
|
|
312
|
+
actual: fileEntity,
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
console.error('[naming-patterns] Error in ClassDeclaration visitor:', error);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
TSEnumDeclaration(node) {
|
|
323
|
+
try {
|
|
324
|
+
if (!isOn('enumValueFormat')) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!baseName.endsWith('.type-enum.ts')) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const members = node.members ?? [];
|
|
331
|
+
for (const member of members) {
|
|
332
|
+
const keyName = (member.id && member.id.name) ? member.id.name : null;
|
|
333
|
+
const initializer = member.initializer;
|
|
334
|
+
if (keyName === null) {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (!CAMEL_CASE_KEY_REGEX.test(keyName)) {
|
|
338
|
+
context.report({
|
|
339
|
+
node: member.id,
|
|
340
|
+
messageId: 'enumKeyCamel',
|
|
341
|
+
data: { keyName: keyName },
|
|
342
|
+
});
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (initializer
|
|
346
|
+
&& initializer.type === 'Literal'
|
|
347
|
+
&& typeof initializer.value === 'string') {
|
|
348
|
+
const value = initializer.value;
|
|
349
|
+
if (!KEBAB_CASE_VALUE_REGEX.test(value)) {
|
|
350
|
+
context.report({
|
|
351
|
+
node: initializer,
|
|
352
|
+
messageId: 'enumValueKebab',
|
|
353
|
+
data: { value: value },
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
console.error('[naming-patterns] Error in TSEnumDeclaration visitor:', error);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
exports.default = rule;
|
|
367
367
|
//# sourceMappingURL=naming-patterns.js.map
|