mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-21 21:47:18 +08:00
This CL moves inspector_overlay out of the front_end folder. Unit tests remain under the front_end for now as we need to see how to move them (they rely on karma config and helpers). Design doc: https://docs.google.com/document/d/1yuQoNPtH2KxSFKoz3bRrQKu9wrPUjW4hx7idzAxb_B4/edit Bug: 1100925 Change-Id: I0da88d9aae33602572d11485a3cbb46b5e3d588f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2395397 Reviewed-by: Mathias Bynens <mathias@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Patrick Brosset <patrick.brosset@microsoft.com> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Use V8's code cache to speed up instantiation time.
|
|
require('v8-compile-cache');
|
|
|
|
const path = require('path');
|
|
const CLIEngine = require('eslint').CLIEngine;
|
|
|
|
const ROOT_DIRECTORY = path.join(__dirname, '..', '..');
|
|
const FRONT_END_DIRECTORY = path.join(ROOT_DIRECTORY, 'front_end');
|
|
const INSPECTOR_OVERLAY_DIRECTORY = path.join(ROOT_DIRECTORY, 'inspector_overlay');
|
|
const TEST_DIRECTORY = path.join(ROOT_DIRECTORY, 'test');
|
|
const SCRIPTS_DIRECTORY = path.join(ROOT_DIRECTORY, 'scripts');
|
|
|
|
const DEFAULT_DIRECTORIES_TO_LINT =
|
|
[FRONT_END_DIRECTORY, INSPECTOR_OVERLAY_DIRECTORY, TEST_DIRECTORY, SCRIPTS_DIRECTORY];
|
|
|
|
const eslintignorePath = path.join(ROOT_DIRECTORY, '.eslintignore');
|
|
|
|
let directoriesOrFilesToLint = process.argv.slice(2);
|
|
|
|
if (directoriesOrFilesToLint.length === 0) {
|
|
directoriesOrFilesToLint = DEFAULT_DIRECTORIES_TO_LINT;
|
|
}
|
|
|
|
const cli = new CLIEngine({
|
|
extensions: ['.js', '.ts'],
|
|
ignorePath: eslintignorePath,
|
|
fix: true,
|
|
});
|
|
|
|
// We filter out certain files in the `.eslintignore`. However, ESLint produces warnings
|
|
// when you include a particular file that is ignored. This means that if you edit a file
|
|
// that is directly ignored in the `.eslintignore`, ESLint would report a failure.
|
|
// This was originally reported in https://github.com/eslint/eslint/issues/9977
|
|
// The suggested workaround is to use the CLIEngine to pre-emptively filter out these
|
|
// problematic paths.
|
|
const filteredFilesToLint = directoriesOrFilesToLint.filter(path => !cli.isPathIgnored(path));
|
|
|
|
const report = cli.executeOnFiles(filteredFilesToLint);
|
|
|
|
// Write fixes to the filesystem
|
|
CLIEngine.outputFixes(report);
|
|
console.log(cli.getFormatter()(report.results));
|
|
|
|
const hasProblems = report.errorCount + report.warningCount > 0;
|
|
process.exit(hasProblems ? 1 : 0);
|