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
--jsonflag to thecheckcommand, 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-codeflag. [1] [2]
Implementation Details:
- Introduced separate processing functions:
processRequestAnsifor standard output andprocessRequestJSONfor 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
--jsonscenarios, 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
tagsproperty in theParsedTextinterface to useReadonly<ParsedTags>instead ofParsedTags, making the tags immutable in the following files:packages/cspell-types/api/Parser/index.d.mtspackages/cspell-types/api/index.d.mtspackages/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
parseDocumentmethod to theParserinterface, 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
parsemethod to theDocumentParserinterface, 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]