Skip to content

Add a CSpell custom-dictionary redundancy auditor #72

Description

@szmyty

Outcome

Add a maintained cspell-dicts workflow that finds custom dictionary entries already covered by active, installed, or upstream CSpell dictionaries and can remove safe duplicates without destroying formatting or comments.

A validated prototype from an interactive tooling session already established the desired command model:

cspell-dicts
cspell-dicts audit --scope active
cspell-dicts list --scope installed
cspell-dicts sync
cspell-dicts audit --scope upstream
cspell-dicts clean --dry-run
cspell-dicts clean
cspell-dicts doctor

The prototype delegated membership checks to CSpell's own trace mechanism so plain text, gzip, Hunspell, and compiled trie dictionaries could be handled consistently.

Required behavior

  • Discover the effective CSpell configuration and imported configuration graph.
  • Resolve dictionaryDefinitions, enabled dictionaries, and additional installed @cspell/dict-* packages.
  • Support active, installed, and explicitly synchronized upstream scopes.
  • Cache upstream data beneath the XDG cache root; do not write generated state into the repository.
  • Report exact custom word → covering dictionary mappings.
  • Preserve flagged, compound, commented, or ambiguous dictionary syntax for manual review.
  • Make cleanup opt-in, confirmation-gated, backup-producing, and previewable with --dry-run.
  • Preserve source formatting/comments where the configured file format permits safe surgical edits.
  • Support table, JSON, CSV, TSV, Markdown, and words-only output.
  • Provide a CI failure mode for duplicate custom entries.
  • Redact secrets and avoid copying unrelated config contents into reports.

Acceptance criteria

  • CLI has documented exit codes and stable machine-readable output.
  • Config discovery handles JSON/JSONC/YAML and imported configs where CSpell supports them.
  • Membership checks use CSpell-compatible semantics rather than a partial custom parser.
  • Cleanup never removes ambiguous/flagged entries automatically.
  • Every mutation has a dry run, explicit confirmation or --yes, timestamped backup, and atomic rewrite.
  • Backup/cache locations respect XDG conventions and are surfaced by doctor.
  • Tests cover comments, duplicate entries, case sensitivity, compounds, Hunspell/trie dictionaries, imported configs, missing packages, offline mode, and interrupted cleanup.
  • CI fixture proves that --fail-on-duplicates behaves deterministically.
  • Documentation distinguishes “recognized by an enabled dictionary” from “valid for this project's domain language.”

Provenance

Distilled from a successful repository cleanup session in which hundreds of redundant custom spellings were identified, previewed, backed up, and removed while ambiguous entries remained untouched. Repository-specific word lists and filenames are intentionally omitted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions