Config should not be evaluated for ignored files (#6233)
Prior to this change, the CLI would resolve the config for a file before checking it against the ignored list. If the config was invalid, the CLI would report a failure. This change relocates the config-resolution phase until after the file is confirmed to not be ignored.
This commit is contained in:
1 parent
cacaa92a3f
commit
353b2ca064
3 files changed
+8
-9
No files matched your search
+6
-9
@@ -420,14 +420,7 @@ function eachFilename(context, patterns, callback) {
|
||||
process.exitCode = 2;
|
||||
return;
|
||||
}
|
||||
filePaths.forEach(filePath =>
|
||||
callback(
|
||||
filePath,
|
||||
Object.assign(getOptionsForFile(context, filePath), {
|
||||
filepath: filePath
|
||||
})
|
||||
)
|
||||
);
|
||||
filePaths.forEach(filePath => callback(filePath));
|
||||
} catch (error) {
|
||||
context.logger.error(
|
||||
`Unable to expand glob patterns: ${patterns.join(" ")}\n${error.message}`
|
||||
@@ -448,7 +441,7 @@ function formatFiles(context) {
|
||||
context.logger.log("Checking formatting...");
|
||||
}
|
||||
|
||||
eachFilename(context, context.filePatterns, (filename, options) => {
|
||||
eachFilename(context, context.filePatterns, filename => {
|
||||
const fileIgnored = ignorer.filter([filename]).length === 0;
|
||||
if (
|
||||
fileIgnored &&
|
||||
@@ -460,6 +453,10 @@ function formatFiles(context) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = Object.assign(getOptionsForFile(context, filename), {
|
||||
filepath: filename
|
||||
});
|
||||
|
||||
if (isTTY()) {
|
||||
// Don't use `console.log` here since we need to replace this line.
|
||||
context.logger.log(filename, { newline: false });
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
throw Error('This config should not be evaluated since the directory is ignored');
|
||||
@@ -0,0 +1 @@
|
||||
throw Error('This config should not be evaluated since the directory is ignored');
|
||||
Reference in new issue
Block a user