Skip to content

Commit 34bfbfe

Browse files
tniessenMylesBorins
authored andcommitted
tools: avoid using process.cwd in tools/lint-js
The first occurrence of path.join() can easily be replaced with path.resolve(). The second occurrence should be unnecessary as ESLint will resolve the path internally, and the old check probably did not work as intended anyway. PR-URL: #17121 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c4eb683 commit 34bfbfe

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

tools/lint-js.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const totalCPUs = require('os').cpus().length;
1313
const CLIEngine = require('./eslint').CLIEngine;
1414
const glob = require('./eslint/node_modules/glob');
1515

16-
const cwd = process.cwd();
1716
const cliOptions = {
1817
rulePaths: rulesDirs,
1918
extensions: extensions,
@@ -82,9 +81,7 @@ if (cluster.isMaster) {
8281
if (i !== -1) {
8382
if (!process.argv[i + 1])
8483
throw new Error('Missing output filename');
85-
var outPath = process.argv[i + 1];
86-
if (!path.isAbsolute(outPath))
87-
outPath = path.join(cwd, outPath);
84+
const outPath = path.resolve(process.argv[i + 1]);
8885
fd = fs.openSync(outPath, 'w');
8986
outFn = function(str) {
9087
fs.writeSync(fd, str, 'utf8');
@@ -176,8 +173,6 @@ if (cluster.isMaster) {
176173
while (paths.length) {
177174
var dir = paths.shift();
178175
curPath = dir;
179-
if (dir.indexOf('/') > 0)
180-
dir = path.join(cwd, dir);
181176
const patterns = cli.resolveFileGlobPatterns([dir]);
182177
dir = path.resolve(patterns[0]);
183178
files = glob.sync(dir, globOptions);

0 commit comments

Comments
 (0)