@soulbatical/tetra-dev-toolkit 1.7.0 → 1.8.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.
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Code Quality Check: Naming Conventions (DB + Code)
3
+ *
4
+ * Wraps the health check naming-conventions as a tetra-audit check.
5
+ * Enforces snake_case in DB, camelCase/PascalCase in code, lowercase dirs.
6
+ *
7
+ * DB violations: table/column naming, PK/FK conventions, bool prefixes, JSON suffixes
8
+ * Code violations: variable/type naming, file naming, directory casing
9
+ *
10
+ * Severity: high — inconsistent naming creates confusion and bugs
11
+ */
12
+
13
+ import { check as healthCheck } from '../health/naming-conventions.js'
14
+
15
+ export const meta = {
16
+ id: 'naming-conventions',
17
+ name: 'Naming Conventions',
18
+ category: 'codeQuality',
19
+ severity: 'high',
20
+ description: 'Enforces snake_case in DB schema, camelCase/PascalCase in TypeScript, lowercase directories'
21
+ }
22
+
23
+ export async function run(config, projectRoot) {
24
+ const result = {
25
+ passed: true,
26
+ findings: [],
27
+ summary: { total: 0, critical: 0, high: 0, medium: 0, low: 0 },
28
+ details: {}
29
+ }
30
+
31
+ const health = await healthCheck(projectRoot)
32
+ result.details = health.details
33
+
34
+ const dbViolations = health.details.database?.violations || []
35
+ const codeViolations = health.details.code?.violations || []
36
+ const dbCompliance = health.details.database?.compliancePercent ?? 100
37
+ const codeCompliance = health.details.code?.compliancePercent ?? 100
38
+
39
+ // DB naming violations
40
+ if (dbViolations.length > 0) {
41
+ // Separate critical (PK/FK structural) from high (naming style)
42
+ const structural = dbViolations.filter(v =>
43
+ v.includes('should be named "id"') ||
44
+ v.includes('should use _id suffix') ||
45
+ v.includes('should be "deleted_at"') ||
46
+ v.includes('missing created_at') ||
47
+ v.includes('missing updated_at') ||
48
+ v.includes('Inconsistent') ||
49
+ v.includes('Non-standard')
50
+ )
51
+ const style = dbViolations.filter(v => !structural.includes(v))
52
+
53
+ if (structural.length > 0) {
54
+ result.findings.push({
55
+ type: 'DB structural naming violations',
56
+ severity: 'critical',
57
+ message: `${structural.length} structural naming issue(s) in DB schema (PK/FK/timestamps/consistency)`,
58
+ files: structural.slice(0, 20)
59
+ })
60
+ result.summary.critical++
61
+ result.summary.total++
62
+ }
63
+
64
+ if (style.length > 0) {
65
+ result.findings.push({
66
+ type: 'DB naming style violations',
67
+ severity: 'high',
68
+ message: `${style.length} naming style issue(s) in DB schema (snake_case, bool prefix, JSON suffix)`,
69
+ files: style.slice(0, 20)
70
+ })
71
+ result.summary.high++
72
+ result.summary.total++
73
+ }
74
+ }
75
+
76
+ // Code naming violations
77
+ if (codeViolations.length > 0) {
78
+ const dirViolations = codeViolations.filter(v => v.includes('should be lowercase'))
79
+ const fileViolations = codeViolations.filter(v => v.includes('naming issue'))
80
+ const varViolations = codeViolations.filter(v =>
81
+ v.includes('should be camelCase') ||
82
+ v.includes('should be PascalCase') ||
83
+ v.includes('should not use I-prefix')
84
+ )
85
+
86
+ if (dirViolations.length > 0) {
87
+ result.findings.push({
88
+ type: 'Directory naming violations',
89
+ severity: 'high',
90
+ message: `${dirViolations.length} director(ies) not lowercase`,
91
+ files: dirViolations.slice(0, 10)
92
+ })
93
+ result.summary.high++
94
+ result.summary.total++
95
+ }
96
+
97
+ if (fileViolations.length > 0) {
98
+ result.findings.push({
99
+ type: 'File naming violations',
100
+ severity: 'medium',
101
+ message: `${fileViolations.length} file(s) with naming issues`,
102
+ files: fileViolations.slice(0, 10)
103
+ })
104
+ result.summary.medium++
105
+ result.summary.total++
106
+ }
107
+
108
+ if (varViolations.length > 0) {
109
+ result.findings.push({
110
+ type: 'Variable/type naming violations',
111
+ severity: 'medium',
112
+ message: `${varViolations.length} variable(s) or type(s) with naming issues`,
113
+ files: varViolations.slice(0, 10)
114
+ })
115
+ result.summary.medium++
116
+ result.summary.total++
117
+ }
118
+ }
119
+
120
+ // Overall compliance summary
121
+ result.details.dbCompliance = dbCompliance
122
+ result.details.codeCompliance = codeCompliance
123
+
124
+ // Fail if DB compliance < 80% or code compliance < 70%, or any critical findings
125
+ result.passed = result.summary.critical === 0 &&
126
+ dbCompliance >= 80 &&
127
+ codeCompliance >= 70
128
+
129
+ return result
130
+ }
package/lib/runner.js CHANGED
@@ -16,6 +16,7 @@ import * as ciPipeline from './checks/stability/ci-pipeline.js'
16
16
  import * as npmAudit from './checks/stability/npm-audit.js'
17
17
  import * as apiResponseFormat from './checks/codeQuality/api-response-format.js'
18
18
  import * as fileSize from './checks/codeQuality/file-size.js'
19
+ import * as namingConventions from './checks/codeQuality/naming-conventions.js'
19
20
  import * as gitignoreValidation from './checks/security/gitignore-validation.js'
20
21
  import * as rlsPolicyAudit from './checks/supabase/rls-policy-audit.js'
21
22
  import * as rpcParamMismatch from './checks/supabase/rpc-param-mismatch.js'
@@ -38,7 +39,8 @@ const ALL_CHECKS = {
38
39
  ],
39
40
  codeQuality: [
40
41
  apiResponseFormat,
41
- fileSize
42
+ fileSize,
43
+ namingConventions
42
44
  ],
43
45
  supabase: [
44
46
  rlsPolicyAudit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulbatical/tetra-dev-toolkit",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "publishConfig": {
5
5
  "access": "restricted"
6
6
  },