npm cspell 10.3.3
v10.3.3

12 hours ago

Fixes

fix: Add `--json` option to check text for use with AI (#9254)

fix: Add --json option to check text for use with AI (#9254)

This pull request adds support for a --json output mode to the check CLI command, enabling results to be emitted as structured JSON per file. It also introduces comprehensive test coverage for the new JSON output behavior, including error handling and exit code logic.

CLI Enhancements:

  • Added a --json flag to the check command, allowing users to receive results in JSON format. This includes proper handling of multiple files and error cases, such as missing files. [1] [2]
  • Updated the exit code logic to work with both standard and JSON output, respecting the --no-exit-code flag. [1] [2]

Implementation Details:

  • Introduced separate processing functions: processRequestAnsi for standard output and processRequestJSON for JSON output, with the latter aggregating results and errors per file. [1] [2]
  • Added a helper function to detect missing files and report them as JSON errors.

Testing Improvements:

  • Expanded CLI test coverage to include various --json scenarios, such as files with spelling errors, missing files, and the interaction with --no-exit-code. [1] [2]
  • Added utility functions and interfaces in tests to parse and validate the JSON output.

fix: Mark ParsedTags as read only. (#9253)

fix: Mark ParsedTags as read only. (#9253)

This pull request makes a small but important change to the ParsedText interface in several files, improving type safety by marking the tags property as a read-only type. This ensures that the tags associated with a parsed text segment cannot be modified after creation.

  • Updated the tags property in the ParsedText interface to use Readonly<ParsedTags> instead of ParsedTags, making the tags immutable in the following files:
    • packages/cspell-types/api/Parser/index.d.mts
    • packages/cspell-types/api/index.d.mts
    • packages/cspell-types/src/Parser/parser.ts

fix: Make sure Parser and DocumentParser can be used together. (#9252)

fix: Make sure Parser and DocumentParser can be used together. (#9252)

This pull request enhances the parser interface definitions in the cspell-types package to provide better flexibility and clarity for parser implementations. The main changes introduce optional parseDocument and parse methods to both the Parser and DocumentParser interfaces, across both type declaration and source files.

Parser interface enhancements:

  • Added an optional parseDocument method to the Parser interface, allowing parsers to optionally implement document-based parsing. (packages/cspell-types/api/Parser/index.d.mts [1] packages/cspell-types/api/index.d.mts [2] packages/cspell-types/src/Parser/parser.ts [3]
  • Added an optional parse method to the DocumentParser interface, enabling parsers to optionally implement content-and-filename-based parsing. (packages/cspell-types/api/Parser/index.d.mts [1] packages/cspell-types/api/index.d.mts [2] packages/cspell-types/src/Parser/parser.ts [3]

Don't miss a new cspell release

NewReleases is sending notifications on new releases.