knip icon indicating copy to clipboard operation
knip copied to clipboard

💡 Rename "ignore" to "ignoreFiles"

Open Zamiell opened this issue 11 months ago • 2 comments

Suggest an idea for Knip

Introduction

Currently, Knip has the following config properties:

  • ignore
  • ignoreBinaries
  • ignoreDependencies
  • ignoreExportsUsedInFile
  • ignoreMembers
  • ignoreUnresolved
  • ignoreWorkspaces

Here, "ignore" really means "ignoreFiles", but that is not really clear from the name alone. Even though this seems like a minor quibble with the tool, it is a cognitive hurdle to use the tool properly.

My User Story

I consider myself to be a veteran user of Knip. However, today, I started with the following config:

export default {
  ignoreBinaries: [ "tsx" ],
  ignoreDependencies: [ "complete-lint" ],
};

I needed to change this config to ignore a new file. So, I naturally tried adding a "ignoreFiles" option, forgetting that it actually supposed to be called "ignore", and then Knip failed to work properly, and let to some frustrating time wasted. If I am being frustrated as a veteran user, then surely other people who are not already familiar with Knip will also encounter difficulties with this.

Recommendation

Since this would be a breaking change, we could start by allowing both "ignore" and "ignoreFiles" interchangeably. And then we could provide a "hint" for people to rename it. And then you could finally remove "ignore" in some future major version.

Zamiell avatar Mar 02 '25 13:03 Zamiell

While I agree it might be confusing, what ignore really does is exclude any type of issue for matching files. So not only unused files are filtered out by this setting, but also unlisted dependencies or unresolved imports.

So I guess what you might be asking for is a new ignoreFiles option to exclude matching files from the unused files category in the report specifically.

webpro avatar Mar 02 '25 16:03 webpro

I guess what you might be asking for is a new ignoreFiles option to exclude matching files from the unused files category in the report specifically.

Yes, thank you.

Zamiell avatar Mar 02 '25 16:03 Zamiell

Closing this issue as part of a general cleanup to keep this project sustainable and optimize my time working on it. If you think this is inappropriate or if there is no workaround and you feel stuck, feel free to open a new issue. Thanks for your understanding.

webpro avatar Aug 10 '25 07:08 webpro