Skip to content

Define how separately declared include and exclude globs combine #9463

Open

Description

@Jason3S

Background

Since #9408, the patterns in a single glob list are applied in order and the last matching pattern wins, as in .gitignore. That covers one .gitignore file, one ignorePaths list, and one overrides[].filename list.

Include and exclude globs are often declared in separate places, so they have no order between them:

  • The files and ignorePaths settings in a config file.
  • Globs on the command line and --exclude.
  • Command-line globs that start with !, which cspell moves into the exclude list.
  • .gitignore files when useGitignore is on, on top of ignorePaths.
  • ignorePaths from several config files that are merged through import. They are combined in a depth-first walk of the imports.

Today an exclude always wins over an include in these cases, so a file can't be brought back once any exclude matches it. For example, ignorePaths: ["!docs/keep.md"] can't re-include a file that a .gitignore excludes. The cspell command line skips ignorePaths patterns that start with ! and shows a warning.

Questions to answer

  1. Should an exclude always win over an include when they come from different places, or should there be a defined order between the sources?
  2. If there is an order, what is it? For example: .gitignore, then config ignorePaths in depth-first import order, then the command line.
  3. Should ignorePaths patterns that start with ! work on the command line, and what do they re-include?

Related: #5104, #9408

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