Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change priority order of ignorePath and ignorePatterns (or at least document it) #863

Open
alexeyr-ci opened this issue Dec 9, 2023 · 0 comments
Labels

Comments

@alexeyr-ci
Copy link
Contributor

alexeyr-ci commented Dec 9, 2023

Feature request description

Currently the ignorer is generated as follows:

depcheck/src/index.js

Lines 62 to 90 in 77fe0e2

function getIgnorer({ rootDir, ignorePath, ignorePatterns }) {
const ignorer = ignore();
ignorer.add(ignorePatterns);
// If an .*ignore file is configured
if (ignorePath) {
const ignorePathFile = path.resolve(rootDir, ignorePath);
if (fs.existsSync(ignorePathFile)) {
debug('depcheck:ignorer')(`Using ${ignorePathFile} as ignore file.`);
const ignorePathFileContent = fs.readFileSync(ignorePathFile, 'utf8');
ignorer.add(ignorePathFileContent);
}
return ignorer;
}
// Fallback on .depcheckignore or .gitignore
const ignoreFile = ['.depcheckignore', '.gitignore']
.map((file) => path.resolve(rootDir, file))
.find((file) => fs.existsSync(file));
if (ignoreFile) {
debug('depcheck:ignorer')(`Using ${ignoreFile} as ignore file.`);
const ignoreContent = fs.readFileSync(ignoreFile, 'utf8');
ignorer.add(ignoreContent);
}
return ignorer;
}

I'd prefer ignorePatterns to be added after ignorePath content. The use-case is to "unignore" generated code which may be the only user of some dependencies. Failing that, document:

  1. That ignorePath follows ignorePatterns;
  2. The fallback files if ignorePath is not given.

Also, if ignorePath is explicitly specified and doesn't exist, that should probably be an error.

I'd be happy to provide a PR.

Code snippets (if applicable)

Not applicable.

Any extra info

Anything else you want to include. Thank you for your input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant