@futdevpro/dynamo-eslint 1.20.2 → 1.20.5

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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +305 -305
  3. package/build/configs/ngx.js +2 -2
  4. package/build/configs/ngx.js.map +1 -1
  5. package/build/plugin/rules/ts/no-as-cast.d.ts.map +1 -1
  6. package/build/plugin/rules/ts/no-as-cast.js +43 -0
  7. package/build/plugin/rules/ts/no-as-cast.js.map +1 -1
  8. package/package.json +14 -7
  9. package/.c8rc.json +0 -26
  10. package/.cursor/rules/__assistant_guide.mdc +0 -30
  11. package/.cursor/rules/__main.mdc +0 -64
  12. package/.cursor/rules/_ag_backend-structure.mdc +0 -86
  13. package/.cursor/rules/_ag_backend.mdc +0 -16
  14. package/.cursor/rules/_ag_debug.mdc +0 -8
  15. package/.cursor/rules/_ag_documentation_writing_rules.mdc +0 -372
  16. package/.cursor/rules/_ag_file-refactoring.mdc +0 -113
  17. package/.cursor/rules/_ag_fixes_rules.mdc +0 -6
  18. package/.cursor/rules/_ag_frontend-structure.mdc +0 -87
  19. package/.cursor/rules/_ag_frontend.mdc +0 -40
  20. package/.cursor/rules/_ag_import-rules.mdc +0 -45
  21. package/.cursor/rules/_ag_naming.mdc +0 -116
  22. package/.cursor/rules/_ag_running_commands.mdc +0 -5
  23. package/.cursor/rules/_ag_server-controller.mdc +0 -6
  24. package/.cursor/rules/_ag_should-be.mdc +0 -7
  25. package/.cursor/rules/_ag_swearing.mdc +0 -47
  26. package/.cursor/rules/ai_development_guide.md +0 -61
  27. package/.cursor/rules/ai_directives.md +0 -114
  28. package/.cursor/rules/cursor-rules.md +0 -160
  29. package/.cursor/rules/default-command.mdc +0 -465
  30. package/.cursor/rules/error_code_pattern.md +0 -40
  31. package/.cursor/rules/saved rule mcp server use.md +0 -16
  32. package/.dynamo/pipeline.cicd.config.json +0 -184
  33. package/.dynamo/version-bump.config.json +0 -5
  34. package/.eslintrc.json +0 -4
  35. package/.github/workflows/main.yml +0 -436
  36. package/.husky/pre-commit +0 -2
  37. package/.vscode/settings.json +0 -11
  38. package/__documentations/2026-04-18-ccap-review-integration.md +0 -173
  39. package/__documentations/2026-08-18-bfr-ctm-005-eslint9-validator-report.md +0 -45
  40. package/__documentations/2026-08-22-angular-20-phase2-release.md +0 -79
  41. package/eslint.config.js +0 -15
  42. package/pnpm-workspace.yaml +0 -2
  43. package/samples/.vscode/settings.json +0 -13
  44. package/samples/base/.eslintrc.json +0 -6
  45. package/samples/base/eslint.config.js +0 -3
  46. package/samples/fsm/.eslintrc.json +0 -4
  47. package/samples/fsm/eslint.config.js +0 -3
  48. package/samples/ngx/.eslintrc.json +0 -6
  49. package/samples/ngx/eslint.config.js +0 -3
  50. package/samples/ngx-package/.eslintrc.json +0 -4
  51. package/samples/ngx-package/eslint.config.js +0 -3
  52. package/samples/nts/.eslintrc.json +0 -6
  53. package/samples/nts/eslint.config.js +0 -3
  54. package/samples/nts-package/.eslintrc.json +0 -4
  55. package/samples/nts-package/eslint.config.js +0 -3
  56. package/samples/package.json.example +0 -22
  57. package/samples/poc-sample.ts +0 -38
  58. package/samples/poc-violations.ts +0 -54
  59. package/scripts/run-coverage-tests.js +0 -24
  60. package/spec/support/helpers/ts-node-helper.js +0 -9
  61. package/spec/support/jasmine.coverage.json +0 -23
  62. package/spec/support/jasmine.json +0 -24
  63. package/src/configs/angular20-compatibility.spec.ts +0 -62
  64. package/src/configs/base.ts +0 -156
  65. package/src/configs/fsm.ts +0 -10
  66. package/src/configs/ngx-package.ts +0 -10
  67. package/src/configs/ngx.ts +0 -93
  68. package/src/configs/nts-package.ts +0 -20
  69. package/src/configs/nts.ts +0 -34
  70. package/src/index.ts +0 -4
  71. package/src/plugin/index.ts +0 -86
  72. package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +0 -44
  73. package/src/plugin/rules/angular/angular-for-track-logic.ts +0 -88
  74. package/src/plugin/rules/angular/effect-signal-loop.spec.ts +0 -89
  75. package/src/plugin/rules/angular/effect-signal-loop.ts +0 -125
  76. package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +0 -50
  77. package/src/plugin/rules/angular/no-async-ngoninit.ts +0 -43
  78. package/src/plugin/rules/angular/no-component-direct-api.spec.ts +0 -78
  79. package/src/plugin/rules/angular/no-component-direct-api.ts +0 -82
  80. package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +0 -63
  81. package/src/plugin/rules/angular/no-method-call-in-template.ts +0 -89
  82. package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +0 -44
  83. package/src/plugin/rules/angular/no-ngfor-directive.ts +0 -62
  84. package/src/plugin/rules/angular/no-ngif-directive.spec.ts +0 -44
  85. package/src/plugin/rules/angular/no-ngif-directive.ts +0 -62
  86. package/src/plugin/rules/explicit-types.spec.ts +0 -190
  87. package/src/plugin/rules/explicit-types.ts +0 -186
  88. package/src/plugin/rules/import/import-order.spec.ts +0 -219
  89. package/src/plugin/rules/import/import-order.ts +0 -197
  90. package/src/plugin/rules/import/no-import-type.spec.ts +0 -69
  91. package/src/plugin/rules/import/no-import-type.ts +0 -46
  92. package/src/plugin/rules/import/no-js-import.spec.ts +0 -82
  93. package/src/plugin/rules/import/no-js-import.ts +0 -45
  94. package/src/plugin/rules/naming-patterns.spec.ts +0 -189
  95. package/src/plugin/rules/naming-patterns.ts +0 -426
  96. package/src/plugin/rules/no-getter-logic.spec.ts +0 -591
  97. package/src/plugin/rules/no-getter-logic.ts +0 -220
  98. package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +0 -583
  99. package/src/plugin/rules/prefer-enum-over-string-union.ts +0 -333
  100. package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +0 -404
  101. package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +0 -314
  102. package/src/plugin/rules/require-jsdoc-description.spec.ts +0 -779
  103. package/src/plugin/rules/require-jsdoc-description.ts +0 -572
  104. package/src/plugin/rules/require-test-description-prefix.spec.ts +0 -459
  105. package/src/plugin/rules/require-test-description-prefix.ts +0 -154
  106. package/src/plugin/rules/ts/data-model-extends.spec.ts +0 -84
  107. package/src/plugin/rules/ts/data-model-extends.ts +0 -100
  108. package/src/plugin/rules/ts/no-any-type.spec.ts +0 -28
  109. package/src/plugin/rules/ts/no-any-type.ts +0 -36
  110. package/src/plugin/rules/ts/no-as-cast.spec.ts +0 -51
  111. package/src/plugin/rules/ts/no-as-cast.ts +0 -51
  112. package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +0 -54
  113. package/src/plugin/rules/ts/no-dynamic-imports.ts +0 -49
  114. package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +0 -54
  115. package/src/plugin/rules/ts/no-native-browser-dialogs.ts +0 -84
  116. package/src/plugin/rules/ts/no-plain-function-export.spec.ts +0 -72
  117. package/src/plugin/rules/ts/no-plain-function-export.ts +0 -73
  118. package/src/plugin/rules/ts/one-export-per-file.spec.ts +0 -64
  119. package/src/plugin/rules/ts/one-export-per-file.ts +0 -77
  120. package/src/scripts/dynamo-fix.ts +0 -172
  121. package/src/scripts/eslintrc-audit.ts +0 -116
  122. package/src/scripts/fix-return-types.spec.ts +0 -65
  123. package/src/scripts/fix-return-types.ts +0 -289
  124. package/src/scripts/validate-imports.ts +0 -292
  125. package/src/scripts/validate-naming.ts +0 -213
  126. package/src/scripts/validator-cli.integration.spec.ts +0 -99
  127. package/tsconfig.json +0 -32
