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

Update ignore to v5 #6975

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -42,7 +42,7 @@
"html-element-attributes": "2.2.0",
"html-styles": "1.0.0",
"html-tag-names": "1.1.4",
"ignore": "4.0.6",
"ignore": "5.1.4",
"is-ci": "2.0.0",
"jest-docblock": "24.9.0",
"json-stable-stringify": "1.0.1",
Expand Down
8 changes: 7 additions & 1 deletion src/cli/util.js
Expand Up @@ -443,7 +443,13 @@ function formatFiles(context) {
}

eachFilename(context, context.filePatterns, filename => {
const fileIgnored = ignorer.filter([filename]).length === 0;
let fileIgnored = false;
try {
fileIgnored = ignorer.ignores(path.relative(process.cwd(), filename));
} catch (_) {
// Invalid path. TODO: Should we show this error to the user, rather than swallowing it?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add note for next major release about that?

}

if (
fileIgnored &&
(context.argv["debug-check"] ||
Expand Down
7 changes: 6 additions & 1 deletion src/common/create-ignorer.js
Expand Up @@ -31,7 +31,12 @@ createIgnorer.sync = function(ignorePath, withNodeModules) {
* @param {undefined | boolean} withNodeModules
*/
function _createIgnorer(ignoreContent, withNodeModules) {
const ignorer = ignore().add(ignoreContent || "");
const ignorer = ignore();

if (ignoreContent) {
ignorer.add(ignoreContent);
}

if (!withNodeModules) {
ignorer.add("node_modules");
}
Expand Down
9 changes: 8 additions & 1 deletion src/common/get-file-info.js
Expand Up @@ -68,8 +68,15 @@ function _getFileInfo({
resolveConfig = false,
sync = false
}) {
let ignored = true;
try {
ignored = ignorer.ignores(path.relative(process.cwd(), filePath));
} catch (_) {
// Invalid path
}

const fileInfo = {
ignored: ignorer.ignores(filePath),
ignored,
inferredParser: options.inferParser(filePath, plugins) || null
};

Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Expand Up @@ -3294,7 +3294,12 @@ ignore-walk@^3.0.1:
dependencies:
minimatch "^3.0.4"

ignore@4.0.6, ignore@^4.0.6:
ignore@5.1.4:
version "5.1.4"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==

ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"

Expand Down