module

Ignorelint::Checks::NpmignoreSemantics

Semantic checks specific to npmignore files.

Detects redundant patterns that duplicate npm's built-in exclude/include behavior.

Constants

BUILTIN_EXCLUDES = {"*.swp", "._*", ".DS_Store", ".git", ".hg", ".svn", "node_modules"}

Files/directories always excluded by npm, regardless of .npmignore.

Users often list these in .npmignore thinking they need to, but npm already excludes them. See: https://docs.npmjs.com/cli/v10/commands/npm-pack

BUILTIN_INCLUDES = {"package.json", "README*", "CHANGELOG*", "LICENSE", "LICENCE"}

Files always included by npm — cannot be excluded even with .npmignore.

These are required for the package to function. A negation pattern (!package.json) is meaningless because the file is already included.

Instance methods

check(pat : Pattern) : Array(Issue)

Check a single pattern for npmignore-specific issues.

Checks:

  • IG-018: Pattern duplicates a built-in exclude (redundant)
  • IG-019: Negation targets a built-in include (cannot be excluded)