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 4 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
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to do this update in next instead and show this error to the user? I’m not sure what an “invalid path” is, but it sounds useful to get to know that some of my patterns are wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. I'm not changing current behave

Copy link
Member

Choose a reason for hiding this comment

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

@evilebottnawi Do you have experience from ESLint or stylelint?

fisker marked this conversation as resolved.
Show resolved Hide resolved
}

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
11 changes: 8 additions & 3 deletions yarn.lock
Expand Up @@ -3333,14 +3333,19 @@ ignore-walk@^3.0.1:
dependencies:
minimatch "^3.0.4"

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

ignore@^3.3.5:
version "3.3.7"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021"

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

import-fresh@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546"
Expand Down