Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/esquery
Advanced tools
TypeScript definitions for esquery
@types/esquery provides TypeScript type definitions for the esquery library, which is used to query and match nodes in an ESTree-compliant AST (Abstract Syntax Tree). This package allows developers to use esquery with TypeScript, ensuring type safety and better development experience.
Querying AST Nodes
This feature allows you to query AST nodes using CSS-like selectors. In the example, it finds all Identifier nodes with the name 'myFunction' that are direct children of FunctionDeclaration nodes.
const esquery = require('esquery');
const ast = /* some ESTree-compliant AST */;
const matches = esquery(ast, 'FunctionDeclaration > Identifier[name="myFunction"]');
console.log(matches);
Complex Queries
This feature supports complex queries using pseudo-classes. In the example, it finds all FunctionDeclaration nodes that have an Identifier child node with the name 'myFunction'.
const esquery = require('esquery');
const ast = /* some ESTree-compliant AST */;
const matches = esquery(ast, 'FunctionDeclaration:has(Identifier[name="myFunction"])');
console.log(matches);
Combining Selectors
This feature allows combining multiple selectors to match different types of nodes. In the example, it finds all FunctionDeclaration and VariableDeclaration nodes in the AST.
const esquery = require('esquery');
const ast = /* some ESTree-compliant AST */;
const matches = esquery(ast, 'FunctionDeclaration, VariableDeclaration');
console.log(matches);
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. It can be extended with custom rules and plugins, and it uses an AST to analyze code. While ESLint is primarily focused on linting, it also provides an API for working with ASTs, similar to esquery.
babel-eslint is a parser that allows ESLint to lint all valid Babel code. It converts Babel's AST into an ESTree-compliant AST, which can then be queried using tools like esquery. It is useful for projects using Babel to transform their code.
Acorn is a small, fast, JavaScript-based JavaScript parser. It produces an ESTree-compliant AST, which can be queried using esquery. Acorn is focused on parsing and does not provide querying capabilities out of the box, but it can be used in conjunction with esquery.
npm install --save @types/esquery
This package contains type definitions for esquery (https://github.com/jrfeenst/esquery).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/esquery.
These definitions were written by cherryblossom000, Brad Zacher, and Brett Zamir.
FAQs
TypeScript definitions for esquery
The npm package @types/esquery receives a total of 112,961 weekly downloads. As such, @types/esquery popularity was classified as popular.
We found that @types/esquery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.