Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@typescript-eslint/scope-manager
Advanced tools
The @typescript-eslint/scope-manager package is part of the TypeScript ESLint project. It is used to generate TypeScript-aware scope information for ESLint. This scope information is essential for linting TypeScript codebases, as it understands TypeScript-specific features like types and interfaces, which are not present in regular JavaScript.
Scope Analysis
The package analyzes the scope of variables and types within TypeScript code. It helps in identifying where variables are defined and how they are being used, which is crucial for linting and avoiding errors like variable shadowing or undeclared variables.
N/A
TypeScript-specific Scope Handling
It extends ESLint's scope analysis capabilities to understand TypeScript-specific constructs such as interfaces, types, and enums, which are not part of the standard JavaScript language.
N/A
Integration with ESLint
The scope manager is designed to work seamlessly with ESLint, allowing developers to use ESLint's rule set for TypeScript code. It provides the necessary scope information to ESLint rules so they can operate on TypeScript code as they would on JavaScript code.
N/A
eslint-scope is a package that performs scope analysis for JavaScript code. It is used by ESLint to determine the variables and their references within the code. Unlike @typescript-eslint/scope-manager, it does not have built-in support for TypeScript-specific features.
ts-morph is a TypeScript compiler API wrapper that provides an easier way to interact with the TypeScript compiler. It includes features for analyzing and manipulating TypeScript code, which can be used for tasks similar to scope analysis. However, it is a more general-purpose tool and not specifically tailored for ESLint integration.
typescript-eslint-parser is a parser that allows ESLint to lint TypeScript code. It is an older package that has been deprecated in favor of @typescript-eslint/parser, which works in conjunction with @typescript-eslint/scope-manager to provide linting capabilities for TypeScript code.
This is a fork of eslint-scope
, enhanced to support TypeScript functionality.
You can view the original licence for the code here.
This package is consumed automatically by @typescript-eslint/parser
.
You probably don't want to use it directly.
You can find our Getting Started docs here
$ yarn add -D typescript @typescript-eslint/scope-manager
$ npm i --save-dev typescript @typescript-eslint/scope-manager
analyze(tree, options)
Analyses a given AST and returns the resulting ScopeManager
.
interface AnalyzeOptions {
/**
* Known visitor keys.
*/
childVisitorKeys?: Record<string, string[]> | null;
/**
* Which ECMAScript version is considered.
* Defaults to `2018`.
*/
ecmaVersion?: EcmaVersion;
/**
* Whether the whole script is executed under node.js environment.
* When enabled, the scope manager adds a function scope immediately following the global scope.
* Defaults to `false`.
*/
globalReturn?: boolean;
/**
* Implied strict mode (if ecmaVersion >= 5).
* Defaults to `false`.
*/
impliedStrict?: boolean;
/**
* The identifier that's used for JSX Element creation (after transpilation).
* This should not be a member expression - just the root identifier (i.e. use "React" instead of "React.createElement").
* Defaults to `"React"`.
*/
jsxPragma?: string;
/**
* The identifier that's used for JSX fragment elements (after transpilation).
* If `null`, assumes transpilation will always use a member on `jsxFactory` (i.e. React.Fragment).
* This should not be a member expression - just the root identifier (i.e. use "h" instead of "h.Fragment").
* Defaults to `null`.
*/
jsxFragmentName?: string | null;
/**
* The lib used by the project.
* This automatically defines a type variable for any types provided by the configured TS libs.
* For more information, see https://www.typescriptlang.org/tsconfig#lib
*
* Defaults to the lib for the provided `ecmaVersion`.
*/
lib?: Lib[];
/**
* The source type of the script.
*/
sourceType?: 'script' | 'module';
}
Example usage:
import { analyze } from '@typescript-eslint/scope-manager';
import { parse } from '@typescript-eslint/typescript-estree';
const code = `const hello: string = 'world';`;
const ast = parse(code, {
// note that scope-manager requires ranges on the AST
range: true,
});
const scope = analyze(ast, {
ecmaVersion: 2020,
sourceType: 'module',
});
FAQs
TypeScript scope analyser for ESLint
The npm package @typescript-eslint/scope-manager receives a total of 31,881,709 weekly downloads. As such, @typescript-eslint/scope-manager popularity was classified as popular.
We found that @typescript-eslint/scope-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.