Index
node
Node/Svelte/React rule implementations (the shared node base layer).
These rules port the intent of the Python rules to the Node ecosystem
(ESLint, tsc, prettier, vitest, npm audit, knip, madge, jscpd, gitleaks …)
without changing axm-audit's scoring, categories, or CheckResult contract.
They register under the node framework via
@register_rule(category, framework=NODE); UI frameworks (svelte, react)
inherit them via resolve_frameworks.
Importing this package fires the @register_rule decorators (side effect).
NodeCircularImportRule
Bases: NodeToolRule
Score circular-import cycles found by madge --circular --json.
Mirrors the Python CircularImportRule: 100 - cycles * 20.
madge --circular --json returns a JSON array of cycles (each a list of
files); an empty array means no cycles.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/architecture.py
args
property
Report circular dependencies as JSON over the source tree.
rule_id
property
Unique identifier (shared with the Python circular-import rule).
score_output(parsed, project_path)
Score by the number of import cycles.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/architecture.py
NodeComplexityRule
Bases: NodeToolRule
Score cyclomatic + cognitive complexity findings from ESLint.
Scoring: 100 - violations * 10, min 0 — identical to the Python rule.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/complexity.py
args
property
Run ESLint over the project with the JSON formatter.
rule_id
property
Unique identifier (shared with the Python complexity rule).
score_output(parsed, project_path)
Score by the count of complexity-rule violations.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/complexity.py
NodeCouplingRule
Bases: ProjectRule
Flag over-coupled modules (high fan-out) via axm-ast.
Mirrors the Python CouplingMetricRule: modules with fan-out > 10,
100 - count * 5.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/coupling.py
rule_id
property
Unique identifier (shared with the Python coupling rule).
check(project_path)
Score by the count of modules whose fan-out exceeds the threshold.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/coupling.py
NodeDeadCodeRule
Bases: _KnipRule
Score unused files + unused exports (knip).
Mirrors the Python DeadCodeRule (category lint): 100 - items*10.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/knip.py
rule_id
property
Unique identifier (shared with the Python dead-code rule).
score_output(parsed, project_path)
Score by the count of unused files + unused exports/types.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/knip.py
NodeDependencyRule
Bases: _KnipRule
Score unused + unlisted dependency hygiene (knip).
Mirrors the Python DependencyHygieneRule: 100 - issues * 10.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/knip.py
rule_id
property
Unique identifier for this rule.
score_output(parsed, project_path)
Score by the count of unused/unlisted dependency issues.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/knip.py
NodeDiffSizeRule
dataclass
Bases: DiffSizeRule
Diff-size rule for node projects — identical git-based logic.
git diff is language-agnostic, so this reuses the Python
implementation wholesale; only the framework registration differs.
Lives in lint like the Python DiffSizeRule.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/quality.py
NodeDuplicationRule
Bases: NodeToolRule
Score code duplication found by jscpd --reporters json.
Mirrors the Python DuplicationRule intent. jscpd reports a duplicated
percentage; we map it to a score (0% → 100, ≥10% → 0) and pass below a 3%
duplication threshold (the research's recommended ceiling).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/architecture.py
| Python | |
|---|---|
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
args
property
Placeholder — :meth:check builds the argv with a real output dir.
rule_id
property
Unique identifier (shared with the Python duplication rule).
check(project_path)
Run jscpd, reading the percentage from its JSON report file.
jscpd's json reporter writes jscpd-report.json to an output
directory; nothing structured lands on stdout (only a one-line human
summary). The base :class:NodeToolRule.parse JSON-decodes stdout, which
for jscpd always yields [] → pct 0 → a permanent false-green. So this
rule reads the report file instead of stdout.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/architecture.py
score_output(parsed, project_path)
Score inversely to the duplicated-token percentage.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/architecture.py
NodeFormatRule
Bases: NodeToolRule
Run prettier --check and score by the unformatted-file count.
Lives in the lint category to mirror the Python FormattingRule.
Scoring: 100 - files * 5, min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/format.py
args
property
Check formatting across the project without writing changes.
findings_returncodes
property
Prettier exits 1 when files are unformatted — that is a finding.
rule_id
property
Unique identifier for this rule (shared with the Python format rule).
parse(result)
Prettier reports unformatted files on stderr — combine both streams.
score_output(parsed, project_path)
Score by the count of unformatted files (parsed is combined output).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/format.py
NodeGodClassRule
Bases: ProjectRule
Flag god classes (too many lines or methods) via axm-ast.
Mirrors the Python GodClassRule: lines > 500 or methods > 15,
100 - count * 15.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/coupling.py
rule_id
property
Unique identifier (shared with the Python god-class rule).
check(project_path)
Score by the count of god classes found in the package's TS classes.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/coupling.py
NodeLintRule
Bases: NodeToolRule
Run ESLint and score based on issue count (Node/Svelte/React projects).
Scoring: 100 - issue_count * 2, min 0 — identical to the Python lint
rule so the lint category is framework-agnostic at the scoring layer.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/lint.py
args
property
Run ESLint over the whole project with the JSON formatter.
rule_id
property
Unique identifier for this rule (shared with the Python lint rule).
score_output(parsed, project_path)
Score by the total ESLint error + warning count.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/lint.py
NodeSecretsRule
Bases: NodeToolRule
Score hardcoded-secret findings from gitleaks.
Mirrors the Python PRACTICE_SECURITY (secret scan): 100 - secrets*25.
gitleaks is a system tool (not a node_modules binary); it writes its JSON
report to stdout and exits non-zero when leaks are found.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/security.py
args
property
Scan the directory, emitting the JSON report to stdout.
findings_returncodes
property
gitleaks exits 1 when leaks are found — a finding, not a crash.
rule_id
property
Unique identifier (shared with the Python secret-scan rule).
score_output(parsed, project_path)
Score by the number of secret findings (gitleaks JSON is an array).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/security.py
NodeSecurityLintRule
Bases: NodeToolRule
Score eslint-plugin-security findings (the bandit pendant for TS/JS).
Mirrors the Python QUALITY_SECURITY: 100 - findings * 15. Reuses the
project's ESLint config (which must enable eslint-plugin-security) and
filters the security/* ruleIds from the JSON output.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/quality.py
args
property
Run ESLint over the project with the JSON formatter.
rule_id
property
Unique identifier (shared with the Python security rule).
score_output(parsed, project_path)
Score by the count of eslint-plugin-security findings.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/quality.py
NodeStructureRule
Bases: ProjectRule
Check package.json completeness + tsconfig strict mode.
Mirrors the Python PyprojectCompletenessRule: binary field-presence
checks, 100 - missing * 10.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/structure.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Score by the count of missing manifest fields + strict tsconfig opts.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/structure.py
NodeTestDuplicateRule
Bases: ProjectRule
Flag duplicate test bodies (identical it/test blocks).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
rule_id
property
Unique identifier (shared with the Python duplicate-tests rule).
check(project_path)
Count test cases whose normalized body duplicates an earlier one.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
NodeTestMirrorRule
Bases: ProjectRule
Every source module has a colocated *.test.ts (node mirror idiom).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
rule_id
property
Unique identifier (shared with the Python mirror rule).
check(project_path)
Flag source modules with no sibling test file.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
NodeTestPyramidRule
Bases: ProjectRule
Colocated *.test.ts are unit tests; flag ones doing real I/O.
A colocated unit test that touches the filesystem/network/subprocess is a
soft signal it belongs in tests/integration or tests/e2e instead.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
rule_id
property
Unique identifier (shared with the Python pyramid-level rule).
check(project_path)
Flag colocated unit tests that perform real I/O.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
NodeTestRule
Bases: NodeToolRule
Run Vitest and require a non-empty, fully-passing suite.
Mirrors the Python testing invariant: a green run with zero tests is NOT a
pass (guards against passWithNoTests). Score is the pass ratio times
100, forced to 0 when no tests ran.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/testing.py
args
property
Run the suite once with the JSON reporter (no watch).
findings_returncodes
property
Vitest exits 1 when tests fail — a finding we score, not a crash.
rule_id
property
Unique identifier (shared cross-framework: test-suite health).
score_output(parsed, project_path)
Score by pass ratio; an empty suite is a hard fail (false-green guard).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/testing.py
NodeTestTautologyRule
Bases: ProjectRule
Flag tautological assertions (expect(true), x.toBe(x)).
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
rule_id
property
Unique identifier (shared with the Python tautology rule).
check(project_path)
Count tautological assertions across the project's test files.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/test_quality.py
NodeTypeCheckRule
Bases: NodeToolRule
Run tsc --noEmit and score by the TypeScript error count.
Scoring: 100 - errors * 5, min 0 — identical to the Python type rule.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/typecheck.py
args
property
Type-check without emitting, with a parseable (non-pretty) format.
findings_returncodes
property
tsc exits 1 or 2 when it found type errors — not an env failure.
rule_id
property
Unique identifier for this rule (shared with the Python type rule).
parse(result)
tsc emits text, not JSON — return raw stdout for scoring.
score_output(parsed, project_path)
Score by the count of error TSxxxx diagnostics.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/typecheck.py
NodeVulnerabilityRule
Bases: NodeToolRule
Score npm-audit vulnerabilities (HIGH/CRITICAL).
Mirrors the Python DEPS_AUDIT: 100 - (high+critical) * 15. Lives in
the deps category like its Python counterpart.
Source code in packages/axm-audit/src/axm_audit/core/rules/node/security.py
args
property
Full vulnerability report as JSON (no --audit-level: that's a gate).
findings_returncodes
property
npm audit exits 1 when vulnerabilities are present — a finding.
rule_id
property
Unique identifier (shared with the Python dependency-audit rule).
score_output(parsed, project_path)
Score by HIGH (15 each) + CRITICAL (15 each) vulnerability counts.