mirror of
https://github.com/facebook/react.git
synced 2026-02-27 03:07:57 +00:00
* 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
31 lines
981 B
JavaScript
31 lines
981 B
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const lintOnFiles = require('../eslint');
|
|
const listChangedFiles = require('../shared/listChangedFiles');
|
|
|
|
const changedFiles = [...listChangedFiles()];
|
|
const jsFiles = changedFiles.filter(file => file.match(/.js$/g));
|
|
|
|
const report = lintOnFiles(jsFiles);
|
|
if (report.errorCount > 0 || getSourceCodeWarnings(report)) {
|
|
console.log('Lint failed for changed files.');
|
|
process.exit(1);
|
|
} else {
|
|
console.log('Lint passed for changed files.');
|
|
}
|
|
|
|
// Prevents failing if the only warnings are about ignored files (#11615)
|
|
function getSourceCodeWarnings({warningCount, results}) {
|
|
const ignoreWanings = results.filter(
|
|
({messages}) => messages[0] && messages[0].message.includes('File ignored')
|
|
);
|
|
return warningCount > 0 ? warningCount !== ignoreWanings.length : false;
|
|
}
|