mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add eslint-scope
This commit is contained in:
parent
423ace8fe7
commit
77cbc856a7
41
types/eslint-scope/eslint-scope-tests.ts
Normal file
41
types/eslint-scope/eslint-scope-tests.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import * as eslint from "eslint";
|
||||
import * as estree from "estree";
|
||||
import * as escope from "eslint-scope";
|
||||
|
||||
declare const program: estree.Program;
|
||||
declare const scope: escope.Scope;
|
||||
declare const variable: escope.Variable;
|
||||
declare const reference: escope.Reference;
|
||||
|
||||
const manager1: escope.ScopeManager = escope.analyze(
|
||||
program,
|
||||
{
|
||||
directive: false,
|
||||
ecmaVersion: 2018,
|
||||
fallback(node) {
|
||||
return Object.keys(node);
|
||||
},
|
||||
ignoreEval: true,
|
||||
impliedStrict: true,
|
||||
nodejsScope: true,
|
||||
optimistic: true,
|
||||
sourceType: "module"
|
||||
}
|
||||
);
|
||||
const manager2: escope.ScopeManager = escope.analyze(
|
||||
program,
|
||||
{
|
||||
ecmaVersion: 5,
|
||||
ignoreEval: false,
|
||||
impliedStrict: false,
|
||||
nodejsScope: false,
|
||||
optimistic: false,
|
||||
sourceType: "script"
|
||||
}
|
||||
);
|
||||
const manager3: escope.ScopeManager = escope.analyze(program);
|
||||
|
||||
const managerInterface: eslint.Scope.ScopeManager = manager1;
|
||||
const scopeInterface: eslint.Scope.Scope = scope;
|
||||
const variableInterface: eslint.Scope.Variable = variable;
|
||||
const referenceInterface: eslint.Scope.Reference = reference;
|
||||
64
types/eslint-scope/index.d.ts
vendored
Normal file
64
types/eslint-scope/index.d.ts
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Type definitions for eslint-scope 3.7
|
||||
// Project: http://github.com/eslint/eslint-scope
|
||||
// Definitions by: Toru Nagashima <https://github.com/mysticatea>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
import * as eslint from "eslint";
|
||||
import * as estree from "estree";
|
||||
|
||||
export const version: string;
|
||||
|
||||
export class ScopeManager implements eslint.Scope.ScopeManager {
|
||||
scopes: Scope[];
|
||||
globalScope: Scope;
|
||||
acquire(node: {}, inner?: boolean): Scope | null;
|
||||
getDeclaredVariables(node: {}): Variable[];
|
||||
}
|
||||
|
||||
export class Scope implements eslint.Scope.Scope {
|
||||
type: "block" | "catch" | "class" | "for" | "function" | "function-expression-name" | "global" | "module" | "switch" | "with" | "TDZ";
|
||||
isStrict: boolean;
|
||||
upper: Scope | null;
|
||||
childScopes: Scope[];
|
||||
variableScope: Scope;
|
||||
block: estree.Node;
|
||||
variables: Variable[];
|
||||
set: Map<string, Variable>;
|
||||
references: Reference[];
|
||||
through: Reference[];
|
||||
functionExpressionScope: boolean;
|
||||
}
|
||||
|
||||
export class Variable implements eslint.Scope.Variable {
|
||||
name: string;
|
||||
identifiers: estree.Identifier[];
|
||||
references: Reference[];
|
||||
defs: eslint.Scope.Definition[];
|
||||
}
|
||||
|
||||
export class Reference implements eslint.Scope.Reference {
|
||||
identifier: estree.Identifier;
|
||||
from: Scope;
|
||||
resolved: Variable | null;
|
||||
writeExpr: estree.Node | null;
|
||||
init: boolean;
|
||||
|
||||
isWrite(): boolean;
|
||||
isRead(): boolean;
|
||||
isWriteOnly(): boolean;
|
||||
isReadOnly(): boolean;
|
||||
isReadWrite(): boolean;
|
||||
}
|
||||
|
||||
export interface AnalysisOptions {
|
||||
optimistic?: boolean;
|
||||
directive?: boolean;
|
||||
ignoreEval?: boolean;
|
||||
nodejsScope?: boolean;
|
||||
impliedStrict?: boolean;
|
||||
fallback?: string | ((node: {}) => string[]);
|
||||
sourceType?: "script" | "module";
|
||||
ecmaVersion?: number;
|
||||
}
|
||||
|
||||
export function analyze(ast: {}, options?: AnalysisOptions): ScopeManager;
|
||||
23
types/eslint-scope/tsconfig.json
Normal file
23
types/eslint-scope/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"eslint-scope-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/eslint-scope/tslint.json
Normal file
1
types/eslint-scope/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user