Svelte-specific rule delta (sits on top of the shared node base layer).
A Svelte project runs every node rule (via resolve_frameworks) PLUS the
rules here. The svelte delta is small by design: the research shows Svelte puts
its UI concerns in the compiler (a11y warnings, type-checking .svelte)
rather than in ESLint plugins, so the delta is essentially one extra CLI —
svelte-check — that tsc alone cannot replace.
Importing this package fires the @register_rule decorators (side effect).
SvelteCheckRule
Bases: NodeToolRule
Run svelte-check and score by its error count.
Scoring: 100 - errors * 5 (same per-error weight as the type rule).
Contributes to the type category for Svelte projects on top of tsc.
Source code in packages/axm-audit/src/axm_audit/core/rules/svelte/svelte_check.py
| Python |
|---|
| @register_rule("type", framework=Framework.SVELTE)
class SvelteCheckRule(NodeToolRule):
"""Run ``svelte-check`` and score by its error count.
Scoring: ``100 - errors * 5`` (same per-error weight as the type rule).
Contributes to the ``type`` category for Svelte projects on top of ``tsc``.
"""
binary = "svelte-check"
install_hint = "Install svelte-check: npm install -D svelte-check"
@property
def rule_id(self) -> str:
"""Unique identifier for this rule."""
return "SVELTE_CHECK"
@property
def args(self) -> list[str]:
"""Machine-readable output, errors-only threshold."""
return ["--output", "machine", "--threshold", "error"]
@property
def findings_returncodes(self) -> frozenset[int]:
"""svelte-check exits 1 when it found errors — a finding, not a crash."""
return frozenset({1})
def parse(self, result: subprocess.CompletedProcess[str]) -> object:
"""svelte-check emits text rows, not JSON — return raw stdout."""
return result.stdout
def score_output(self, parsed: object, project_path: Path) -> CheckResult:
"""Score by the count of svelte-check ERROR diagnostics."""
output = parsed if isinstance(parsed, str) else ""
error_count = _count_errors(output)
score = max(0, 100 - error_count * 5)
passed = score >= PASS_THRESHOLD
return CheckResult(
rule_id=self.rule_id,
passed=passed,
message=f"svelte-check: {score}/100 ({error_count} errors)",
severity=Severity.WARNING if not passed else Severity.INFO,
score=score,
details={"error_count": error_count},
fix_hint="Fix the svelte-check errors above" if error_count else None,
)
|
args
property
Machine-readable output, errors-only threshold.
findings_returncodes
property
svelte-check exits 1 when it found errors — a finding, not a crash.
rule_id
property
Unique identifier for this rule.
parse(result)
svelte-check emits text rows, not JSON — return raw stdout.
Source code in packages/axm-audit/src/axm_audit/core/rules/svelte/svelte_check.py
| Python |
|---|
| def parse(self, result: subprocess.CompletedProcess[str]) -> object:
"""svelte-check emits text rows, not JSON — return raw stdout."""
return result.stdout
|
score_output(parsed, project_path)
Score by the count of svelte-check ERROR diagnostics.
Source code in packages/axm-audit/src/axm_audit/core/rules/svelte/svelte_check.py
| Python |
|---|
| def score_output(self, parsed: object, project_path: Path) -> CheckResult:
"""Score by the count of svelte-check ERROR diagnostics."""
output = parsed if isinstance(parsed, str) else ""
error_count = _count_errors(output)
score = max(0, 100 - error_count * 5)
passed = score >= PASS_THRESHOLD
return CheckResult(
rule_id=self.rule_id,
passed=passed,
message=f"svelte-check: {score}/100 ({error_count} errors)",
severity=Severity.WARNING if not passed else Severity.INFO,
score=score,
details={"error_count": error_count},
fix_hint="Fix the svelte-check errors above" if error_count else None,
)
|