@rushstack/eslint-bulk
Advanced tools
Comparing version 0.1.29 to 0.1.30
@@ -31,12 +31,12 @@ "use strict"; | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
function findPatchPath() { | ||
const candidatePaths = [`${process.cwd()}/.eslintrc.js`, `${process.cwd()}/.eslintrc.cjs`]; | ||
let eslintrcPath; | ||
if (fs.existsSync(path.join(process.cwd(), '.eslintrc.js'))) { | ||
eslintrcPath = '.eslintrc.js'; | ||
for (const candidatePath of candidatePaths) { | ||
if (fs.existsSync(candidatePath)) { | ||
eslintrcPath = candidatePath; | ||
break; | ||
} | ||
} | ||
else if (fs.existsSync(path.join(process.cwd(), '.eslintrc.cjs'))) { | ||
eslintrcPath = '.eslintrc.cjs'; | ||
} | ||
else { | ||
if (!eslintrcPath) { | ||
console.error('@rushstack/eslint-bulk: Please run this command from the directory that contains .eslintrc.js or .eslintrc.cjs'); | ||
@@ -46,5 +46,42 @@ process.exit(1); | ||
const env = Object.assign(Object.assign({}, process.env), { _RUSHSTACK_ESLINT_BULK_DETECT: 'true' }); | ||
let eslintPackageJsonPath; | ||
try { | ||
eslintPackageJsonPath = require.resolve('eslint/package.json', { paths: [process.cwd()] }); | ||
} | ||
catch (e) { | ||
if (e.code !== 'MODULE_NOT_FOUND') { | ||
throw e; | ||
} | ||
} | ||
let eslintBinPath; | ||
if (eslintPackageJsonPath) { | ||
eslintPackageJsonPath = eslintPackageJsonPath.replace(/\\/g, '/'); | ||
const packagePath = eslintPackageJsonPath.substring(0, eslintPackageJsonPath.lastIndexOf('/')); | ||
const { bin: { eslint: relativeEslintBinPath } = {} } = require(eslintPackageJsonPath); | ||
if (relativeEslintBinPath) { | ||
eslintBinPath = `${packagePath}/${relativeEslintBinPath}`; | ||
} | ||
else { | ||
console.warn(`@rushstack/eslint-bulk: The eslint package resolved at "${packagePath}" does not contain an eslint bin path. ` + | ||
'Attempting to use a globally-installed eslint instead.'); | ||
} | ||
} | ||
else { | ||
console.log('@rushstack/eslint-bulk: Unable to resolve the eslint package as a dependency of the current project. ' + | ||
'Attempting to use a globally-installed eslint instead.'); | ||
} | ||
let eslintBinCommand; | ||
if (eslintBinPath) { | ||
eslintBinCommand = `${process.argv0} ${eslintBinPath}`; | ||
} | ||
else { | ||
eslintBinCommand = 'eslint'; // Try to use a globally-installed eslint if a local package was not found | ||
} | ||
let stdout; | ||
try { | ||
stdout = (0, child_process_1.execSync)(`eslint --stdin --config ${eslintrcPath}`, { env, input: '', stdio: 'pipe' }); | ||
stdout = (0, child_process_1.execSync)(`${eslintBinCommand} --stdin --config ${eslintrcPath}`, { | ||
env, | ||
input: '', | ||
stdio: 'pipe' | ||
}); | ||
} | ||
@@ -103,5 +140,3 @@ catch (e) { | ||
try { | ||
const args = process.argv.slice(2).join(' '); | ||
const command = `node ${patchPath} ${args}`; | ||
(0, child_process_1.execSync)(command, { stdio: 'inherit' }); | ||
require(patchPath); | ||
} | ||
@@ -108,0 +143,0 @@ catch (e) { |
{ | ||
"name": "@rushstack/eslint-bulk", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "Roll out new ESLint rules in a large monorepo without cluttering up your code with \"eslint-ignore-next-line\"", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20325
144
4