mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-29 16:57:00 +08:00
[eslint] Fix when running with .
Fixes some issue around what gets ignored when linting. Found while running `npm run lint -- .` Bug: 397260638 Change-Id: I858b9078611a3cb9f31c60ff3e18d99b56563d73 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6280813 Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Mathias Bynens <mathias@chromium.org>
This commit is contained in:
committed by
Devtools-frontend LUCI CQ
parent
d593a7bbb3
commit
4dc470bc32
@@ -6,7 +6,7 @@ import { spawn } from 'child_process';
|
||||
import { ESLint } from 'eslint';
|
||||
import { readFileSync } from 'fs';
|
||||
import { sync } from 'globby';
|
||||
import { extname, join } from 'path';
|
||||
import { extname, join, resolve, relative } from 'path';
|
||||
import stylelint from 'stylelint';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
@@ -247,12 +247,37 @@ async function runLitAnalyzer(files) {
|
||||
return results.every(r => r.status);
|
||||
}
|
||||
|
||||
const DEVTOOLS_ROOT_DIR = resolve(import.meta.dirname, '..', '..');
|
||||
/**
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function shouldIgnoreFile(path) {
|
||||
const resolvedPath = resolve(path);
|
||||
const relativePath = relative(DEVTOOLS_ROOT_DIR, resolvedPath);
|
||||
|
||||
if (
|
||||
relativePath.includes('third_party') ||
|
||||
relativePath.includes('node_modules')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const scripts = [];
|
||||
const styles = [];
|
||||
for (const path of sync(flags.files, {
|
||||
expandDirectories: { extensions: ['css', 'mjs', 'js', 'ts'] },
|
||||
gitignore: true,
|
||||
})) {
|
||||
if (shouldIgnoreFile(path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (extname(path) === '.css') {
|
||||
styles.push(path);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user