Skip to main content

Crate jsslint_core

Crate jsslint_core 

Source
Expand description

Core rule engine for the JSS style checker — spec 018 Rust port.

This crate contains zero binding-specific code. jsslint-cli, jsslint-wasm, jsslint-r, and jsslint-py are thin marshalling layers over the types and functions exported here; see /home/node/.claude/plans/having-the-style-checker-compressed-crown.md for the full architecture.

Re-exports§

pub use catalogue::lookup as lookup_rule;
pub use catalogue::RuleMeta;
pub use report::CategoryStatus;
pub use report::CategorySummary;
pub use report::ComplianceReport;
pub use report::Fix;
pub use report::FixConfidence;
pub use report::Severity;
pub use report::SkippedRule;
pub use report::Violation;

Modules§

bib
BibTeX parsing substrate — spec 018 Phase 2. See parser.rs’s module docs for the exact bibtexparser-compatibility policy this implements (including the core/parser.py-specific duplicate-key / duplicate-field re-insertion behavior, which differs from raw bibtexparser).
catalogue
Rule metadata catalogue — compiled in from specs/003-jss-rule-catalogue/catalogue.yaml by build.rs.
config
Tool configuration — mirrors texlint.api.ToolConfig (the fields Phase 4 needs, plus doi_resolver) and texlint.config’s defaults-then-.jss-lint.toml-then-CLI merge (load).
conformance
One-page conformance report — mirrors texlint/report.py (spec 015). Markdown and HTML are ported here; PDF is CLI-only scope (see jsslint-cli’s report_pdf module) since it’s a different document from Python’s WeasyPrint-rendered PDF, not something jsslint-core’s WASM/PyO3 consumers need — see rust/README.md.
diff
jss-lint diff engine + renderers — mirrors texlint/diff.py (spec 016). Pure comparison over the spec-001 --output json shape; violations are kept as generic serde_json::Value objects (not this crate’s typed Violation) since a diff input can be any spec-001-shaped JSON file, including ones this binary didn’t produce, and every original field must round-trip into render_json’s output untouched.
engine
Document assembly + rule-running engine — mirrors core/engine.py’s parse_document/load_journal/run.
explain
Rule explanation renderer — mirrors texlint/explain.py (spec 009).
fixer
Auto-fix engine — mirrors core/fixer.py in full, including the file I/O, atomic write, interactive prompting, and re-validation-by-re-running-the-whole-engine parts of Python’s apply_fixes (deferred in the initial port to a pure-logic subset since a fully assembled rule engine didn’t exist yet; Phase 4 now has one).
html_output
Author/reviewer HTML renderer — hand-translated from output/html_output.py‘s author.html.j2/reviewer.html.j2 (no templating-engine dependency, matching this crate’s existing terminal.rs/sarif.rs/conformance.rs approach of building output strings directly). Byte-exact output was derived by reading the templates’ Jinja2 whitespace-control semantics ({%- -%} trim markers around the guide-link <td>; every other {% %} tag is not trimmed, since the templates’ Environment doesn’t set trim_blocks/lstrip_blocks, so untrimmed tags leave their adjacent source newlines/indentation in the output) and cross- checked against real jss-lint --output html renders.
json_output
Deterministic JSON renderer — mirrors /workspace/src/texlint/output/json_output.py byte-for-byte, including two of its quirks (both intentional to preserve parity, not oversights):
lsp
Pure projections from Violation/Fix to LSP-shaped plain data — mirrors texlint/lsp/conversions.py. Deliberately returns plain structs, not lsp_types wire types: this module has no LSP protocol library dependency, matching conversions.py’s own design (“importable without pygls; the actual LSP server … lives in a sibling module”). jsslint-cli’s protocol-speaking server converts these into lsp_types structs for transmission.
report
Domain model — mirrors texlint.api (see /workspace/src/texlint/api.py).
rmd
.Rmd (R Markdown) parsing — ports core/rmd_parser.py’s hand-rolled line-based tokenizer exactly: START -> FRONTMATTER -> BODY -> FENCE state machine splitting the file into YAML frontmatter, headings, prose blocks, and fenced code blocks. Each prose block is scrubbed (HTML comments, URLs, inline R/code spans, bold/italic emphasis -> blanked to equivalent-length whitespace) and then parsed as a raw-LaTeX fragment via the unmodified tex::parse_tex_source.
rnw
.Rnw (Sweave/knitr) chunk preprocessing — ports core/parser.py’s wrap_rnw_chunks_as_sinput and its helpers (_global_chunk_defaults, _chunk_is_hidden) exactly. Rewrites R code chunks (<<...>>=@) into \begin{Sinput} / \end{Sinput} envelopes in place (newline-count preserving) so the rewritten source can be fed, unchanged, through the existing tex::parse_tex_source pipeline — no changes needed there.
rules
Shared rule infrastructure — spec 018 Phase 2. Ports the parts of _helpers.py and per-rule-module helper functions that more than one bib rule needs: citation-scope resolution (_iter_referenced_entries / _collect_cited_keys), the entry_line/entry_violation factories, and the source-rescan technique naming.py/house_style.py use to locate a field value’s byte span for a Fix (bibtexparser exposes no field-level offsets, only entry.start_line).
sarif
Deterministic SARIF 2.1.0 renderer — mirrors output/sarif.py (spec 006 contract + the spec 008 fixes[] addition). Reuses json_output::write_value for the same Python-json.dumps- compatible serialization (ensure_ascii=True escaping, sort_keys=True, indent=2).
terminal
Terminal renderer — mirrors output/terminal.py’s rich-based rendering for the NON-terminal (piped/redirected stdout) case, which is what Console(force_terminal=False, ...) produces when sys.stdout isn’t a real tty (the overwhelmingly common case: CI, editor-integration subprocess calls, > file.txt). No ANSI color codes are emitted in that case even though the Python source builds [red]...[/red]-style markup — rich strips it down to plain text automatically. Real-terminal (tty) colored output is NOT replicated here; this module only targets the non-tty path.
terms
Canonical-form lookup tables — embedded from specs/003-jss-rule-catalogue/terms.json (generated from texlint.journals.jss.terms by tools/generate_terms_json.py; run that script and commit the diff whenever terms.py changes).
tex
Tolerant LaTeX parsing substrate — spec 018 Phase 1. Ports pylatexenc.latexwalker’s node model (node.rs, parser.rs), core/parser.py’s pre-tokenization neutralization (neutralize.rs), pos_to_lineno_colno (position.rs), and _helpers.py’s prose-context classifier (prose.rs).