npm-pkg-lint 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +139 -70
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3229,33 +3229,31 @@ var require_tmp = __commonJS({
|
|
|
3229
3229
|
}
|
|
3230
3230
|
function tmpName(options, callback) {
|
|
3231
3231
|
const args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
cb(
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3249
|
-
|
|
3250
|
-
}
|
|
3251
|
-
})();
|
|
3232
|
+
_assertAndSanitizeOptions(opts, function(err, sanitizedOptions) {
|
|
3233
|
+
if (err) return cb(err);
|
|
3234
|
+
let tries = sanitizedOptions.tries;
|
|
3235
|
+
(function _getUniqueName() {
|
|
3236
|
+
try {
|
|
3237
|
+
const name2 = _generateTmpName(sanitizedOptions);
|
|
3238
|
+
fs16.stat(name2, function(err2) {
|
|
3239
|
+
if (!err2) {
|
|
3240
|
+
if (tries-- > 0) return _getUniqueName();
|
|
3241
|
+
return cb(new Error("Could not get a unique tmp filename, max tries reached " + name2));
|
|
3242
|
+
}
|
|
3243
|
+
cb(null, name2);
|
|
3244
|
+
});
|
|
3245
|
+
} catch (err2) {
|
|
3246
|
+
cb(err2);
|
|
3247
|
+
}
|
|
3248
|
+
})();
|
|
3249
|
+
});
|
|
3252
3250
|
}
|
|
3253
3251
|
function tmpNameSync(options) {
|
|
3254
3252
|
const args = _parseArguments(options), opts = args[0];
|
|
3255
|
-
|
|
3256
|
-
let tries =
|
|
3253
|
+
const sanitizedOptions = _assertAndSanitizeOptionsSync(opts);
|
|
3254
|
+
let tries = sanitizedOptions.tries;
|
|
3257
3255
|
do {
|
|
3258
|
-
const name2 = _generateTmpName(
|
|
3256
|
+
const name2 = _generateTmpName(sanitizedOptions);
|
|
3259
3257
|
try {
|
|
3260
3258
|
fs16.statSync(name2);
|
|
3261
3259
|
} catch (e) {
|
|
@@ -3285,7 +3283,7 @@ var require_tmp = __commonJS({
|
|
|
3285
3283
|
const args = _parseArguments(options), opts = args[0];
|
|
3286
3284
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
3287
3285
|
const name2 = tmpNameSync(opts);
|
|
3288
|
-
|
|
3286
|
+
let fd = fs16.openSync(name2, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
3289
3287
|
if (opts.discardDescriptor) {
|
|
3290
3288
|
fs16.closeSync(fd);
|
|
3291
3289
|
fd = void 0;
|
|
@@ -3392,14 +3390,11 @@ var require_tmp = __commonJS({
|
|
|
3392
3390
|
} catch (e) {
|
|
3393
3391
|
rnd = crypto2.pseudoRandomBytes(howMany);
|
|
3394
3392
|
}
|
|
3395
|
-
for (
|
|
3393
|
+
for (let i = 0; i < howMany; i++) {
|
|
3396
3394
|
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
|
3397
3395
|
}
|
|
3398
3396
|
return value.join("");
|
|
3399
3397
|
}
|
|
3400
|
-
function _isBlank(s) {
|
|
3401
|
-
return s === null || _isUndefined(s) || !s.trim();
|
|
3402
|
-
}
|
|
3403
3398
|
function _isUndefined(obj) {
|
|
3404
3399
|
return typeof obj === "undefined";
|
|
3405
3400
|
}
|
|
@@ -3416,12 +3411,37 @@ var require_tmp = __commonJS({
|
|
|
3416
3411
|
}
|
|
3417
3412
|
return [actualOptions, callback];
|
|
3418
3413
|
}
|
|
3414
|
+
function _resolvePath(name2, tmpDir, cb) {
|
|
3415
|
+
const pathToResolve = path15.isAbsolute(name2) ? name2 : path15.join(tmpDir, name2);
|
|
3416
|
+
fs16.stat(pathToResolve, function(err) {
|
|
3417
|
+
if (err) {
|
|
3418
|
+
fs16.realpath(path15.dirname(pathToResolve), function(err2, parentDir) {
|
|
3419
|
+
if (err2) return cb(err2);
|
|
3420
|
+
cb(null, path15.join(parentDir, path15.basename(pathToResolve)));
|
|
3421
|
+
});
|
|
3422
|
+
} else {
|
|
3423
|
+
fs16.realpath(pathToResolve, cb);
|
|
3424
|
+
}
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
function _resolvePathSync(name2, tmpDir) {
|
|
3428
|
+
const pathToResolve = path15.isAbsolute(name2) ? name2 : path15.join(tmpDir, name2);
|
|
3429
|
+
try {
|
|
3430
|
+
fs16.statSync(pathToResolve);
|
|
3431
|
+
return fs16.realpathSync(pathToResolve);
|
|
3432
|
+
} catch (_err) {
|
|
3433
|
+
const parentDir = fs16.realpathSync(path15.dirname(pathToResolve));
|
|
3434
|
+
return path15.join(parentDir, path15.basename(pathToResolve));
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3419
3437
|
function _generateTmpName(opts) {
|
|
3420
3438
|
const tmpDir = opts.tmpdir;
|
|
3421
|
-
if (!_isUndefined(opts.name))
|
|
3439
|
+
if (!_isUndefined(opts.name)) {
|
|
3422
3440
|
return path15.join(tmpDir, opts.dir, opts.name);
|
|
3423
|
-
|
|
3441
|
+
}
|
|
3442
|
+
if (!_isUndefined(opts.template)) {
|
|
3424
3443
|
return path15.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
3444
|
+
}
|
|
3425
3445
|
const name2 = [
|
|
3426
3446
|
opts.prefix ? opts.prefix : "tmp",
|
|
3427
3447
|
"-",
|
|
@@ -3432,54 +3452,75 @@ var require_tmp = __commonJS({
|
|
|
3432
3452
|
].join("");
|
|
3433
3453
|
return path15.join(tmpDir, opts.dir, name2);
|
|
3434
3454
|
}
|
|
3435
|
-
function
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
|
|
3455
|
+
function _assertOptionsBase(options) {
|
|
3456
|
+
if (!_isUndefined(options.name)) {
|
|
3457
|
+
const name2 = options.name;
|
|
3458
|
+
if (path15.isAbsolute(name2)) throw new Error(`name option must not contain an absolute path, found "${name2}".`);
|
|
3459
|
+
const basename2 = path15.basename(name2);
|
|
3460
|
+
if (basename2 === ".." || basename2 === "." || basename2 !== name2)
|
|
3461
|
+
throw new Error(`name option must not contain a path, found "${name2}".`);
|
|
3462
|
+
}
|
|
3463
|
+
if (!_isUndefined(options.template) && !options.template.match(TEMPLATE_PATTERN)) {
|
|
3464
|
+
throw new Error(`Invalid template, found "${options.template}".`);
|
|
3465
|
+
}
|
|
3466
|
+
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0) {
|
|
3448
3467
|
throw new Error(`Invalid tries, found "${options.tries}".`);
|
|
3468
|
+
}
|
|
3449
3469
|
options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1;
|
|
3450
3470
|
options.keep = !!options.keep;
|
|
3451
3471
|
options.detachDescriptor = !!options.detachDescriptor;
|
|
3452
3472
|
options.discardDescriptor = !!options.discardDescriptor;
|
|
3453
3473
|
options.unsafeCleanup = !!options.unsafeCleanup;
|
|
3454
|
-
options.dir = _isUndefined(options.dir) ? "" : path15.relative(tmpDir, _resolvePath(options.dir, tmpDir));
|
|
3455
|
-
options.template = _isUndefined(options.template) ? void 0 : path15.relative(tmpDir, _resolvePath(options.template, tmpDir));
|
|
3456
|
-
options.template = _isBlank(options.template) ? void 0 : path15.relative(options.dir, options.template);
|
|
3457
|
-
options.name = _isUndefined(options.name) ? void 0 : options.name;
|
|
3458
3474
|
options.prefix = _isUndefined(options.prefix) ? "" : options.prefix;
|
|
3459
3475
|
options.postfix = _isUndefined(options.postfix) ? "" : options.postfix;
|
|
3460
3476
|
}
|
|
3461
|
-
function
|
|
3462
|
-
if (name2
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3477
|
+
function _getRelativePath(option, name2, tmpDir, cb) {
|
|
3478
|
+
if (_isUndefined(name2)) return cb(null);
|
|
3479
|
+
_resolvePath(name2, tmpDir, function(err, resolvedPath) {
|
|
3480
|
+
if (err) return cb(err);
|
|
3481
|
+
const relativePath = path15.relative(tmpDir, resolvedPath);
|
|
3482
|
+
if (!resolvedPath.startsWith(tmpDir)) {
|
|
3483
|
+
return cb(new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`));
|
|
3484
|
+
}
|
|
3485
|
+
cb(null, relativePath);
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
function _getRelativePathSync(option, name2, tmpDir) {
|
|
3489
|
+
if (_isUndefined(name2)) return;
|
|
3490
|
+
const resolvedPath = _resolvePathSync(name2, tmpDir);
|
|
3491
|
+
const relativePath = path15.relative(tmpDir, resolvedPath);
|
|
3492
|
+
if (!resolvedPath.startsWith(tmpDir)) {
|
|
3493
|
+
throw new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`);
|
|
3466
3494
|
}
|
|
3495
|
+
return relativePath;
|
|
3467
3496
|
}
|
|
3468
|
-
function
|
|
3469
|
-
|
|
3470
|
-
if (
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
if (path15.isAbsolute(name2) && !name2.startsWith(tmpDir)) {
|
|
3477
|
-
throw new Error(`${option} option must be relative to "${tmpDir}", found "${name2}".`);
|
|
3497
|
+
function _assertAndSanitizeOptions(options, cb) {
|
|
3498
|
+
_getTmpDir(options, function(err, tmpDir) {
|
|
3499
|
+
if (err) return cb(err);
|
|
3500
|
+
options.tmpdir = tmpDir;
|
|
3501
|
+
try {
|
|
3502
|
+
_assertOptionsBase(options, tmpDir);
|
|
3503
|
+
} catch (err2) {
|
|
3504
|
+
return cb(err2);
|
|
3478
3505
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3506
|
+
_getRelativePath("dir", options.dir, tmpDir, function(err2, dir2) {
|
|
3507
|
+
if (err2) return cb(err2);
|
|
3508
|
+
options.dir = _isUndefined(dir2) ? "" : dir2;
|
|
3509
|
+
_getRelativePath("template", options.template, tmpDir, function(err3, template) {
|
|
3510
|
+
if (err3) return cb(err3);
|
|
3511
|
+
options.template = template;
|
|
3512
|
+
cb(null, options);
|
|
3513
|
+
});
|
|
3514
|
+
});
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
function _assertAndSanitizeOptionsSync(options) {
|
|
3518
|
+
const tmpDir = options.tmpdir = _getTmpDirSync(options);
|
|
3519
|
+
_assertOptionsBase(options, tmpDir);
|
|
3520
|
+
const dir2 = _getRelativePathSync("dir", options.dir, tmpDir);
|
|
3521
|
+
options.dir = _isUndefined(dir2) ? "" : dir2;
|
|
3522
|
+
options.template = _getRelativePathSync("template", options.template, tmpDir);
|
|
3523
|
+
return options;
|
|
3483
3524
|
}
|
|
3484
3525
|
function _isEBADF(error) {
|
|
3485
3526
|
return _isExpectedError(error, -EBADF, "EBADF");
|
|
@@ -3493,15 +3534,18 @@ var require_tmp = __commonJS({
|
|
|
3493
3534
|
function setGracefulCleanup() {
|
|
3494
3535
|
_gracefulCleanup = true;
|
|
3495
3536
|
}
|
|
3496
|
-
function _getTmpDir(options) {
|
|
3497
|
-
return
|
|
3537
|
+
function _getTmpDir(options, cb) {
|
|
3538
|
+
return fs16.realpath(options && options.tmpdir || os2.tmpdir(), cb);
|
|
3539
|
+
}
|
|
3540
|
+
function _getTmpDirSync(options) {
|
|
3541
|
+
return fs16.realpathSync(options && options.tmpdir || os2.tmpdir());
|
|
3498
3542
|
}
|
|
3499
3543
|
process.addListener(EXIT, _garbageCollector);
|
|
3500
3544
|
Object.defineProperty(module.exports, "tmpdir", {
|
|
3501
3545
|
enumerable: true,
|
|
3502
3546
|
configurable: false,
|
|
3503
3547
|
get: function() {
|
|
3504
|
-
return
|
|
3548
|
+
return _getTmpDirSync();
|
|
3505
3549
|
}
|
|
3506
3550
|
});
|
|
3507
3551
|
module.exports.dir = dir;
|
|
@@ -6473,6 +6517,30 @@ function normalizeIdentifier(identifier) {
|
|
|
6473
6517
|
return String.fromCharCode(parseInt(unicodeEscape.slice(2), 16));
|
|
6474
6518
|
});
|
|
6475
6519
|
}
|
|
6520
|
+
function getEndLocation(text) {
|
|
6521
|
+
let line = 1;
|
|
6522
|
+
let column = 1;
|
|
6523
|
+
for (let i = 0; i < text.length; i++) {
|
|
6524
|
+
const char = text[i];
|
|
6525
|
+
if (char === "\n") {
|
|
6526
|
+
line++;
|
|
6527
|
+
column = 1;
|
|
6528
|
+
} else if (char === "\r") {
|
|
6529
|
+
if (text[i + 1] === "\n") {
|
|
6530
|
+
i++;
|
|
6531
|
+
}
|
|
6532
|
+
line++;
|
|
6533
|
+
column = 1;
|
|
6534
|
+
} else {
|
|
6535
|
+
column++;
|
|
6536
|
+
}
|
|
6537
|
+
}
|
|
6538
|
+
return {
|
|
6539
|
+
line,
|
|
6540
|
+
column,
|
|
6541
|
+
offset: text.length
|
|
6542
|
+
};
|
|
6543
|
+
}
|
|
6476
6544
|
function getStringValue(value, token, json5 = false) {
|
|
6477
6545
|
let result = "";
|
|
6478
6546
|
let escapeIndex = value.indexOf("\\");
|
|
@@ -6838,6 +6906,7 @@ function parse(text, options) {
|
|
|
6838
6906
|
if (unexpectedToken) {
|
|
6839
6907
|
throw new UnexpectedToken(tokenizer.token);
|
|
6840
6908
|
}
|
|
6909
|
+
const textEndLocation = getEndLocation(text);
|
|
6841
6910
|
const docParts = {
|
|
6842
6911
|
loc: {
|
|
6843
6912
|
start: {
|
|
@@ -6846,7 +6915,7 @@ function parse(text, options) {
|
|
|
6846
6915
|
offset: 0
|
|
6847
6916
|
},
|
|
6848
6917
|
end: {
|
|
6849
|
-
...
|
|
6918
|
+
...textEndLocation
|
|
6850
6919
|
}
|
|
6851
6920
|
}
|
|
6852
6921
|
};
|