From 3e712a34cb4fca323d48ca5d627fa846947cacde Mon Sep 17 00:00:00 2001 From: Brie <723547+brieb@users.noreply.github.com> Date: Wed, 9 Jan 2019 15:51:32 -0800 Subject: [PATCH] [jscodeshift] Fix lints --- types/jscodeshift/index.d.ts | 46 +++++++++++++++-------------------- types/jscodeshift/tslint.json | 9 ++++++- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/types/jscodeshift/index.d.ts b/types/jscodeshift/index.d.ts index 3e91d382ba..391b4a4f13 100644 --- a/types/jscodeshift/index.d.ts +++ b/types/jscodeshift/index.d.ts @@ -119,7 +119,7 @@ declare module "jscodeshift/src/template" { export default function withParser(parser: Parser): Template; - export {}; // force module + export {}; // to shut off automatic exporting } declare module "jscodeshift/src/Collection" { @@ -131,7 +131,7 @@ declare module "jscodeshift/src/Collection" { type Type = typeof recast.types.Type; type ASTPath = NodePath; - interface Collection + export interface Collection extends NodeCollection.TraversalMethods, NodeCollection.MutationMethods, VariableDeclarator.GlobalMethods, @@ -144,32 +144,32 @@ declare module "jscodeshift/src/Collection" { * @param types An array of types all the paths in the collection * have in common. If not passed, it will be inferred from the paths. */ - new (paths: ASTPath[], parent: Collection, types?: Type[]): this; + new (paths: Array>, parent: Collection, types?: Type[]): this; /** * Returns a new collection containing the nodes for which the callback returns true. */ filter( - callback: (path: ASTPath, i: number, paths: ASTPath[]) => path is ASTPath + callback: (path: ASTPath, i: number, paths: Array>) => path is ASTPath ): Collection; filter( - callback: (path: ASTPath, i: number, paths: ASTPath[]) => boolean + callback: (path: ASTPath, i: number, paths: Array>) => boolean ): Collection; /** * Executes callback for each node/path in the collection. */ - forEach(callback: (path: ASTPath, i: number, paths: ASTPath[]) => void): this; + forEach(callback: (path: ASTPath, i: number, paths: Array>) => void): this; /** * Tests whether at-least one path passes the test implemented by the provided callback. */ - some(callback: (path: ASTPath, i: number, paths: ASTPath[]) => boolean): boolean; + some(callback: (path: ASTPath, i: number, paths: Array>) => boolean): boolean; /** * Tests whether all paths pass the test implemented by the provided callback. */ - every(callback: (path: ASTPath, i: number, paths: ASTPath[]) => boolean): boolean; + every(callback: (path: ASTPath, i: number, paths: Array>) => boolean): boolean; /** * Executes the callback for every path in the collection and returns a new @@ -188,8 +188,8 @@ declare module "jscodeshift/src/Collection" { callback: ( path: ASTPath, i: number, - paths: ASTPath[] - ) => ASTPath | ASTPath[] | null | undefined, + paths: Array> + ) => ASTPath | Array> | null | undefined, type: Type ): Collection; @@ -203,9 +203,9 @@ declare module "jscodeshift/src/Collection" { nodes(): N[]; /** Returns an array of ASTPaths in this this collection. */ - paths(): ASTPath[]; + paths(): Array>; - getAST(): ASTPath[]; + getAST(): Array>; /** * Converts the AST back to a string, using recast. @@ -222,7 +222,7 @@ declare module "jscodeshift/src/Collection" { at(index: number): Collection; /** Calls "get" on the first path (same as "collection.paths(0).get(...)"). */ - get(...fields: (string | number)[]): T; + get(...fields: Array): any; /** * Returns the type(s) of the collection. This is only used for unit tests, @@ -245,6 +245,8 @@ declare module "jscodeshift/src/Collection" { * @param type Optional type to add the methods to */ export function registerMethods(methods: object, type?: Type): void; + + export {}; // to shut off automatic exporting } declare module "jscodeshift/src/collections/Node" { @@ -255,9 +257,7 @@ declare module "jscodeshift/src/collections/Node" { /** * Find nodes of a specific type within the nodes of this collection. */ - find(type: Type): Collection; - find(type: Type, filter: (value: any) => boolean): Collection; - find(type: Type, filter: object): Collection; + find(type: Type, filter?: ((value: any) => boolean) | object): Collection; /** * Returns a collection containing the paths that create the scope of the @@ -277,7 +277,7 @@ declare module "jscodeshift/src/collections/Node" { * * If the callback returns a falsey value, the element is skipped. */ - getVariableDeclarators(nameGetter: Function): Collection; + getVariableDeclarators(nameGetter: (...args: any[]) => any): Collection; } export interface MutationMethods { @@ -285,22 +285,16 @@ declare module "jscodeshift/src/collections/Node" { * Simply replaces the selected nodes with the provided node. If a function * is provided it is executed for every node and the node is replaced with the * functions return value. - * - * @param {Node|Array|function} nodes */ replaceWith(nodes: T | T[] | ((path: any, i: number) => T)): this; /** * Inserts a new node before the current one. - * - * @param {Node|Array|function} insert */ insertBefore(insert: any): Collection; /** * Inserts a new node after the current one. - * - * @param {Node|Array|function} insert */ insertAfter(insert: any): Collection; @@ -309,7 +303,7 @@ declare module "jscodeshift/src/collections/Node" { export function register(): void; - export {}; // force module + export {}; // to shut off automatic exporting } declare module "jscodeshift/src/collections/VariableDeclarator" { @@ -352,7 +346,7 @@ declare module "jscodeshift/src/collections/VariableDeclarator" { export function register(): void; export const filters: FilterMethods; - export {}; // force module + export {}; // to shut off automatic exporting } declare module "jscodeshift/src/collections/JSXElement" { @@ -425,5 +419,5 @@ declare module "jscodeshift/src/collections/JSXElement" { export const filters: FilterMethods; export const mappings: MappingMethods; - export {}; // force module + export {}; // to shut off automatic exporting } diff --git a/types/jscodeshift/tslint.json b/types/jscodeshift/tslint.json index 3db14f85ea..94991f356f 100644 --- a/types/jscodeshift/tslint.json +++ b/types/jscodeshift/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-declare-current-package": false, + "no-self-import": false, + "no-unnecessary-generics": false + } +}