Skip to content

💡: Add maxFileSize configuration option to skip large files #7953

@liblaf

Description

@liblaf

Problem

Currently, cspell does not provide a built-in way to skip files based on their size. When working with repositories that contain large files (e.g., JSON/CSV data files), cspell will attempt to process them, which can lead to:

  • Performance degradation and long processing times
  • Memory issues when reading very large files
  • Unnecessary spell-checking of files that don't benefit from it

Solution

Add a maxFileSize configuration option that automatically skips files exceeding a specified size threshold.

Configuration File Example

cspell.json:

{
  "version": "0.2",
  "maxFileSize": 1048576,  // 1MB in bytes
  "ignorePaths": ["node_modules/**"]
}

cspell.config.js:

module.exports = {
  maxFileSize: 1024 * 1024,  // 1MB
  // or with human-readable format
  maxFileSize: '1MB',
};

Command Line Flag Example

cspell lint --max-file-size 1048576 .
# or with human-readable format
cspell lint --max-file-size 1MB .

Behavior

  • Files exceeding maxFileSize should be automatically skipped
  • Skipped files should be reported in verbose mode: Skipped: large-file.json (size: 5MB, max: 1MB)
  • The default value should be unlimited (current behavior) for backward compatibility
  • Size could be specified in bytes or with units (KB, MB, GB)

Alternatives

Users currently need to manually exclude large files using:

  • --exclude patterns (requires knowing specific file paths)
  • ignorePaths in configuration (requires maintaining patterns)
  • .gitignore integration (not always suitable)

These workarounds are not ideal because they require manual maintenance and don't automatically handle files based on size.

Additional Context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions