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.
master
James Reggio 2019-06-18 13:20:47 -07:00 committed by Lucas Duailibe
parent cacaa92a3f
commit 353b2ca064
3 changed files with 8 additions and 9 deletions

View File

@ -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 });

View File

@ -0,0 +1 @@
throw Error('This config should not be evaluated since the directory is ignored');

View File

@ -0,0 +1 @@
throw Error('This config should not be evaluated since the directory is ignored');