|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @emails react-core |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +const path = require('path'); |
| 13 | + |
| 14 | +const {ESLint} = require('eslint'); |
| 15 | + |
| 16 | +function getESLintInstance(format) { |
| 17 | + return new ESLint({ |
| 18 | + useEslintrc: false, |
| 19 | + overrideConfigFile: |
| 20 | + __dirname + `../../../scripts/rollup/validate/eslintrc.${format}.js`, |
| 21 | + ignore: false, |
| 22 | + }); |
| 23 | +} |
| 24 | + |
| 25 | +const esLints = { |
| 26 | + cjs: getESLintInstance('cjs'), |
| 27 | +}; |
| 28 | + |
| 29 | +// Performs sanity checks on bundles *built* by Rollup. |
| 30 | +// Helps catch Rollup regressions. |
| 31 | +async function lint(folder) { |
| 32 | + console.log(`Linting ` + folder); |
| 33 | + const eslint = esLints.cjs; |
| 34 | + |
| 35 | + const results = await eslint.lintFiles([ |
| 36 | + __dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.development.js', |
| 37 | + __dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.production.min.js', |
| 38 | + __dirname + '/' + folder + '/cjs/react-jsx-runtime.development.js', |
| 39 | + __dirname + '/' + folder + '/cjs/react-jsx-runtime.production.min.js', |
| 40 | + ]); |
| 41 | + if ( |
| 42 | + results.some(result => result.errorCount > 0 || result.warningCount > 0) |
| 43 | + ) { |
| 44 | + process.exitCode = 1; |
| 45 | + console.log(`Failed`); |
| 46 | + const formatter = await eslint.loadFormatter('stylish'); |
| 47 | + const resultText = formatter.format(results); |
| 48 | + console.log(resultText); |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +async function lintEverything() { |
| 53 | + console.log(`Linting known bundles...`); |
| 54 | + await lint('react-14'); |
| 55 | + await lint('react-15'); |
| 56 | + await lint('react-16'); |
| 57 | + await lint('react-17'); |
| 58 | +} |
| 59 | + |
| 60 | +lintEverything().catch(error => { |
| 61 | + process.exitCode = 1; |
| 62 | + console.error(error); |
| 63 | +}); |
0 commit comments