cmp-standards 2.0.0
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 +541 -0
- package/dist/analytics/index.d.ts +5 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +5 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/tracker.d.ts +107 -0
- package/dist/analytics/tracker.d.ts.map +1 -0
- package/dist/analytics/tracker.js +333 -0
- package/dist/analytics/tracker.js.map +1 -0
- package/dist/auto-improve/eslint-generator.d.ts +36 -0
- package/dist/auto-improve/eslint-generator.d.ts.map +1 -0
- package/dist/auto-improve/eslint-generator.js +280 -0
- package/dist/auto-improve/eslint-generator.js.map +1 -0
- package/dist/auto-improve/index.d.ts +6 -0
- package/dist/auto-improve/index.d.ts.map +1 -0
- package/dist/auto-improve/index.js +6 -0
- package/dist/auto-improve/index.js.map +1 -0
- package/dist/auto-improve/pattern-detector.d.ts +92 -0
- package/dist/auto-improve/pattern-detector.d.ts.map +1 -0
- package/dist/auto-improve/pattern-detector.js +231 -0
- package/dist/auto-improve/pattern-detector.js.map +1 -0
- package/dist/cli/index.d.ts +18 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +769 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/dashboard/index.d.ts +6 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +6 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/server.d.ts +15 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +373 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/dashboard/ui.d.ts +9 -0
- package/dist/dashboard/ui.d.ts.map +1 -0
- package/dist/dashboard/ui.js +530 -0
- package/dist/dashboard/ui.js.map +1 -0
- package/dist/db/client.d.ts +66 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +159 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/drizzle-client.d.ts +302 -0
- package/dist/db/drizzle-client.d.ts.map +1 -0
- package/dist/db/drizzle-client.js +404 -0
- package/dist/db/drizzle-client.js.map +1 -0
- package/dist/db/index.d.ts +5 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +5 -0
- package/dist/db/index.js.map +1 -0
- package/dist/eslint/config-builder.d.ts +45 -0
- package/dist/eslint/config-builder.d.ts.map +1 -0
- package/dist/eslint/config-builder.js +128 -0
- package/dist/eslint/config-builder.js.map +1 -0
- package/dist/eslint/index.d.ts +161 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +106 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/rules/consistent-error-handling.d.ts +9 -0
- package/dist/eslint/rules/consistent-error-handling.d.ts.map +1 -0
- package/dist/eslint/rules/consistent-error-handling.js +52 -0
- package/dist/eslint/rules/consistent-error-handling.js.map +1 -0
- package/dist/eslint/rules/finance-ledger-sync.d.ts +12 -0
- package/dist/eslint/rules/finance-ledger-sync.d.ts.map +1 -0
- package/dist/eslint/rules/finance-ledger-sync.js +72 -0
- package/dist/eslint/rules/finance-ledger-sync.js.map +1 -0
- package/dist/eslint/rules/no-async-useeffect.d.ts +10 -0
- package/dist/eslint/rules/no-async-useeffect.d.ts.map +1 -0
- package/dist/eslint/rules/no-async-useeffect.js +49 -0
- package/dist/eslint/rules/no-async-useeffect.js.map +1 -0
- package/dist/eslint/rules/no-await-in-loop.d.ts +10 -0
- package/dist/eslint/rules/no-await-in-loop.d.ts.map +1 -0
- package/dist/eslint/rules/no-await-in-loop.js +51 -0
- package/dist/eslint/rules/no-await-in-loop.js.map +1 -0
- package/dist/eslint/rules/no-inline-functions-in-jsx.d.ts +10 -0
- package/dist/eslint/rules/no-inline-functions-in-jsx.d.ts.map +1 -0
- package/dist/eslint/rules/no-inline-functions-in-jsx.js +45 -0
- package/dist/eslint/rules/no-inline-functions-in-jsx.js.map +1 -0
- package/dist/eslint/rules/no-raw-sql.d.ts +19 -0
- package/dist/eslint/rules/no-raw-sql.d.ts.map +1 -0
- package/dist/eslint/rules/no-raw-sql.js +136 -0
- package/dist/eslint/rules/no-raw-sql.js.map +1 -0
- package/dist/eslint/rules/no-sequential-api-calls.d.ts +10 -0
- package/dist/eslint/rules/no-sequential-api-calls.d.ts.map +1 -0
- package/dist/eslint/rules/no-sequential-api-calls.js +72 -0
- package/dist/eslint/rules/no-sequential-api-calls.js.map +1 -0
- package/dist/eslint/rules/prefer-server-components.d.ts +10 -0
- package/dist/eslint/rules/prefer-server-components.d.ts.map +1 -0
- package/dist/eslint/rules/prefer-server-components.js +76 -0
- package/dist/eslint/rules/prefer-server-components.js.map +1 -0
- package/dist/eslint/rules/require-loading-states.d.ts +9 -0
- package/dist/eslint/rules/require-loading-states.d.ts.map +1 -0
- package/dist/eslint/rules/require-loading-states.js +85 -0
- package/dist/eslint/rules/require-loading-states.js.map +1 -0
- package/dist/eslint/rules/require-zod-validation.d.ts +10 -0
- package/dist/eslint/rules/require-zod-validation.d.ts.map +1 -0
- package/dist/eslint/rules/require-zod-validation.js +70 -0
- package/dist/eslint/rules/require-zod-validation.js.map +1 -0
- package/dist/eslint/rules/semantic-tokens-only.d.ts +10 -0
- package/dist/eslint/rules/semantic-tokens-only.d.ts.map +1 -0
- package/dist/eslint/rules/semantic-tokens-only.js +62 -0
- package/dist/eslint/rules/semantic-tokens-only.js.map +1 -0
- package/dist/feedback/collector.d.ts +74 -0
- package/dist/feedback/collector.d.ts.map +1 -0
- package/dist/feedback/collector.js +231 -0
- package/dist/feedback/collector.js.map +1 -0
- package/dist/feedback/index.d.ts +5 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +5 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/memory-checkpoint.d.ts +43 -0
- package/dist/hooks/memory-checkpoint.d.ts.map +1 -0
- package/dist/hooks/memory-checkpoint.js +257 -0
- package/dist/hooks/memory-checkpoint.js.map +1 -0
- package/dist/hooks/post-tool-use.d.ts +61 -0
- package/dist/hooks/post-tool-use.d.ts.map +1 -0
- package/dist/hooks/post-tool-use.js +262 -0
- package/dist/hooks/post-tool-use.js.map +1 -0
- package/dist/hooks/pre-tool-use.d.ts +34 -0
- package/dist/hooks/pre-tool-use.d.ts.map +1 -0
- package/dist/hooks/pre-tool-use.js +358 -0
- package/dist/hooks/pre-tool-use.js.map +1 -0
- package/dist/hooks/session-start.d.ts +38 -0
- package/dist/hooks/session-start.d.ts.map +1 -0
- package/dist/hooks/session-start.js +274 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +42 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +599 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/registry/embeddings.d.ts +38 -0
- package/dist/registry/embeddings.d.ts.map +1 -0
- package/dist/registry/embeddings.js +110 -0
- package/dist/registry/embeddings.js.map +1 -0
- package/dist/registry/generator.d.ts +41 -0
- package/dist/registry/generator.d.ts.map +1 -0
- package/dist/registry/generator.js +323 -0
- package/dist/registry/generator.js.map +1 -0
- package/dist/registry/index.d.ts +6 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/services/IdeaCollector.d.ts +103 -0
- package/dist/services/IdeaCollector.d.ts.map +1 -0
- package/dist/services/IdeaCollector.js +371 -0
- package/dist/services/IdeaCollector.js.map +1 -0
- package/dist/services/ProjectScaffold.d.ts +76 -0
- package/dist/services/ProjectScaffold.d.ts.map +1 -0
- package/dist/services/ProjectScaffold.js +479 -0
- package/dist/services/ProjectScaffold.js.map +1 -0
- package/dist/services/ProjectScanner.d.ts +81 -0
- package/dist/services/ProjectScanner.d.ts.map +1 -0
- package/dist/services/ProjectScanner.js +349 -0
- package/dist/services/ProjectScanner.js.map +1 -0
- package/dist/services/TaskTracker.d.ts +89 -0
- package/dist/services/TaskTracker.d.ts.map +1 -0
- package/dist/services/TaskTracker.js +324 -0
- package/dist/services/TaskTracker.js.map +1 -0
- package/dist/services/WorkPlanManager.d.ts +107 -0
- package/dist/services/WorkPlanManager.d.ts.map +1 -0
- package/dist/services/WorkPlanManager.js +440 -0
- package/dist/services/WorkPlanManager.js.map +1 -0
- package/dist/services/auto-inject.d.ts +77 -0
- package/dist/services/auto-inject.d.ts.map +1 -0
- package/dist/services/auto-inject.js +289 -0
- package/dist/services/auto-inject.js.map +1 -0
- package/dist/services/auto-tag.d.ts +61 -0
- package/dist/services/auto-tag.d.ts.map +1 -0
- package/dist/services/auto-tag.js +203 -0
- package/dist/services/auto-tag.js.map +1 -0
- package/dist/services/cross-project-sync.d.ts +76 -0
- package/dist/services/cross-project-sync.d.ts.map +1 -0
- package/dist/services/cross-project-sync.js +235 -0
- package/dist/services/cross-project-sync.js.map +1 -0
- package/dist/services/index.d.ts +17 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +23 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/memory-consolidation.d.ts +77 -0
- package/dist/services/memory-consolidation.d.ts.map +1 -0
- package/dist/services/memory-consolidation.js +298 -0
- package/dist/services/memory-consolidation.js.map +1 -0
- package/dist/services/semantic-search.d.ts +93 -0
- package/dist/services/semantic-search.d.ts.map +1 -0
- package/dist/services/semantic-search.js +278 -0
- package/dist/services/semantic-search.js.map +1 -0
- package/dist/services/weekly-digest.d.ts +105 -0
- package/dist/services/weekly-digest.d.ts.map +1 -0
- package/dist/services/weekly-digest.js +292 -0
- package/dist/services/weekly-digest.js.map +1 -0
- package/dist/types/index.d.ts +274 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +84 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.d.ts +21 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +89 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/paths.d.ts +28 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +80 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +95 -0
- package/templates/agents/architecture-expert.md +61 -0
- package/templates/agents/database-expert.md +62 -0
- package/templates/agents/documentation-expert.md +57 -0
- package/templates/agents/memory-expert.md +88 -0
- package/templates/agents/performance-expert.md +61 -0
- package/templates/agents/security-expert.md +59 -0
- package/templates/agents/ux-expert.md +63 -0
- package/templates/agents/worker.md +75 -0
- package/templates/ai-skills/SKILL_TEMPLATE.md +55 -0
- package/templates/commands/experts.md +138 -0
- package/templates/hooks/README.md +158 -0
- package/templates/hooks/project.config.json.template +77 -0
- package/templates/hooks/settings.local.json.template +57 -0
- package/templates/memory-config.json +82 -0
- package/templates/memory-config.schema.json +212 -0
- package/templates/settings.json +58 -0
- package/templates/workflows/business-improvement.md +264 -0
- package/templates/workflows/expert-review.md +153 -0
- package/templates/workflows/internal-app.md +245 -0
- package/templates/workflows/sync-docs.md +187 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Plugin: cmp-standards
|
|
3
|
+
*
|
|
4
|
+
* Universal and configurable ESLint rules for MetaNautical projects.
|
|
5
|
+
* Rules are organized into categories:
|
|
6
|
+
*
|
|
7
|
+
* UNIVERSAL - Apply to all projects (security, performance, React best practices)
|
|
8
|
+
* CONFIGURABLE - Adapt based on project.config.json
|
|
9
|
+
* PROJECT-SPECIFIC - Only for projects that explicitly enable them
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/carlosmartinpavon/carlosmartinpavon
|
|
12
|
+
*/
|
|
13
|
+
export declare const rules: {
|
|
14
|
+
'no-raw-sql': import("eslint").Rule.RuleModule;
|
|
15
|
+
'require-zod-validation': import("eslint").Rule.RuleModule;
|
|
16
|
+
'no-await-in-loop': import("eslint").Rule.RuleModule;
|
|
17
|
+
'semantic-tokens-only': import("eslint").Rule.RuleModule;
|
|
18
|
+
'no-async-useeffect': import("eslint").Rule.RuleModule;
|
|
19
|
+
'no-inline-functions-in-jsx': import("eslint").Rule.RuleModule;
|
|
20
|
+
'no-sequential-api-calls': import("eslint").Rule.RuleModule;
|
|
21
|
+
'require-loading-states': import("eslint").Rule.RuleModule;
|
|
22
|
+
'consistent-error-handling': import("eslint").Rule.RuleModule;
|
|
23
|
+
'finance-ledger-sync': import("eslint").Rule.RuleModule;
|
|
24
|
+
'prefer-server-components': import("eslint").Rule.RuleModule;
|
|
25
|
+
};
|
|
26
|
+
export declare const configs: {
|
|
27
|
+
/**
|
|
28
|
+
* Recommended config - universal rules only
|
|
29
|
+
*/
|
|
30
|
+
recommended: {
|
|
31
|
+
plugins: string[];
|
|
32
|
+
rules: {
|
|
33
|
+
'cmp/no-raw-sql': string;
|
|
34
|
+
'cmp/require-zod-validation': string;
|
|
35
|
+
'cmp/no-await-in-loop': string;
|
|
36
|
+
'cmp/no-async-useeffect': string;
|
|
37
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
38
|
+
'cmp/no-sequential-api-calls': string;
|
|
39
|
+
'cmp/require-loading-states': string;
|
|
40
|
+
'cmp/consistent-error-handling': string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Strict config - all universal rules as errors
|
|
45
|
+
*/
|
|
46
|
+
strict: {
|
|
47
|
+
plugins: string[];
|
|
48
|
+
rules: {
|
|
49
|
+
'cmp/no-raw-sql': string;
|
|
50
|
+
'cmp/require-zod-validation': string;
|
|
51
|
+
'cmp/no-await-in-loop': string;
|
|
52
|
+
'cmp/semantic-tokens-only': string;
|
|
53
|
+
'cmp/no-async-useeffect': string;
|
|
54
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
55
|
+
'cmp/no-sequential-api-calls': string;
|
|
56
|
+
'cmp/require-loading-states': string;
|
|
57
|
+
'cmp/consistent-error-handling': string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Next.js config - includes Next.js specific rules
|
|
62
|
+
*/
|
|
63
|
+
nextjs: {
|
|
64
|
+
plugins: string[];
|
|
65
|
+
rules: {
|
|
66
|
+
'cmp/no-raw-sql': string;
|
|
67
|
+
'cmp/require-zod-validation': string;
|
|
68
|
+
'cmp/prefer-server-components': string;
|
|
69
|
+
'cmp/no-async-useeffect': string;
|
|
70
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Finance config - includes finance-specific rules
|
|
75
|
+
*/
|
|
76
|
+
finance: {
|
|
77
|
+
plugins: string[];
|
|
78
|
+
rules: {
|
|
79
|
+
'cmp/no-raw-sql': string;
|
|
80
|
+
'cmp/require-zod-validation': string;
|
|
81
|
+
'cmp/finance-ledger-sync': string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export { buildConfig, generateConfig, toFlatConfig, toLegacyConfig, printConfig, type ESLintConfig, type ConfigOptions, } from './config-builder.js';
|
|
86
|
+
declare const _default: {
|
|
87
|
+
rules: {
|
|
88
|
+
'no-raw-sql': import("eslint").Rule.RuleModule;
|
|
89
|
+
'require-zod-validation': import("eslint").Rule.RuleModule;
|
|
90
|
+
'no-await-in-loop': import("eslint").Rule.RuleModule;
|
|
91
|
+
'semantic-tokens-only': import("eslint").Rule.RuleModule;
|
|
92
|
+
'no-async-useeffect': import("eslint").Rule.RuleModule;
|
|
93
|
+
'no-inline-functions-in-jsx': import("eslint").Rule.RuleModule;
|
|
94
|
+
'no-sequential-api-calls': import("eslint").Rule.RuleModule;
|
|
95
|
+
'require-loading-states': import("eslint").Rule.RuleModule;
|
|
96
|
+
'consistent-error-handling': import("eslint").Rule.RuleModule;
|
|
97
|
+
'finance-ledger-sync': import("eslint").Rule.RuleModule;
|
|
98
|
+
'prefer-server-components': import("eslint").Rule.RuleModule;
|
|
99
|
+
};
|
|
100
|
+
configs: {
|
|
101
|
+
/**
|
|
102
|
+
* Recommended config - universal rules only
|
|
103
|
+
*/
|
|
104
|
+
recommended: {
|
|
105
|
+
plugins: string[];
|
|
106
|
+
rules: {
|
|
107
|
+
'cmp/no-raw-sql': string;
|
|
108
|
+
'cmp/require-zod-validation': string;
|
|
109
|
+
'cmp/no-await-in-loop': string;
|
|
110
|
+
'cmp/no-async-useeffect': string;
|
|
111
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
112
|
+
'cmp/no-sequential-api-calls': string;
|
|
113
|
+
'cmp/require-loading-states': string;
|
|
114
|
+
'cmp/consistent-error-handling': string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Strict config - all universal rules as errors
|
|
119
|
+
*/
|
|
120
|
+
strict: {
|
|
121
|
+
plugins: string[];
|
|
122
|
+
rules: {
|
|
123
|
+
'cmp/no-raw-sql': string;
|
|
124
|
+
'cmp/require-zod-validation': string;
|
|
125
|
+
'cmp/no-await-in-loop': string;
|
|
126
|
+
'cmp/semantic-tokens-only': string;
|
|
127
|
+
'cmp/no-async-useeffect': string;
|
|
128
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
129
|
+
'cmp/no-sequential-api-calls': string;
|
|
130
|
+
'cmp/require-loading-states': string;
|
|
131
|
+
'cmp/consistent-error-handling': string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Next.js config - includes Next.js specific rules
|
|
136
|
+
*/
|
|
137
|
+
nextjs: {
|
|
138
|
+
plugins: string[];
|
|
139
|
+
rules: {
|
|
140
|
+
'cmp/no-raw-sql': string;
|
|
141
|
+
'cmp/require-zod-validation': string;
|
|
142
|
+
'cmp/prefer-server-components': string;
|
|
143
|
+
'cmp/no-async-useeffect': string;
|
|
144
|
+
'cmp/no-inline-functions-in-jsx': string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Finance config - includes finance-specific rules
|
|
149
|
+
*/
|
|
150
|
+
finance: {
|
|
151
|
+
plugins: string[];
|
|
152
|
+
rules: {
|
|
153
|
+
'cmp/no-raw-sql': string;
|
|
154
|
+
'cmp/require-zod-validation': string;
|
|
155
|
+
'cmp/finance-ledger-sync': string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export default _default;
|
|
161
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiBH,eAAO,MAAM,KAAK;;;;;;;;;;;;CAejB,CAAA;AAED,eAAO,MAAM,OAAO;IAClB;;OAEG;;;;;;;;;;;;;;IAeH;;OAEG;;;;;;;;;;;;;;;IAgBH;;OAEG;;;;;;;;;;;IAYH;;OAEG;;;;;;;;;CASJ,CAAA;AAGD,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAA;;;;;;;;;;;;;;;;QAvE1B;;WAEG;;;;;;;;;;;;;;QAeH;;WAEG;;;;;;;;;;;;;;;QAgBH;;WAEG;;;;;;;;;;;QAYH;;WAEG;;;;;;;;;;;AAsBL,wBAGC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Plugin: cmp-standards
|
|
3
|
+
*
|
|
4
|
+
* Universal and configurable ESLint rules for MetaNautical projects.
|
|
5
|
+
* Rules are organized into categories:
|
|
6
|
+
*
|
|
7
|
+
* UNIVERSAL - Apply to all projects (security, performance, React best practices)
|
|
8
|
+
* CONFIGURABLE - Adapt based on project.config.json
|
|
9
|
+
* PROJECT-SPECIFIC - Only for projects that explicitly enable them
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/carlosmartinpavon/carlosmartinpavon
|
|
12
|
+
*/
|
|
13
|
+
// Universal Rules (always apply)
|
|
14
|
+
import noRawSql from './rules/no-raw-sql.js';
|
|
15
|
+
import requireZodValidation from './rules/require-zod-validation.js';
|
|
16
|
+
import noAwaitInLoop from './rules/no-await-in-loop.js';
|
|
17
|
+
import semanticTokensOnly from './rules/semantic-tokens-only.js';
|
|
18
|
+
import noAsyncUseeffect from './rules/no-async-useeffect.js';
|
|
19
|
+
import noInlineFunctionsInJsx from './rules/no-inline-functions-in-jsx.js';
|
|
20
|
+
import noSequentialApiCalls from './rules/no-sequential-api-calls.js';
|
|
21
|
+
import requireLoadingStates from './rules/require-loading-states.js';
|
|
22
|
+
import consistentErrorHandling from './rules/consistent-error-handling.js';
|
|
23
|
+
// Configurable Rules (read from project config)
|
|
24
|
+
import financeLedgerSync from './rules/finance-ledger-sync.js';
|
|
25
|
+
import preferServerComponents from './rules/prefer-server-components.js';
|
|
26
|
+
export const rules = {
|
|
27
|
+
// Universal
|
|
28
|
+
'no-raw-sql': noRawSql,
|
|
29
|
+
'require-zod-validation': requireZodValidation,
|
|
30
|
+
'no-await-in-loop': noAwaitInLoop,
|
|
31
|
+
'semantic-tokens-only': semanticTokensOnly,
|
|
32
|
+
'no-async-useeffect': noAsyncUseeffect,
|
|
33
|
+
'no-inline-functions-in-jsx': noInlineFunctionsInJsx,
|
|
34
|
+
'no-sequential-api-calls': noSequentialApiCalls,
|
|
35
|
+
'require-loading-states': requireLoadingStates,
|
|
36
|
+
'consistent-error-handling': consistentErrorHandling,
|
|
37
|
+
// Configurable
|
|
38
|
+
'finance-ledger-sync': financeLedgerSync,
|
|
39
|
+
'prefer-server-components': preferServerComponents,
|
|
40
|
+
};
|
|
41
|
+
export const configs = {
|
|
42
|
+
/**
|
|
43
|
+
* Recommended config - universal rules only
|
|
44
|
+
*/
|
|
45
|
+
recommended: {
|
|
46
|
+
plugins: ['cmp'],
|
|
47
|
+
rules: {
|
|
48
|
+
'cmp/no-raw-sql': 'error',
|
|
49
|
+
'cmp/require-zod-validation': 'warn',
|
|
50
|
+
'cmp/no-await-in-loop': 'warn',
|
|
51
|
+
'cmp/no-async-useeffect': 'error',
|
|
52
|
+
'cmp/no-inline-functions-in-jsx': 'warn',
|
|
53
|
+
'cmp/no-sequential-api-calls': 'warn',
|
|
54
|
+
'cmp/require-loading-states': 'warn',
|
|
55
|
+
'cmp/consistent-error-handling': 'warn',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Strict config - all universal rules as errors
|
|
60
|
+
*/
|
|
61
|
+
strict: {
|
|
62
|
+
plugins: ['cmp'],
|
|
63
|
+
rules: {
|
|
64
|
+
'cmp/no-raw-sql': 'error',
|
|
65
|
+
'cmp/require-zod-validation': 'error',
|
|
66
|
+
'cmp/no-await-in-loop': 'error',
|
|
67
|
+
'cmp/semantic-tokens-only': 'error',
|
|
68
|
+
'cmp/no-async-useeffect': 'error',
|
|
69
|
+
'cmp/no-inline-functions-in-jsx': 'error',
|
|
70
|
+
'cmp/no-sequential-api-calls': 'error',
|
|
71
|
+
'cmp/require-loading-states': 'error',
|
|
72
|
+
'cmp/consistent-error-handling': 'error',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Next.js config - includes Next.js specific rules
|
|
77
|
+
*/
|
|
78
|
+
nextjs: {
|
|
79
|
+
plugins: ['cmp'],
|
|
80
|
+
rules: {
|
|
81
|
+
'cmp/no-raw-sql': 'error',
|
|
82
|
+
'cmp/require-zod-validation': 'warn',
|
|
83
|
+
'cmp/prefer-server-components': 'warn',
|
|
84
|
+
'cmp/no-async-useeffect': 'error',
|
|
85
|
+
'cmp/no-inline-functions-in-jsx': 'warn',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Finance config - includes finance-specific rules
|
|
90
|
+
*/
|
|
91
|
+
finance: {
|
|
92
|
+
plugins: ['cmp'],
|
|
93
|
+
rules: {
|
|
94
|
+
'cmp/no-raw-sql': 'error',
|
|
95
|
+
'cmp/require-zod-validation': 'error',
|
|
96
|
+
'cmp/finance-ledger-sync': 'error',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
// Config Builder
|
|
101
|
+
export { buildConfig, generateConfig, toFlatConfig, toLegacyConfig, printConfig, } from './config-builder.js';
|
|
102
|
+
export default {
|
|
103
|
+
rules,
|
|
104
|
+
configs,
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iCAAiC;AACjC,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,oBAAoB,MAAM,mCAAmC,CAAA;AACpE,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,kBAAkB,MAAM,iCAAiC,CAAA;AAChE,OAAO,gBAAgB,MAAM,+BAA+B,CAAA;AAC5D,OAAO,sBAAsB,MAAM,uCAAuC,CAAA;AAC1E,OAAO,oBAAoB,MAAM,oCAAoC,CAAA;AACrE,OAAO,oBAAoB,MAAM,mCAAmC,CAAA;AACpE,OAAO,uBAAuB,MAAM,sCAAsC,CAAA;AAE1E,gDAAgD;AAChD,OAAO,iBAAiB,MAAM,gCAAgC,CAAA;AAC9D,OAAO,sBAAsB,MAAM,qCAAqC,CAAA;AAExE,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,YAAY;IACZ,YAAY,EAAE,QAAQ;IACtB,wBAAwB,EAAE,oBAAoB;IAC9C,kBAAkB,EAAE,aAAa;IACjC,sBAAsB,EAAE,kBAAkB;IAC1C,oBAAoB,EAAE,gBAAgB;IACtC,4BAA4B,EAAE,sBAAsB;IACpD,yBAAyB,EAAE,oBAAoB;IAC/C,wBAAwB,EAAE,oBAAoB;IAC9C,2BAA2B,EAAE,uBAAuB;IAEpD,eAAe;IACf,qBAAqB,EAAE,iBAAiB;IACxC,0BAA0B,EAAE,sBAAsB;CACnD,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;OAEG;IACH,WAAW,EAAE;QACX,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,KAAK,EAAE;YACL,gBAAgB,EAAE,OAAO;YACzB,4BAA4B,EAAE,MAAM;YACpC,sBAAsB,EAAE,MAAM;YAC9B,wBAAwB,EAAE,OAAO;YACjC,gCAAgC,EAAE,MAAM;YACxC,6BAA6B,EAAE,MAAM;YACrC,4BAA4B,EAAE,MAAM;YACpC,+BAA+B,EAAE,MAAM;SACxC;KACF;IAED;;OAEG;IACH,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,KAAK,EAAE;YACL,gBAAgB,EAAE,OAAO;YACzB,4BAA4B,EAAE,OAAO;YACrC,sBAAsB,EAAE,OAAO;YAC/B,0BAA0B,EAAE,OAAO;YACnC,wBAAwB,EAAE,OAAO;YACjC,gCAAgC,EAAE,OAAO;YACzC,6BAA6B,EAAE,OAAO;YACtC,4BAA4B,EAAE,OAAO;YACrC,+BAA+B,EAAE,OAAO;SACzC;KACF;IAED;;OAEG;IACH,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,KAAK,EAAE;YACL,gBAAgB,EAAE,OAAO;YACzB,4BAA4B,EAAE,MAAM;YACpC,8BAA8B,EAAE,MAAM;YACtC,wBAAwB,EAAE,OAAO;YACjC,gCAAgC,EAAE,MAAM;SACzC;KACF;IAED;;OAEG;IACH,OAAO,EAAE;QACP,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,KAAK,EAAE;YACL,gBAAgB,EAAE,OAAO;YACzB,4BAA4B,EAAE,OAAO;YACrC,yBAAyB,EAAE,OAAO;SACnC;KACF;CACF,CAAA;AAED,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,GAGZ,MAAM,qBAAqB,CAAA;AAE5B,eAAe;IACb,KAAK;IACL,OAAO;CACR,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/consistent-error-handling
|
|
3
|
+
*
|
|
4
|
+
* Ensures consistent error handling patterns across the codebase.
|
|
5
|
+
*/
|
|
6
|
+
import type { Rule } from 'eslint';
|
|
7
|
+
declare const rule: Rule.RuleModule;
|
|
8
|
+
export default rule;
|
|
9
|
+
//# sourceMappingURL=consistent-error-handling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistent-error-handling.d.ts","sourceRoot":"","sources":["../../../src/eslint/rules/consistent-error-handling.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAmDhB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/consistent-error-handling
|
|
3
|
+
*
|
|
4
|
+
* Ensures consistent error handling patterns across the codebase.
|
|
5
|
+
*/
|
|
6
|
+
const rule = {
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Enforce consistent error handling patterns',
|
|
11
|
+
category: 'Best Practices',
|
|
12
|
+
recommended: true,
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
emptyCatch: 'Empty catch block. Handle the error or re-throw it.',
|
|
16
|
+
consoleCatch: 'Use proper error handling instead of console.log in catch block.',
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
return {
|
|
22
|
+
CatchClause(node) {
|
|
23
|
+
const body = node.body;
|
|
24
|
+
// Empty catch block
|
|
25
|
+
if (body.body.length === 0) {
|
|
26
|
+
context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: 'emptyCatch',
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Only console.log/error in catch
|
|
33
|
+
if (body.body.length === 1) {
|
|
34
|
+
const statement = body.body[0];
|
|
35
|
+
if (statement.type === 'ExpressionStatement' &&
|
|
36
|
+
statement.expression.type === 'CallExpression') {
|
|
37
|
+
const callee = statement.expression.callee;
|
|
38
|
+
if (callee.type === 'MemberExpression' &&
|
|
39
|
+
callee.object?.name === 'console') {
|
|
40
|
+
context.report({
|
|
41
|
+
node,
|
|
42
|
+
messageId: 'consoleCatch',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export default rule;
|
|
52
|
+
//# sourceMappingURL=consistent-error-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistent-error-handling.js","sourceRoot":"","sources":["../../../src/eslint/rules/consistent-error-handling.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE;YACR,UAAU,EAAE,qDAAqD;YACjE,YAAY,EAAE,kEAAkE;SACjF;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,WAAW,CAAC,IAAS;gBACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;gBAEtB,oBAAoB;gBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC3B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,YAAY;qBACxB,CAAC,CAAA;oBACF,OAAM;gBACR,CAAC;gBAED,kCAAkC;gBAClC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAC9B,IACE,SAAS,CAAC,IAAI,KAAK,qBAAqB;wBACxC,SAAS,CAAC,UAAU,CAAC,IAAI,KAAK,gBAAgB,EAC9C,CAAC;wBACD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAA;wBAC1C,IACE,MAAM,CAAC,IAAI,KAAK,kBAAkB;4BAClC,MAAM,CAAC,MAAM,EAAE,IAAI,KAAK,SAAS,EACjC,CAAC;4BACD,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI;gCACJ,SAAS,EAAE,cAAc;6BAC1B,CAAC,CAAA;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/finance-ledger-sync
|
|
3
|
+
*
|
|
4
|
+
* CRITICAL: Ensures finance operations call LedgerService.createEntry()
|
|
5
|
+
* This rule is configurable - only activates for projects with finance code.
|
|
6
|
+
*
|
|
7
|
+
* Every finance insert MUST have a corresponding ledger entry or cash flow breaks.
|
|
8
|
+
*/
|
|
9
|
+
import type { Rule } from 'eslint';
|
|
10
|
+
declare const rule: Rule.RuleModule;
|
|
11
|
+
export default rule;
|
|
12
|
+
//# sourceMappingURL=finance-ledger-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance-ledger-sync.d.ts","sourceRoot":"","sources":["../../../src/eslint/rules/finance-ledger-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAUlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA8DhB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/finance-ledger-sync
|
|
3
|
+
*
|
|
4
|
+
* CRITICAL: Ensures finance operations call LedgerService.createEntry()
|
|
5
|
+
* This rule is configurable - only activates for projects with finance code.
|
|
6
|
+
*
|
|
7
|
+
* Every finance insert MUST have a corresponding ledger entry or cash flow breaks.
|
|
8
|
+
*/
|
|
9
|
+
const FINANCE_TABLES = [
|
|
10
|
+
'finance',
|
|
11
|
+
'expenses',
|
|
12
|
+
'payments',
|
|
13
|
+
'invoices',
|
|
14
|
+
'transactions',
|
|
15
|
+
];
|
|
16
|
+
const rule = {
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Ensure finance operations sync with LedgerService',
|
|
21
|
+
category: 'Finance',
|
|
22
|
+
recommended: false, // Only for projects with finance
|
|
23
|
+
},
|
|
24
|
+
messages: {
|
|
25
|
+
missingLedgerSync: 'Finance insert detected but no LedgerService.createEntry() call. Cash flow will be out of sync!',
|
|
26
|
+
},
|
|
27
|
+
schema: [],
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
let hasFinanceInsert = false;
|
|
31
|
+
let hasLedgerCall = false;
|
|
32
|
+
let financeInsertNode = null;
|
|
33
|
+
return {
|
|
34
|
+
'Program:exit'() {
|
|
35
|
+
if (hasFinanceInsert && !hasLedgerCall && financeInsertNode) {
|
|
36
|
+
context.report({
|
|
37
|
+
node: financeInsertNode,
|
|
38
|
+
messageId: 'missingLedgerSync',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
hasFinanceInsert = false;
|
|
42
|
+
hasLedgerCall = false;
|
|
43
|
+
financeInsertNode = null;
|
|
44
|
+
},
|
|
45
|
+
CallExpression(node) {
|
|
46
|
+
const callee = node.callee;
|
|
47
|
+
// Check for insert into finance tables
|
|
48
|
+
if (callee.type === 'MemberExpression') {
|
|
49
|
+
const methodName = callee.property?.name;
|
|
50
|
+
// db.insert(financeTable)
|
|
51
|
+
if (methodName === 'insert') {
|
|
52
|
+
const arg = node.arguments[0];
|
|
53
|
+
if (arg?.type === 'Identifier') {
|
|
54
|
+
const tableName = arg.name.toLowerCase();
|
|
55
|
+
if (FINANCE_TABLES.some(ft => tableName.includes(ft))) {
|
|
56
|
+
hasFinanceInsert = true;
|
|
57
|
+
financeInsertNode = node;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// LedgerService.createEntry()
|
|
62
|
+
if (callee.object?.name === 'LedgerService' &&
|
|
63
|
+
methodName === 'createEntry') {
|
|
64
|
+
hasLedgerCall = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
export default rule;
|
|
72
|
+
//# sourceMappingURL=finance-ledger-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance-ledger-sync.js","sourceRoot":"","sources":["../../../src/eslint/rules/finance-ledger-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,cAAc;CACf,CAAA;AAED,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,SAAS;YACnB,WAAW,EAAE,KAAK,EAAE,iCAAiC;SACtD;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,iGAAiG;SACrH;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,IAAI,gBAAgB,GAAG,KAAK,CAAA;QAC5B,IAAI,aAAa,GAAG,KAAK,CAAA;QACzB,IAAI,iBAAiB,GAAQ,IAAI,CAAA;QAEjC,OAAO;YACL,cAAc;gBACZ,IAAI,gBAAgB,IAAI,CAAC,aAAa,IAAI,iBAAiB,EAAE,CAAC;oBAC5D,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,iBAAiB;wBACvB,SAAS,EAAE,mBAAmB;qBAC/B,CAAC,CAAA;gBACJ,CAAC;gBACD,gBAAgB,GAAG,KAAK,CAAA;gBACxB,aAAa,GAAG,KAAK,CAAA;gBACrB,iBAAiB,GAAG,IAAI,CAAA;YAC1B,CAAC;YAED,cAAc,CAAC,IAAS;gBACtB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;gBAE1B,uCAAuC;gBACvC,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBACvC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAA;oBAExC,0BAA0B;oBAC1B,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;wBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;wBAC7B,IAAI,GAAG,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;4BAC/B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;4BACxC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gCACtD,gBAAgB,GAAG,IAAI,CAAA;gCACvB,iBAAiB,GAAG,IAAI,CAAA;4BAC1B,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,8BAA8B;oBAC9B,IACE,MAAM,CAAC,MAAM,EAAE,IAAI,KAAK,eAAe;wBACvC,UAAU,KAAK,aAAa,EAC5B,CAAC;wBACD,aAAa,GAAG,IAAI,CAAA;oBACtB,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-async-useeffect
|
|
3
|
+
*
|
|
4
|
+
* Prevents async functions directly in useEffect.
|
|
5
|
+
* Create an inner async function instead.
|
|
6
|
+
*/
|
|
7
|
+
import type { Rule } from 'eslint';
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
10
|
+
//# sourceMappingURL=no-async-useeffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-async-useeffect.d.ts","sourceRoot":"","sources":["../../../src/eslint/rules/no-async-useeffect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA8ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-async-useeffect
|
|
3
|
+
*
|
|
4
|
+
* Prevents async functions directly in useEffect.
|
|
5
|
+
* Create an inner async function instead.
|
|
6
|
+
*/
|
|
7
|
+
const rule = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Prevent async useEffect callbacks',
|
|
12
|
+
category: 'Best Practices',
|
|
13
|
+
recommended: true,
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
noAsyncUseEffect: 'useEffect callback cannot be async. Create an inner async function and call it.',
|
|
17
|
+
suggestion: `
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const fetchData = async () => {
|
|
20
|
+
// your async code
|
|
21
|
+
};
|
|
22
|
+
fetchData();
|
|
23
|
+
}, []);`,
|
|
24
|
+
},
|
|
25
|
+
schema: [],
|
|
26
|
+
},
|
|
27
|
+
create(context) {
|
|
28
|
+
return {
|
|
29
|
+
CallExpression(node) {
|
|
30
|
+
if (node.callee.type === 'Identifier' &&
|
|
31
|
+
node.callee.name === 'useEffect' &&
|
|
32
|
+
node.arguments[0]) {
|
|
33
|
+
const callback = node.arguments[0];
|
|
34
|
+
// Check for async arrow function or async function expression
|
|
35
|
+
if ((callback.type === 'ArrowFunctionExpression' ||
|
|
36
|
+
callback.type === 'FunctionExpression') &&
|
|
37
|
+
callback.async) {
|
|
38
|
+
context.report({
|
|
39
|
+
node: callback,
|
|
40
|
+
messageId: 'noAsyncUseEffect',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export default rule;
|
|
49
|
+
//# sourceMappingURL=no-async-useeffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-async-useeffect.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-async-useeffect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE;YACR,gBAAgB,EAAE,iFAAiF;YACnG,UAAU,EAAE;;;;;;QAMV;SACH;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAAS;gBACtB,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;oBACjC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW;oBAChC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EACjB,CAAC;oBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;oBAElC,8DAA8D;oBAC9D,IACE,CAAC,QAAQ,CAAC,IAAI,KAAK,yBAAyB;wBAC3C,QAAQ,CAAC,IAAI,KAAK,oBAAoB,CAAC;wBACxC,QAAQ,CAAC,KAAK,EACd,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,QAAQ;4BACd,SAAS,EAAE,kBAAkB;yBAC9B,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-await-in-loop
|
|
3
|
+
*
|
|
4
|
+
* Prevents await inside loops which causes sequential execution.
|
|
5
|
+
* Use Promise.all() for parallel execution instead.
|
|
6
|
+
*/
|
|
7
|
+
import type { Rule } from 'eslint';
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
10
|
+
//# sourceMappingURL=no-await-in-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-await-in-loop.d.ts","sourceRoot":"","sources":["../../../src/eslint/rules/no-await-in-loop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA+ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-await-in-loop
|
|
3
|
+
*
|
|
4
|
+
* Prevents await inside loops which causes sequential execution.
|
|
5
|
+
* Use Promise.all() for parallel execution instead.
|
|
6
|
+
*/
|
|
7
|
+
const rule = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Prevent await inside loops (use Promise.all instead)',
|
|
12
|
+
category: 'Performance',
|
|
13
|
+
recommended: true,
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
awaitInLoop: 'Avoid await inside loops. Use Promise.all() for parallel execution.',
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
let loopDepth = 0;
|
|
22
|
+
function enterLoop() {
|
|
23
|
+
loopDepth++;
|
|
24
|
+
}
|
|
25
|
+
function exitLoop() {
|
|
26
|
+
loopDepth--;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
ForStatement: enterLoop,
|
|
30
|
+
'ForStatement:exit': exitLoop,
|
|
31
|
+
ForInStatement: enterLoop,
|
|
32
|
+
'ForInStatement:exit': exitLoop,
|
|
33
|
+
ForOfStatement: enterLoop,
|
|
34
|
+
'ForOfStatement:exit': exitLoop,
|
|
35
|
+
WhileStatement: enterLoop,
|
|
36
|
+
'WhileStatement:exit': exitLoop,
|
|
37
|
+
DoWhileStatement: enterLoop,
|
|
38
|
+
'DoWhileStatement:exit': exitLoop,
|
|
39
|
+
AwaitExpression(node) {
|
|
40
|
+
if (loopDepth > 0) {
|
|
41
|
+
context.report({
|
|
42
|
+
node,
|
|
43
|
+
messageId: 'awaitInLoop',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export default rule;
|
|
51
|
+
//# sourceMappingURL=no-await-in-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-await-in-loop.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-await-in-loop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,sDAAsD;YACnE,QAAQ,EAAE,aAAa;YACvB,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qEAAqE;SACnF;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,IAAI,SAAS,GAAG,CAAC,CAAA;QAEjB,SAAS,SAAS;YAChB,SAAS,EAAE,CAAA;QACb,CAAC;QAED,SAAS,QAAQ;YACf,SAAS,EAAE,CAAA;QACb,CAAC;QAED,OAAO;YACL,YAAY,EAAE,SAAS;YACvB,mBAAmB,EAAE,QAAQ;YAC7B,cAAc,EAAE,SAAS;YACzB,qBAAqB,EAAE,QAAQ;YAC/B,cAAc,EAAE,SAAS;YACzB,qBAAqB,EAAE,QAAQ;YAC/B,cAAc,EAAE,SAAS;YACzB,qBAAqB,EAAE,QAAQ;YAC/B,gBAAgB,EAAE,SAAS;YAC3B,uBAAuB,EAAE,QAAQ;YAEjC,eAAe,CAAC,IAAI;gBAClB,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;oBAClB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,aAAa;qBACzB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-inline-functions-in-jsx
|
|
3
|
+
*
|
|
4
|
+
* Prevents inline function definitions in JSX props.
|
|
5
|
+
* These cause unnecessary re-renders.
|
|
6
|
+
*/
|
|
7
|
+
import type { Rule } from 'eslint';
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
10
|
+
//# sourceMappingURL=no-inline-functions-in-jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-inline-functions-in-jsx.d.ts","sourceRoot":"","sources":["../../../src/eslint/rules/no-inline-functions-in-jsx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA2ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Rule: cmp/no-inline-functions-in-jsx
|
|
3
|
+
*
|
|
4
|
+
* Prevents inline function definitions in JSX props.
|
|
5
|
+
* These cause unnecessary re-renders.
|
|
6
|
+
*/
|
|
7
|
+
const rule = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Prevent inline functions in JSX props (causes re-renders)',
|
|
12
|
+
category: 'Performance',
|
|
13
|
+
recommended: true,
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
noInlineFunction: 'Avoid inline functions in JSX. Extract to a const or use useCallback.',
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
return {
|
|
22
|
+
JSXAttribute(node) {
|
|
23
|
+
const value = node.value;
|
|
24
|
+
if (!value || value.type !== 'JSXExpressionContainer')
|
|
25
|
+
return;
|
|
26
|
+
const expression = value.expression;
|
|
27
|
+
// Arrow functions or function expressions
|
|
28
|
+
if (expression.type === 'ArrowFunctionExpression' ||
|
|
29
|
+
expression.type === 'FunctionExpression') {
|
|
30
|
+
// Allow simple one-liners for event handlers
|
|
31
|
+
const isSimple = expression.body.type !== 'BlockStatement' ||
|
|
32
|
+
expression.body.body.length <= 1;
|
|
33
|
+
if (!isSimple) {
|
|
34
|
+
context.report({
|
|
35
|
+
node: expression,
|
|
36
|
+
messageId: 'noInlineFunction',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export default rule;
|
|
45
|
+
//# sourceMappingURL=no-inline-functions-in-jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-inline-functions-in-jsx.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-inline-functions-in-jsx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,2DAA2D;YACxE,QAAQ,EAAE,aAAa;YACvB,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE;YACR,gBAAgB,EAAE,uEAAuE;SAC1F;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,YAAY,CAAC,IAAS;gBACpB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;gBAExB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB;oBAAE,OAAM;gBAE7D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAA;gBAEnC,0CAA0C;gBAC1C,IACE,UAAU,CAAC,IAAI,KAAK,yBAAyB;oBAC7C,UAAU,CAAC,IAAI,KAAK,oBAAoB,EACxC,CAAC;oBACD,6CAA6C;oBAC7C,MAAM,QAAQ,GACZ,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB;wBACzC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;oBAElC,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,UAAU;4BAChB,SAAS,EAAE,kBAAkB;yBAC9B,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,IAAI,CAAA"}
|