@@ -1,89 +0,0 @@
1
- import effectSignalLoopRule from './effect-signal-loop';
2
-
3
- describe('| effect-signal-loop', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(effectSignalLoopRule.meta?.type).toBe('problem');
6
- expect(effectSignalLoopRule.meta?.messages?.effectSignalLoop).toBeDefined();
7
- });
8
-
9
- it('| should report when same signal is read AND written in effect', () => {
10
- let reportCalled: boolean = false;
11
- const mockContext: any = {
12
- report: (options: any): void => {
13
- reportCalled = true;
14
- expect(options.messageId).toBe('effectSignalLoop');
15
- expect(options.data.signalName).toBe('count_$');
16
- },
17
- options: [],
18
- };
19
- const rule: any = effectSignalLoopRule.create(mockContext);
20
- const mockNode: any = {
21
- callee: { type: 'Identifier', name: 'effect' },
22
- arguments: [
23
- {
24
- type: 'ArrowFunctionExpression',
25
- body: {
26
- type: 'BlockStatement',
27
- body: [
28
- {
29
- type: 'ExpressionStatement',
30
- expression: {
31
- type: 'CallExpression',
32
- callee: { type: 'Identifier', name: 'count_$' },
33
- arguments: [],
34
- },
35
- },
36
- {
37
- type: 'ExpressionStatement',
38
- expression: {
39
- type: 'CallExpression',
40
- callee: {
41
- type: 'MemberExpression',
42
- object: { type: 'Identifier', name: 'count_$' },
43
- property: { type: 'Identifier', name: 'set' },
44
- },
45
- arguments: [{ type: 'Literal', value: 1 }],
46
- },
47
- },
48
- ],
49
- },
50
- },
51
- ],
52
- };
53
- rule.CallExpression(mockNode);
54
- expect(reportCalled).toBe(true);
55
- });
56
-
57
- it('| should not report when only reading a signal', () => {
58
- let reportCalled: boolean = false;
59
- const mockContext: any = { report: () => { reportCalled = true; }, options: [] };
60
- const rule: any = effectSignalLoopRule.create(mockContext);
61
- const mockNode: any = {
62
- callee: { type: 'Identifier', name: 'effect' },
63
- arguments: [
64
- {
65
- type: 'ArrowFunctionExpression',
66
- body: {
67
- type: 'CallExpression',
68
- callee: { type: 'Identifier', name: 'count_$' },
69
- arguments: [],
70
- },
71
- },
72
- ],
73
- };
74
- rule.CallExpression(mockNode);
75
- expect(reportCalled).toBe(false);
76
- });
77
-
78
- it('| should ignore non-effect calls', () => {
79
- let reportCalled: boolean = false;
80
- const mockContext: any = { report: () => { reportCalled = true; }, options: [] };
81
- const rule: any = effectSignalLoopRule.create(mockContext);
82
- const mockNode: any = {
83
- callee: { type: 'Identifier', name: 'computed' },
84
- arguments: [],
85
- };
86
- rule.CallExpression(mockNode);
87
- expect(reportCalled).toBe(false);
88
- });
89
- });
@@ -1,125 +0,0 @@
1
- import { Rule } from 'eslint';
2
-
3
- /**
4
- * Adott AST node alá tartozó signal olvasások / írások begyűjtése.
5
- * Olvasás: `something_$()` hívás (callee Identifier `*_$` névvel vagy
6
- * MemberExpression `.foo_$()` property-vel).
7
- * Írás: `something_$.set(...)` vagy `something_$.update(...)`.
8
- */
9
- function collectSignals(
10
- rootNode: any,
11
- reads: Set<string>,
12
- writes: Set<string>,
13
- ): void {
14
- if (!rootNode || typeof rootNode !== 'object') {
15
- return;
16
- }
17
-
18
- if (rootNode.type === 'CallExpression') {
19
- const callee: any = rootNode.callee;
20
- // Signal olvasás: `name_$()` direkt hívás (Identifier callee)
21
- if (callee && callee.type === 'Identifier' && /_\$$/.test(callee.name)) {
22
- reads.add(callee.name);
23
- }
24
- // Signal olvasás: `this.name_$()` vagy `obj.name_$()`
25
- if (
26
- callee
27
- && callee.type === 'MemberExpression'
28
- && callee.property
29
- && callee.property.type === 'Identifier'
30
- && /_\$$/.test(callee.property.name)
31
- ) {
32
- reads.add(callee.property.name);
33
- }
34
- // Signal írás: `name_$.set(...)` / `name_$.update(...)`
35
- if (
36
- callee
37
- && callee.type === 'MemberExpression'
38
- && callee.property
39
- && callee.property.type === 'Identifier'
40
- && (callee.property.name === 'set' || callee.property.name === 'update')
41
- ) {
42
- const obj: any = callee.object;
43
- if (obj && obj.type === 'Identifier' && /_\$$/.test(obj.name)) {
44
- writes.add(obj.name);
45
- }
46
- if (
47
- obj
48
- && obj.type === 'MemberExpression'
49
- && obj.property
50
- && obj.property.type === 'Identifier'
51
- && /_\$$/.test(obj.property.name)
52
- ) {
53
- writes.add(obj.property.name);
54
- }
55
- }
56
- }
57
-
58
- for (const key in rootNode) {
59
- if (key === 'parent' || key === 'loc' || key === 'range') {
60
- continue;
61
- }
62
- const value: any = rootNode[key];
63
- if (Array.isArray(value)) {
64
- for (const item of value) {
65
- collectSignals(item, reads, writes);
66
- }
67
- } else if (value && typeof value === 'object' && typeof value.type === 'string') {
68
- collectSignals(value, reads, writes);
69
- }
70
- }
71
- }
72
-
73
- /**
74
- * Effect-signal-loop szabály: detektálja azt az `effect(...)` hívást ami
75
- * ugyanazt a signal-t olvassa (dependency-ként) és írja (`.set` / `.update`).
76
- * Ez végtelen loop-ot okozna, mert a write újra triggereli az effect-et.
77
- * CCAP "effect-signal-loop" review ESLint AST-portja.
78
- */
79
- const rule: Rule.RuleModule = {
80
- meta: {
81
- type: 'problem',
82
- docs: {
83
- description: 'Detect `effect()` callbacks that read and write the same signal — infinite loop risk.',
84
- recommended: true,
85
- },
86
- schema: [],
87
- messages: {
88
- effectSignalLoop:
89
- 'Effect-signal loop: `{{signalName}}` olvasva ÉS írva (.set/.update) ugyanabban az `effect()`-ben. '
90
- + 'Végtelen újrafutás veszélye — a signal-írás újra triggereli az effect-et.',
91
- },
92
- },
93
- create(context: Rule.RuleContext): Rule.RuleListener {
94
- return {
95
- CallExpression(node: any): void {
96
- try {
97
- const callee: any = node.callee;
98
- if (!callee || callee.type !== 'Identifier' || callee.name !== 'effect') {
99
- return;
100
- }
101
- const firstArg: any = node.arguments && node.arguments[0];
102
- if (!firstArg) {
103
- return;
104
- }
105
- const reads: Set<string> = new Set<string>();
106
- const writes: Set<string> = new Set<string>();
107
- collectSignals(firstArg, reads, writes);
108
- for (const signalName of writes) {
109
- if (reads.has(signalName)) {
110
- context.report({
111
- node: node,
112
- messageId: 'effectSignalLoop',
113
- data: { signalName: signalName },
114
- });
115
- }
116
- }
117
- } catch (error) {
118
- console.error('[effect-signal-loop] Error in CallExpression visitor:', error);
119
- }
120
- },
121
- };
122
- },
123
- };
124
-
125
- export default rule;
@@ -1,50 +0,0 @@
1
- import noAsyncNgOnInitRule from './no-async-ngoninit';
2
-
3
- describe('| no-async-ngoninit', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(noAsyncNgOnInitRule.meta?.type).toBe('suggestion');
6
- expect(noAsyncNgOnInitRule.meta?.messages?.noAsyncNgOnInit).toBeDefined();
7
- });
8
-
9
- it('| should report `async ngOnInit`', () => {
10
- let reportCalled: boolean = false;
11
- const mockContext: any = {
12
- report: (options: any): void => {
13
- reportCalled = true;
14
- expect(options.messageId).toBe('noAsyncNgOnInit');
15
- },
16
- options: [],
17
- };
18
- const rule: any = noAsyncNgOnInitRule.create(mockContext);
19
- const mockNode: any = {
20
- key: { type: 'Identifier', name: 'ngOnInit' },
21
- value: { async: true },
22
- };
23
- rule.MethodDefinition(mockNode);
24
- expect(reportCalled).toBe(true);
25
- });
26
-
27
- it('| should not report sync `ngOnInit`', () => {
28
- let reportCalled: boolean = false;
29
- const mockContext: any = { report: () => { reportCalled = true; }, options: [] };
30
- const rule: any = noAsyncNgOnInitRule.create(mockContext);
31
- const mockNode: any = {
32
- key: { type: 'Identifier', name: 'ngOnInit' },
33
- value: { async: false },
34
- };
35
- rule.MethodDefinition(mockNode);
36
- expect(reportCalled).toBe(false);
37
- });
38
-
39
- it('| should not report unrelated async methods', () => {
40
- let reportCalled: boolean = false;
41
- const mockContext: any = { report: () => { reportCalled = true; }, options: [] };
42
- const rule: any = noAsyncNgOnInitRule.create(mockContext);
43
- const mockNode: any = {
44
- key: { type: 'Identifier', name: 'loadData' },
45
- value: { async: true },
46
- };
47
- rule.MethodDefinition(mockNode);
48
- expect(reportCalled).toBe(false);
49
- });
50
- });
@@ -1,43 +0,0 @@
1
- import { Rule } from 'eslint';
2
-
3
- /**
4
- * No-async-ngOnInit szabály: `ngOnInit` metódus nem lehet `async`.
5
- * Angular nem várja le az `async ngOnInit`-et — ez néma hibát okoz.
6
- * CCAP "no-async-ngoninit" review ESLint AST-portja.
7
- */
8
- const rule: Rule.RuleModule = {
9
- meta: {
10
- type: 'suggestion',
11
- docs: {
12
- description: 'Forbid `async ngOnInit` in Angular components — Angular does not await it.',
13
- recommended: true,
14
- },
15
- schema: [],
16
- messages: {
17
- noAsyncNgOnInit:
18
- '`async ngOnInit` tilos — Angular nem várja le. '
19
- + 'Tedd a logikát egy külön `async` privát metódusba és hívd meg `ngOnInit`-ből.',
20
- },
21
- },
22
- create(context: Rule.RuleContext): Rule.RuleListener {
23
- return {
24
- MethodDefinition(node: any): void {
25
- try {
26
- if (!node.key || node.key.type !== 'Identifier' || node.key.name !== 'ngOnInit') {
27
- return;
28
- }
29
- if (node.value && node.value.async === true) {
30
- context.report({
31
- node: node.key,
32
- messageId: 'noAsyncNgOnInit',
33
- });
34
- }
35
- } catch (error) {
36
- console.error('[no-async-ngoninit] Error in MethodDefinition visitor:', error);
37
- }
38
- },
39
- };
40
- },
41
- };
42
-
43
- export default rule;
@@ -1,78 +0,0 @@
1
- import noComponentDirectApiRule from './no-component-direct-api';
2
-
3
- describe('| no-component-direct-api', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(noComponentDirectApiRule.meta?.type).toBe('suggestion');
6
- expect(noComponentDirectApiRule.meta?.messages?.noApiServiceImport).toBeDefined();
7
- expect(noComponentDirectApiRule.meta?.messages?.noHttpClientImport).toBeDefined();
8
- });
9
-
10
- it('| should skip non-component files', () => {
11
- const mockContext: any = { filename: '/x/foo.ts', report: () => {}, options: [] };
12
- const result: any = noComponentDirectApiRule.create(mockContext);
13
- expect(result.ImportDeclaration).toBeUndefined();
14
- });
15
-
16
- it('| should report `*ApiService` import in component', () => {
17
- let reportCalled: boolean = false;
18
- const mockContext: any = {
19
- filename: '/x/user.component.ts',
20
- report: (options: any): void => {
21
- if (options.messageId === 'noApiServiceImport') {
22
- reportCalled = true;
23
- expect(options.data.names).toBe('User_ApiService');
24
- }
25
- },
26
- options: [],
27
- };
28
- const rule: any = noComponentDirectApiRule.create(mockContext);
29
- const mockNode: any = {
30
- source: { value: './user.api-service' },
31
- specifiers: [
32
- { type: 'ImportSpecifier', imported: { name: 'User_ApiService' } },
33
- ],
34
- };
35
- rule.ImportDeclaration(mockNode);
36
- expect(reportCalled).toBe(true);
37
- });
38
-
39
- it('| should report `HttpClient` import in component', () => {
40
- let httpReported: boolean = false;
41
- const mockContext: any = {
42
- filename: '/x/user.component.ts',
43
- report: (options: any): void => {
44
- if (options.messageId === 'noHttpClientImport') {
45
- httpReported = true;
46
- }
47
- },
48
- options: [],
49
- };
50
- const rule: any = noComponentDirectApiRule.create(mockContext);
51
- const mockNode: any = {
52
- source: { value: '@angular/common/http' },
53
- specifiers: [
54
- { type: 'ImportSpecifier', imported: { name: 'HttpClient' } },
55
- ],
56
- };
57
- rule.ImportDeclaration(mockNode);
58
- expect(httpReported).toBe(true);
59
- });
60
-
61
- it('| should not report data-service import in component', () => {
62
- let reportCalled: boolean = false;
63
- const mockContext: any = {
64
- filename: '/x/user.component.ts',
65
- report: () => { reportCalled = true; },
66
- options: [],
67
- };
68
- const rule: any = noComponentDirectApiRule.create(mockContext);
69
- const mockNode: any = {
70
- source: { value: './user.data-service' },
71
- specifiers: [
72
- { type: 'ImportSpecifier', imported: { name: 'User_DataService' } },
73
- ],
74
- };
75
- rule.ImportDeclaration(mockNode);
76
- expect(reportCalled).toBe(false);
77
- });
78
- });
@@ -1,82 +0,0 @@
1
- import { Rule } from 'eslint';
2
-
3
- /** ApiService class név regex – `_ApiService` vagy `ApiService` végződésű class. */
4
- const API_SERVICE_NAME_REGEX: RegExp = /\w+(?:_)?ApiService$/;
5
-
6
- /**
7
- * No-component-direct-api szabály: `*.component.ts` fájlok nem importálhatnak közvetlenül
8
- * `*ApiService` class-okat vagy `HttpClient`-et. Single Source of Truth elv – data-service
9
- * vagy control-service réteg kötelező.
10
- * CCAP "no-component-direct-api" review ESLint AST-portja.
11
- */
12
- const rule: Rule.RuleModule = {
13
- meta: {
14
- type: 'suggestion',
15
- docs: {
16
- description:
17
- 'Components must not directly import `*ApiService` or `HttpClient`; '
18
- + 'use data-service / control-service layer (Single Source of Truth).',
19
- recommended: true,
20
- },
21
- schema: [],
22
- messages: {
23
- noApiServiceImport:
24
- 'Komponens közvetlenül importál ApiService class-t: `{{names}}`. '
25
- + 'Használj data-service-t vagy control-service-t (Single Source of Truth).',
26
- noHttpClientImport:
27
- 'Komponens közvetlenül importálja a `HttpClient`-et. '
28
- + 'Használj api-service / data-service / control-service réteget.',
29
- },
30
- },
31
- create(context: Rule.RuleContext): Rule.RuleListener {
32
- const filename: string = context.filename ?? '';
33
- if (!filename.endsWith('.component.ts')) {
34
- return {};
35
- }
36
-
37
- return {
38
- ImportDeclaration(node: any): void {
39
- try {
40
- const source: string = (node.source && typeof node.source.value === 'string')
41
- ? node.source.value
42
- : '';
43
- const apiServiceNames: string[] = [];
44
- let hasHttpClient: boolean = false;
45
-
46
- for (const specifier of node.specifiers ?? []) {
47
- if (specifier.type !== 'ImportSpecifier') {
48
- continue;
49
- }
50
- const importedName: string = (specifier.imported && specifier.imported.name)
51
- ? specifier.imported.name
52
- : '';
53
- if (importedName === 'HttpClient' && source === '@angular/common/http') {
54
- hasHttpClient = true;
55
- }
56
- if (API_SERVICE_NAME_REGEX.test(importedName)) {
57
- apiServiceNames.push(importedName);
58
- }
59
- }
60
-
61
- if (apiServiceNames.length > 0) {
62
- context.report({
63
- node: node,
64
- messageId: 'noApiServiceImport',
65
- data: { names: apiServiceNames.join(', ') },
66
- });
67
- }
68
- if (hasHttpClient) {
69
- context.report({
70
- node: node,
71
- messageId: 'noHttpClientImport',
72
- });
73
- }
74
- } catch (error) {
75
- console.error('[no-component-direct-api] Error in ImportDeclaration visitor:', error);
76
- }
77
- },
78
- };
79
- },
80
- };
81
-
82
- export default rule;
@@ -1,63 +0,0 @@
1
- import noMethodCallInTemplateRule from './no-method-call-in-template';
2
-
3
- describe('| no-method-call-in-template', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(noMethodCallInTemplateRule.meta?.type).toBe('suggestion');
6
- expect(noMethodCallInTemplateRule.meta?.messages?.interpolationCall).toBeDefined();
7
- expect(noMethodCallInTemplateRule.meta?.messages?.propertyBindingCall).toBeDefined();
8
- expect(noMethodCallInTemplateRule.meta?.messages?.blockCall).toBeDefined();
9
- });
10
-
11
- it('| should skip non-html files', () => {
12
- const mockContext: any = { filename: '/x/foo.ts', report: () => {}, options: [], sourceCode: { text: '' } };
13
- const result: any = noMethodCallInTemplateRule.create(mockContext);
14
- expect(result.Program).toBeUndefined();
15
- });
16
-
17
- it('| should report interpolation method call `{{ getName() }}`', () => {
18
- let reportCount: number = 0;
19
- const mockContext: any = {
20
- filename: '/x/user.component.html',
21
- report: (options: any): void => {
22
- if (options.messageId === 'interpolationCall') {
23
- reportCount += 1;
24
- }
25
- },
26
- options: [],
27
- sourceCode: { text: '<div>{{ getName() }}</div>' },
28
- };
29
- const rule: any = noMethodCallInTemplateRule.create(mockContext);
30
- rule.Program();
31
- expect(reportCount).toBeGreaterThan(0);
32
- });
33
-
34
- it('| should NOT report signal call `{{ name_$() }}`', () => {
35
- let reportCount: number = 0;
36
- const mockContext: any = {
37
- filename: '/x/user.component.html',
38
- report: (): void => { reportCount += 1; },
39
- options: [],
40
- sourceCode: { text: '<div>{{ name_$() }}</div>' },
41
- };
42
- const rule: any = noMethodCallInTemplateRule.create(mockContext);
43
- rule.Program();
44
- expect(reportCount).toBe(0);
45
- });
46
-
47
- it('| should report `@if (isActive())` block call', () => {
48
- let blockReported: boolean = false;
49
- const mockContext: any = {
50
- filename: '/x/user.component.html',
51
- report: (options: any): void => {
52
- if (options.messageId === 'blockCall') {
53
- blockReported = true;
54
- }
55
- },
56
- options: [],
57
- sourceCode: { text: '@if (isActive()) { <span>X</span> }' },
58
- };
59
- const rule: any = noMethodCallInTemplateRule.create(mockContext);
60
- rule.Program();
61
- expect(blockReported).toBe(true);
62
- });
63
- });
@@ -1,89 +0,0 @@
1
- import { Rule } from 'eslint';
2
-
3
- /**
4
- * Interpoláció metódushívás regex: `{{ ... method() ... }}`. Signal hívás (`_$()`) kizárva.
5
- * Capture group 1: a hívott metódus neve.
6
- */
7
- const INTERPOLATION_CALL_REGEX: RegExp =
8
- /\{\{[^}]*\b([a-zA-Z_$][a-zA-Z0-9_$]*(?<!_\$))\s*\([^)]*\)[^}]*\}\}/g;
9
-
10
- /**
11
- * Property binding metódushívás regex: `[attr]="method()"`. Esemény binding `(event)="..."` kizárva.
12
- */
13
- const PROPERTY_BINDING_CALL_REGEX: RegExp =
14
- /\[[^\]]+\]="[^"]*\b[a-zA-Z_$][a-zA-Z0-9_$]*(?<!_\$)\s*\([^)]*\)[^"]*"/g;
15
-
16
- /**
17
- * Angular block (`@if`, `@switch`, `@case`, `@else if`) metódushívás regex.
18
- */
19
- const BLOCK_CALL_REGEX: RegExp =
20
- /@(?:if|switch|case|else if)\s*\([^)]*\b[a-zA-Z_$][a-zA-Z0-9_$]*(?<!_\$)\s*\([^)]*\)/g;
21
-
22
- /**
23
- * Adott offset alapján a sor és oszlop kiszámítása az alap szövegből.
24
- */
25
- function computeLoc(text: string, index: number): { line: number; column: number } {
26
- const before: string = text.substring(0, index);
27
- const newlineMatches: RegExpMatchArray | null = before.match(/\n/g);
28
- const line: number = (newlineMatches ? newlineMatches.length : 0) + 1;
29
- const lastNewline: number = before.lastIndexOf('\n');
30
- const column: number = lastNewline === -1 ? index : index - lastNewline - 1;
31
- return { line: line, column: column };
32
- }
33
-
34
- /**
35
- * No-method-call-in-template szabály: Angular template-ekben tilos metódust hívni
36
- * adat megjelenítéshez. Megengedett: signal `mySignal_$()` és esemény `(click)="handler()"`.
37
- * CCAP "no-method-call-in-template" review ESLint port (template parser source-text scan).
38
- */
39
- const rule: Rule.RuleModule = {
40
- meta: {
41
- type: 'suggestion',
42
- docs: {
43
- description:
44
- 'Forbid method calls in Angular templates for data display; '
45
- + 'use signals / computed / pipes instead. Event bindings `(click)="..."` allowed.',
46
- recommended: true,
47
- },
48
- schema: [],
49
- messages: {
50
- interpolationCall: 'Metódushívás interpolációban: `{{ method() }}`. Használj signal-t vagy pipe-ot.',
51
- propertyBindingCall: 'Metódushívás property bindingban. Használj signal-t vagy computed-t.',
52
- blockCall: 'Metódushívás Angular block direktívában (`@if` / `@switch`). Használj signal-t vagy computed-t.',
53
- },
54
- },
55
- create(context: Rule.RuleContext): Rule.RuleListener {
56
- const filename: string = context.filename ?? '';
57
- if (!filename.endsWith('.html')) {
58
- return {};
59
- }
60
- const text: string = context.sourceCode.text ?? '';
61
-
62
- function reportMatches(regex: RegExp, messageId: string): void {
63
- const localRegex: RegExp = new RegExp(regex.source, 'g');
64
- let match: RegExpExecArray | null = localRegex.exec(text);
65
- while (match !== null) {
66
- const loc: { line: number; column: number } = computeLoc(text, match.index);
67
- context.report({
68
- loc: { start: loc, end: { line: loc.line, column: loc.column + match[0].length } },
69
- messageId: messageId,
70
- });
71
- match = localRegex.exec(text);
72
- }
73
- }
74
-
75
- return {
76
- Program(): void {
77
- try {
78
- reportMatches(INTERPOLATION_CALL_REGEX, 'interpolationCall');
79
- reportMatches(PROPERTY_BINDING_CALL_REGEX, 'propertyBindingCall');
80
- reportMatches(BLOCK_CALL_REGEX, 'blockCall');
81
- } catch (error) {
82
- console.error('[no-method-call-in-template] Error in Program visitor:', error);
83
- }
84
- },
85
- };
86
- },
87
- };
88
-
89
- export default rule;
@@ -1,44 +0,0 @@
1
- import noNgForDirectiveRule from './no-ngfor-directive';
2
-
3
- describe('| no-ngfor-directive', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(noNgForDirectiveRule.meta?.type).toBe('suggestion');
6
- expect(noNgForDirectiveRule.meta?.messages?.noNgFor).toBeDefined();
7
- });
8
-
9
- it('| should skip non-html files', () => {
10
- const mockContext: any = { filename: '/x/foo.ts', report: () => {}, options: [], sourceCode: { text: '' } };
11
- const result: any = noNgForDirectiveRule.create(mockContext);
12
- expect(result.Program).toBeUndefined();
13
- });
14
-
15
- it('| should report `*ngFor`', () => {
16
- let reportCount: number = 0;
17
- const mockContext: any = {
18
- filename: '/x/list.component.html',
19
- report: (options: any): void => {
20
- if (options.messageId === 'noNgFor') {
21
- reportCount += 1;
22
- }
23
- },
24
- options: [],
25
- sourceCode: { text: '<div *ngFor="let item of items">X</div>' },
26
- };
27
- const rule: any = noNgForDirectiveRule.create(mockContext);
28
- rule.Program();
29
- expect(reportCount).toBeGreaterThan(0);
30
- });
31
-
32
- it('| should NOT report `@for` block', () => {
33
- let reportCount: number = 0;
34
- const mockContext: any = {
35
- filename: '/x/list.component.html',
36
- report: (): void => { reportCount += 1; },
37
- options: [],
38
- sourceCode: { text: '@for (item of items; track item.id) { <div>X</div> }' },
39
- };
40
- const rule: any = noNgForDirectiveRule.create(mockContext);
41
- rule.Program();
42
- expect(reportCount).toBe(0);
43
- });
44
- });