Do not fail `yarn linc` for ignored file warning (#11615) (#11641)
* Add rule to ignore default handling of not linting hidden files * Undo changes * Add function to validate warnings * Use validateWarnings when reporting linc command * Restore files * Contain code to line file
Jordan Tepper committed
Nov 28, 2017 at 08:54 UTC
7788bcdb26844a19c23d0f6d5ab4d20822e59c85
1 file changed
+9
-1
scripts/tasks/linc.js
+9
-1
@@ -14,9 +14,17 @@ const changedFiles = [...listChangedFiles()];
14
const jsFiles = changedFiles.filter(file => file.match(/.js$/g));
15
16
const report = lintOnFiles(jsFiles);
17
-if (report.errorCount > 0 || report.warningCount > 0) {
17
+if (report.errorCount > 0 || getSourceCodeWarnings(report)) {
18
console.log('Lint failed for changed files.');
19
process.exit(1);
20
} else {
21
console.log('Lint passed for changed files.');
22
}
23
+
24
+// Prevents failing if the only warnings are about ignored files (#11615)
25
+function getSourceCodeWarnings({warningCount, results}) {
26
+ const ignoreWanings = results.filter(
27
+ ({messages}) => messages[0] && messages[0].message.includes('File ignored')
28
+ );
29
+ return warningCount > 0 ? warningCount !== ignoreWanings.length : false;
30
+}