Socket
Socket
Sign inDemoInstall

eslint-utils

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

132

index.js

@@ -243,2 +243,4 @@ /*! @author Toru Nagashima <https://github.com/mysticatea> */

/* globals BigInt */
const builtinNames = Object.freeze(

@@ -248,2 +250,5 @@ new Set([

"ArrayBuffer",
"BigInt",
"BigInt64Array",
"BigUint64Array",
"Boolean",

@@ -256,5 +261,3 @@ "DataView",

"encodeURIComponent",
"Error",
"escape",
"EvalError",
"Float32Array",

@@ -280,4 +283,2 @@ "Float64Array",

"Proxy",
"RangeError",
"ReferenceError",
"Reflect",

@@ -288,4 +289,2 @@ "RegExp",

"Symbol",
"SyntaxError",
"TypeError",
"Uint16Array",

@@ -297,3 +296,2 @@ "Uint32Array",

"unescape",
"URIError",
"WeakMap",

@@ -303,4 +301,80 @@ "WeakSet",

);
const callAllowed = new Set(
[
Array.isArray,
typeof BigInt === "function" ? BigInt : undefined,
Boolean,
Date,
Date.parse,
decodeURI,
decodeURIComponent,
encodeURI,
encodeURIComponent,
escape,
isFinite,
isNaN,
isPrototypeOf,
...Object.getOwnPropertyNames(Math)
.map(k => Math[k])
.filter(f => typeof f === "function"),
Number,
Number.isFinite,
Number.isNaN,
Number.parseFloat,
Number.parseInt,
Object,
Object.entries, //eslint-disable-line @mysticatea/node/no-unsupported-features/es-builtins
Object.is,
Object.isExtensible,
Object.isFrozen,
Object.isSealed,
Object.keys,
Object.values, //eslint-disable-line @mysticatea/node/no-unsupported-features/es-builtins
parseFloat,
parseInt,
RegExp,
String,
String.fromCharCode,
String.fromCodePoint,
String.raw,
Symbol,
Symbol.for,
Symbol.keyFor,
unescape,
].filter(f => typeof f === "function")
);
const callPassThrough = new Set([
Object.freeze,
Object.preventExtensions,
Object.seal,
]);
/**
* Get the property descriptor.
* @param {object} object The object to get.
* @param {string|number|symbol} name The property name to get.
*/
function getPropertyDescriptor(object, name) {
let x = object;
while ((typeof x === "object" || typeof x === "function") && x !== null) {
const d = Object.getOwnPropertyDescriptor(x, name);
if (d) {
return d
}
x = Object.getPrototypeOf(x);
}
return null
}
/**
* Check if a property is getter or not.
* @param {object} object The object to check.
* @param {string|number|symbol} name The property name to check.
*/
function isGetter(object, name) {
const d = getPropertyDescriptor(object, name);
return d != null && d.get != null
}
/**
* Get the element values of a given node list.

@@ -423,3 +497,8 @@ * @param {Node[]} nodeList The node list to get values.

const methodName = property.value;
return { value: receiver[methodName](...args) }
if (callAllowed.has(receiver[methodName])) {
return { value: receiver[methodName](...args) }
}
if (callPassThrough.has(receiver[methodName])) {
return { value: args[0] }
}
}

@@ -430,3 +509,8 @@ } else {

const func = callee.value;
return { value: func(...args) }
if (callAllowed.has(func)) {
return { value: func(...args) }
}
if (callPassThrough.has(func)) {
return { value: args[0] }
}
}

@@ -485,7 +569,7 @@ }

//istanbul ignore if : this is implementation-specific behavior.
if (node.regex != null && node.value == null) {
// It was a RegExp literal, but Node.js didn't support it.
if ((node.regex != null || node.bigint != null) && node.value == null) {
// It was a RegExp/BigInt literal, but Node.js didn't support it.
return null
}
return node
return { value: node.value }
},

@@ -518,3 +602,7 @@

if (object != null && property != null) {
if (
object != null &&
property != null &&
!isGetter(object.value, property.value)
) {
return { value: object.value[property.value] }

@@ -531,3 +619,5 @@ }

const Func = callee.value;
return { value: new Func(...args) }
if (callAllowed.has(Func)) {
return { value: new Func(...args) }
}
}

@@ -591,3 +681,5 @@

return { value: func(strings, ...expressions) }
if (func === String.raw) {
return { value: func(strings, ...expressions) }
}
}

@@ -676,2 +768,12 @@

function getStringIfConstant(node, initialScope = null) {
// Handle the literals that the platform doesn't support natively.
if (node.type === "Literal" && node.value === null) {
if (node.regex) {
return `/${node.regex.pattern}/${node.regex.flags}`
}
if (node.bigint) {
return node.bigint
}
}
const evaluated = getStaticValue(node, initialScope);

@@ -678,0 +780,0 @@ return evaluated && String(evaluated.value)

2

package.json
{
"name": "eslint-utils",
"version": "1.4.0",
"version": "1.4.1",
"description": "Utilities for ESLint plugins.",

@@ -5,0 +5,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc