Skip to content

negation-of-excluded-parent

INI / EditorConfig / .gitignorecorrectnessno fixdefault: warn

Reports a ! pattern for a path whose parent directory is excluded by an earlier pattern (!a/b after a/). Only literal paths are checked. In .dockerignore, where the later pattern wins, it is not reported.

Git does not look inside an excluded directory, so it cannot re-include a file in it, and the negation does nothing. The file stays ignored although the file seems to say otherwise.

To fix, exclude the contents instead of the directory (a/*), then add the negation.

Reported
node_modules/
!node_modules/keep.js
/a/b
!/a/b/c
*.o
!/lib/a.o
vendor/
...
gitignore:
lint:
rules:
negation-of-excluded-parent: warn # off, warn (default), error

Suppress one line with sudsy-disable-next-line negation-of-excluded-parent in a comment of the file’s language.