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
parent
cacaa92a3f
commit
353b2ca064
|
@ -420,14 +420,7 @@ function eachFilename(context, patterns, callback) {
|
||||||
process.exitCode = 2;
|
process.exitCode = 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filePaths.forEach(filePath =>
|
filePaths.forEach(filePath => callback(filePath));
|
||||||
callback(
|
|
||||||
filePath,
|
|
||||||
Object.assign(getOptionsForFile(context, filePath), {
|
|
||||||
filepath: filePath
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
context.logger.error(
|
context.logger.error(
|
||||||
`Unable to expand glob patterns: ${patterns.join(" ")}\n${error.message}`
|
`Unable to expand glob patterns: ${patterns.join(" ")}\n${error.message}`
|
||||||
|
@ -448,7 +441,7 @@ function formatFiles(context) {
|
||||||
context.logger.log("Checking formatting...");
|
context.logger.log("Checking formatting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
eachFilename(context, context.filePatterns, (filename, options) => {
|
eachFilename(context, context.filePatterns, filename => {
|
||||||
const fileIgnored = ignorer.filter([filename]).length === 0;
|
const fileIgnored = ignorer.filter([filename]).length === 0;
|
||||||
if (
|
if (
|
||||||
fileIgnored &&
|
fileIgnored &&
|
||||||
|
@ -460,6 +453,10 @@ function formatFiles(context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const options = Object.assign(getOptionsForFile(context, filename), {
|
||||||
|
filepath: filename
|
||||||
|
});
|
||||||
|
|
||||||
if (isTTY()) {
|
if (isTTY()) {
|
||||||
// Don't use `console.log` here since we need to replace this line.
|
// Don't use `console.log` here since we need to replace this line.
|
||||||
context.logger.log(filename, { newline: false });
|
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');
|
Loading…
Reference in New Issue