Skip to content

Commit

Permalink
Merge branch 'master' into fix-module-boundary-types
Browse files Browse the repository at this point in the history
  • Loading branch information
mijay committed Jan 21, 2020
2 parents 617067a + 77a1caa commit 9cc9f3d
Show file tree
Hide file tree
Showing 13 changed files with 12,534 additions and 1,341 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/README.md
Expand Up @@ -11,7 +11,7 @@
## Getting Started

**[You can find our Getting Started docs here](../../docs/getting-started/linting/README.md)**
**[You can find our FAQ / Troubleshooting docs here](./docs/getting-started/linting/FAQ.md)**
**[You can find our FAQ / Troubleshooting docs here](../../docs/getting-started/linting/FAQ.md)**

These docs walk you through setting up ESLint, this plugin, and our parser. If you know what you're doing and just want to quick start, read on...

Expand Down
17 changes: 16 additions & 1 deletion packages/experimental-utils/src/ts-eslint-scope/Reference.ts
Expand Up @@ -3,21 +3,36 @@ import ESLintReference from 'eslint-scope/lib/reference';
import { Scope } from './Scope';
import { Variable } from './Variable';

export type ReferenceFlag = 0x1 | 0x2 | 0x3;

interface Reference {
identifier: TSESTree.Identifier;
from: Scope;
resolved: Variable | null;
writeExpr: TSESTree.Node | null;
init: boolean;

partial: boolean;
__maybeImplicitGlobal: boolean;
tainted?: boolean;
typeMode?: boolean;

isWrite(): boolean;
isRead(): boolean;
isWriteOnly(): boolean;
isReadOnly(): boolean;
isReadWrite(): boolean;
}
const Reference = ESLintReference as {
new (): Reference;
new (
identifier: TSESTree.Identifier,
scope: Scope,
flag?: ReferenceFlag,
writeExpr?: TSESTree.Node | null,
maybeImplicitGlobal?: boolean,
partial?: boolean,
init?: boolean,
): Reference;

READ: 0x1;
WRITE: 0x2;
Expand Down
4 changes: 2 additions & 2 deletions packages/experimental-utils/src/ts-eslint-scope/Referencer.ts
Expand Up @@ -44,8 +44,8 @@ interface Referencer<SM extends ScopeManager> extends Visitor {

AssignmentExpression(node: TSESTree.Node): void;
CatchClause(node: TSESTree.Node): void;
Program(node: TSESTree.Node): void;
Identifier(node: TSESTree.Node): void;
Program(node: TSESTree.Program): void;
Identifier(node: TSESTree.Identifier): void;
UpdateExpression(node: TSESTree.Node): void;
MemberExpression(node: TSESTree.Node): void;
Property(node: TSESTree.Node): void;
Expand Down
26 changes: 14 additions & 12 deletions packages/experimental-utils/src/ts-eslint-scope/Scope.ts
Expand Up @@ -15,7 +15,7 @@ import {
ClassScope as ESLintClassScope,
} from 'eslint-scope/lib/scope';
import { Definition } from './Definition';
import { Reference } from './Reference';
import { Reference, ReferenceFlag } from './Reference';
import { ScopeManager } from './ScopeManager';
import { Variable } from './Variable';

Expand Down Expand Up @@ -46,35 +46,37 @@ interface Scope {
references: Reference[];
through: Reference[];
thisFound?: boolean;
taints: Map<string, boolean>;
functionExpressionScope: boolean;
__left: Reference[];

__shouldStaticallyClose(scopeManager: ScopeManager): boolean;
__shouldStaticallyCloseForGlobal(ref: any): boolean;
__staticCloseRef(ref: any): void;
__dynamicCloseRef(ref: any): void;
__globalCloseRef(ref: any): void;
__close(scopeManager: ScopeManager): Scope;
__isValidResolution(ref: any, variable: any): boolean;
__resolve(ref: any): boolean;
__isValidResolution(ref: any, variable: any): variable is Variable;
__resolve(ref: Reference): boolean;
__delegateToUpperScope(ref: any): void;
__addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void;
__defineGeneric(
name: any,
set: any,
variables: any,
node: any,
name: string,
set: Map<string, Variable>,
variables: Variable[],
node: TSESTree.Identifier,
def: Definition,
): void;

__define(node: TSESTree.Node, def: Definition): void;

__referencing(
node: TSESTree.Node,
assign: number,
writeExpr: TSESTree.Node,
maybeImplicitGlobal: any,
partial: any,
init: any,
assign?: ReferenceFlag,
writeExpr?: TSESTree.Node,
maybeImplicitGlobal?: any,
partial?: any,
init?: any,
): void;

__detectEval(): void;
Expand Down
Expand Up @@ -16,6 +16,9 @@ interface ScopeManagerOptions {
interface ScopeManager {
__options: ScopeManagerOptions;
__currentScope: Scope;
__nodeToScope: WeakMap<TSESTree.Node, Scope[]>;
__declaredVariables: WeakMap<TSESTree.Node, Variable[]>;

scopes: Scope[];
globalScope: Scope;

Expand All @@ -28,15 +31,15 @@ interface ScopeManager {
isStrictModeSupported(): boolean;

// Returns appropriate scope for this node.
__get(node: TSESTree.Node): Scope;
__get(node: TSESTree.Node): Scope | undefined;
getDeclaredVariables(node: TSESTree.Node): Variable[];
acquire(node: TSESTree.Node, inner?: boolean): Scope | null;
acquireAll(node: TSESTree.Node): Scope | null;
release(node: TSESTree.Node, inner?: boolean): Scope | null;
attach(): void;
detach(): void;

__nestScope(scope: Scope): Scope;
__nestScope<T extends Scope>(scope: T): T;
__nestGlobalScope(node: TSESTree.Node): Scope;
__nestBlockScope(node: TSESTree.Node): Scope;
__nestFunctionScope(node: TSESTree.Node, isMethodDefinition: boolean): Scope;
Expand Down
4 changes: 4 additions & 0 deletions packages/experimental-utils/src/ts-eslint-scope/Variable.ts
Expand Up @@ -2,13 +2,17 @@ import { TSESTree } from '@typescript-eslint/typescript-estree';
import ESLintVariable from 'eslint-scope/lib/variable';
import { Reference } from './Reference';
import { Definition } from './Definition';
import { Scope } from './Scope';

interface Variable {
name: string;
identifiers: TSESTree.Identifier[];
references: Reference[];
defs: Definition[];
eslintUsed?: boolean;
stack?: unknown;
tainted?: boolean;
scope?: Scope;
}

const Variable = ESLintVariable as {
Expand Down

0 comments on commit 9cc9f3d

Please sign in to comment.