diff --git a/src/rules/typedefRule.ts b/src/rules/typedefRule.ts index f2e2557b6a4..318085e0559 100644 --- a/src/rules/typedefRule.ts +++ b/src/rules/typedefRule.ts @@ -20,6 +20,37 @@ import * as ts from "typescript"; import * as Lint from "../index"; +interface Options { + "call-signature"?: boolean; + "arrow-call-signature"?: boolean; + parameter?: boolean; + "arrow-parameter"?: boolean; + "property-declaration"?: boolean; + "variable-declaration"?: boolean; + "member-variable-declaration"?: boolean; + "object-destructuring"?: boolean; + "array-destructuring"?: boolean; +} +type Option = keyof Options; + +const OPTION_CALL_SIGNATURE: Option = "call-signature"; +const OPTION_ARROW_CALL_SIGNATURE: Option = "arrow-call-signature"; +const OPTION_PARAMETER: Option = "parameter"; +const OPTION_ARROW_PARAMETER: Option = "arrow-parameter"; +const OPTION_PROPERTY_DECLARATION: Option = "property-declaration"; +const OPTION_VARIABLE_DECLARATION: Option = "variable-declaration"; +const OPTION_MEMBER_VARIABLE_DECLARATION: Option = "member-variable-declaration"; +const OPTION_OBJECT_DESTRUCTURING: Option = "object-destructuring"; +const OPTION_ARRAY_DESTRUCTURING: Option = "array-destructuring"; + +function parseOptions(ruleArguments: Option[]) { + const options: Options = {}; + for (const arg of ruleArguments) { + options[arg] = true; + } + return options; +} + export class Rule extends Lint.Rules.AbstractRule { /* tslint:disable:object-literal-sort-keys */ public static metadata: Lint.IRuleMetadata = { @@ -28,230 +59,157 @@ export class Rule extends Lint.Rules.AbstractRule { optionsDescription: Lint.Utils.dedent` Several arguments may be optionally provided: - * \`"call-signature"\` checks return type of functions. - * \`"arrow-call-signature"\` checks return type of arrow functions. - * \`"parameter"\` checks type specifier of function parameters for non-arrow functions. - * \`"arrow-parameter"\` checks type specifier of function parameters for arrow functions. - * \`"property-declaration"\` checks return types of interface properties. - * \`"variable-declaration"\` checks non-binding variable declarations. - * \`"member-variable-declaration"\` checks member variable declarations. - * \`"object-destructuring"\` checks object destructuring declarations. - * \`"array-destructuring"\` checks array destructuring declarations.`, + * \`"${OPTION_CALL_SIGNATURE}"\` checks return type of functions. + * \`"${OPTION_ARROW_CALL_SIGNATURE}"\` checks return type of arrow functions. + * \`"${OPTION_PARAMETER}"\` checks type specifier of function parameters for non-arrow functions. + * \`"${OPTION_ARROW_PARAMETER}"\` checks type specifier of function parameters for arrow functions. + * \`"${OPTION_PROPERTY_DECLARATION}"\` checks return types of interface properties. + * \`"${OPTION_VARIABLE_DECLARATION}"\` checks non-binding variable declarations. + * \`"${OPTION_MEMBER_VARIABLE_DECLARATION}"\` checks member variable declarations. + * \`"${OPTION_OBJECT_DESTRUCTURING}"\` checks object destructuring declarations. + * \`"${OPTION_ARRAY_DESTRUCTURING}"\` checks array destructuring declarations.`, options: { type: "array", items: { type: "string", enum: [ - "call-signature", - "arrow-call-signature", - "parameter", - "arrow-parameter", - "property-declaration", - "variable-declaration", - "member-variable-declaration", - "object-destructuring", - "array-destructuring", + OPTION_CALL_SIGNATURE, + OPTION_ARROW_CALL_SIGNATURE, + OPTION_PARAMETER, + OPTION_ARROW_PARAMETER, + OPTION_PROPERTY_DECLARATION, + OPTION_VARIABLE_DECLARATION, + OPTION_MEMBER_VARIABLE_DECLARATION, + OPTION_OBJECT_DESTRUCTURING, + OPTION_ARRAY_DESTRUCTURING, ], }, minLength: 0, maxLength: 7, }, - optionExamples: [[true, "call-signature", "parameter", "member-variable-declaration"]], + optionExamples: [[true, OPTION_CALL_SIGNATURE, OPTION_PARAMETER, OPTION_MEMBER_VARIABLE_DECLARATION]], type: "typescript", typescriptOnly: true, }; /* tslint:enable:object-literal-sort-keys */ - public static FAILURE_STRING = "missing type declaration"; - public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new TypedefWalker(sourceFile, this.getOptions())); + return this.applyWithWalker(new TypedefWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments))); } } -class TypedefWalker extends Lint.RuleWalker { - public visitFunctionDeclaration(node: ts.FunctionDeclaration) { - this.handleCallSignature(node); - super.visitFunctionDeclaration(node); - } - - public visitFunctionExpression(node: ts.FunctionExpression) { - this.handleCallSignature(node); - super.visitFunctionExpression(node); - } - - public visitArrowFunction(node: ts.ArrowFunction) { - const location = (node.parameters != null) ? node.parameters.end : null; - - if (location != null - && node.parent !== undefined - && node.parent.kind !== ts.SyntaxKind.CallExpression - && !isTypedPropertyDeclaration(node.parent)) { - - this.checkTypeAnnotation("arrow-call-signature", location, node.type, node.name); - } - super.visitArrowFunction(node); - } - - public visitGetAccessor(node: ts.AccessorDeclaration) { - this.handleCallSignature(node); - super.visitGetAccessor(node); - } - - public visitMethodDeclaration(node: ts.MethodDeclaration) { - this.handleCallSignature(node); - super.visitMethodDeclaration(node); - } - - public visitMethodSignature(node: ts.SignatureDeclaration) { - this.handleCallSignature(node); - super.visitMethodSignature(node); - } - - public visitObjectLiteralExpression(node: ts.ObjectLiteralExpression) { - for (const property of node.properties) { - switch (property.kind) { - case ts.SyntaxKind.PropertyAssignment: - this.visitPropertyAssignment(property as ts.PropertyAssignment); - break; +class TypedefWalker extends Lint.AbstractWalker { + public walk(sourceFile: ts.SourceFile): void { + const cb = (node: ts.Node): void => { + switch (node.kind) { + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.FunctionExpression: + case ts.SyntaxKind.GetAccessor: case ts.SyntaxKind.MethodDeclaration: - this.visitMethodDeclaration(property as ts.MethodDeclaration); + case ts.SyntaxKind.MethodSignature: { + const { name, parameters, type } = node as ts.CallSignatureDeclaration; + this.checkTypeAnnotation("call-signature", name !== undefined ? name : parameters, type, name); break; - case ts.SyntaxKind.GetAccessor: - this.visitGetAccessor(property as ts.AccessorDeclaration); + } + case ts.SyntaxKind.ArrowFunction: + this.checkArrowFunction(node as ts.ArrowFunction); break; - case ts.SyntaxKind.SetAccessor: - this.visitSetAccessor(property as ts.AccessorDeclaration); + case ts.SyntaxKind.Parameter: + this.checkParameter(node as ts.ParameterDeclaration); break; - default: + case ts.SyntaxKind.PropertyDeclaration: + this.checkPropertyDeclaration(node as ts.PropertyDeclaration); + break; + case ts.SyntaxKind.PropertySignature: { + const { name, type } = node as ts.PropertySignature; + this.checkTypeAnnotation("property-declaration", name, type, name); + break; + } + case ts.SyntaxKind.VariableDeclaration: + this.checkVariableDeclaration(node as ts.VariableDeclaration); break; } - } + + return ts.forEachChild(node, cb); + }; + + return ts.forEachChild(sourceFile, cb); } - public visitParameterDeclaration(node: ts.ParameterDeclaration) { - // a parameter's "type" could be a specific string value, for example `fn(option: "someOption", anotherOption: number)` - if ((node.type == null || node.type.kind !== ts.SyntaxKind.StringLiteral) - && node.parent !== undefined - && node.parent.parent !== undefined) { + private checkArrowFunction({ parent, parameters, type }: ts.ArrowFunction): void { + if (parent!.kind !== ts.SyntaxKind.CallExpression && !isTypedPropertyDeclaration(parent!)) { + this.checkTypeAnnotation("arrow-call-signature", parameters, type); + } + } - const isArrowFunction = node.parent.kind === ts.SyntaxKind.ArrowFunction; + private checkParameter({ parent, name, type }: ts.ParameterDeclaration): void { + const isArrowFunction = parent!.kind === ts.SyntaxKind.ArrowFunction; - let optionName: string | null = null; - if (isArrowFunction && isTypedPropertyDeclaration(node.parent.parent)) { - // leave optionName as null and don't perform check - } else if (isArrowFunction && utils.isPropertyDeclaration(node.parent.parent)) { - optionName = "member-variable-declaration"; - } else if (isArrowFunction) { - optionName = "arrow-parameter"; + const option = (() => { + if (!isArrowFunction) { + return "parameter"; + } else if (isTypedPropertyDeclaration(parent!.parent!)) { + return undefined; + } else if (utils.isPropertyDeclaration(parent!.parent!)) { + return "member-variable-declaration"; } else { - optionName = "parameter"; + return "arrow-parameter"; } + })(); - if (optionName !== null) { - this.checkTypeAnnotation(optionName, node.getEnd(), node.type as ts.TypeNode, node.name); - } + if (option !== undefined) { + this.checkTypeAnnotation(option, name, type, name); } - super.visitParameterDeclaration(node); } - public visitPropertyAssignment(node: ts.PropertyAssignment) { - super.visitPropertyAssignment(node); - } - - public visitPropertyDeclaration(node: ts.PropertyDeclaration) { - const optionName = "member-variable-declaration"; - + private checkPropertyDeclaration({ initializer, name, type }: ts.PropertyDeclaration): void { // If this is an arrow function, it doesn't need to have a typedef on the property declaration // as the typedefs can be on the function's parameters instead - const performCheck = !(node.initializer != null && node.initializer.kind === ts.SyntaxKind.ArrowFunction && node.type == null); - - if (performCheck) { - this.checkTypeAnnotation(optionName, node.name.getEnd(), node.type, node.name); + if (initializer === undefined || initializer.kind !== ts.SyntaxKind.ArrowFunction) { + this.checkTypeAnnotation("member-variable-declaration", name, type, name); } - super.visitPropertyDeclaration(node); - } - - public visitPropertySignature(node: ts.PropertyDeclaration) { - const optionName = "property-declaration"; - this.checkTypeAnnotation(optionName, node.name.getEnd(), node.type, node.name); - super.visitPropertySignature(node); } - public visitSetAccessor(node: ts.AccessorDeclaration) { - this.handleCallSignature(node); - super.visitSetAccessor(node); - } - - public visitVariableDeclaration(node: ts.VariableDeclaration) { + private checkVariableDeclaration({ parent, name, type }: ts.VariableDeclaration): void { // variable declarations should always have a grandparent, but check that to be on the safe side. // catch statements will be the parent of the variable declaration // for-in/for-of loops will be the gradparent of the variable declaration - if (node.parent != null && node.parent.parent != null - && (node as ts.Node).parent!.kind !== ts.SyntaxKind.CatchClause - && node.parent.parent.kind !== ts.SyntaxKind.ForInStatement - && node.parent.parent.kind !== ts.SyntaxKind.ForOfStatement) { + if (parent!.kind === ts.SyntaxKind.CatchClause + || parent!.parent!.kind === ts.SyntaxKind.ForInStatement + || parent!.parent!.kind === ts.SyntaxKind.ForOfStatement) { + return; + } - let rule: string; - switch (node.name.kind) { + const option = (() => { + switch (name.kind) { case ts.SyntaxKind.ObjectBindingPattern: - rule = "object-destructuring"; - break; + return "object-destructuring"; case ts.SyntaxKind.ArrayBindingPattern: - rule = "array-destructuring"; - break; + return "array-destructuring"; default: - rule = "variable-declaration"; - break; + return "variable-declaration"; } + })(); - this.checkTypeAnnotation(rule, node.name.getEnd(), node.type, node.name); - } - super.visitVariableDeclaration(node); + this.checkTypeAnnotation(option, name, type, name); } - private handleCallSignature(node: ts.SignatureDeclaration) { - const location = (node.parameters != null) ? node.parameters.end : null; - // set accessors can't have a return type. - if (location != null && node.kind !== ts.SyntaxKind.SetAccessor && node.kind !== ts.SyntaxKind.ArrowFunction) { - this.checkTypeAnnotation("call-signature", location, node.type, node.name); - } - } - - private checkTypeAnnotation(option: string, - location: number, - typeAnnotation: ts.TypeNode | undefined, - name?: ts.Node) { - if (this.hasOption(option) && typeAnnotation == null) { - this.addFailureAt(location, 1, `expected ${option}${getName(name, ": '", "'")} to have a typedef`); - } - } -} - -function getName(name?: ts.Node, prefix = "", suffix = ""): string { - let ns = ""; - - if (name != null) { - switch (name.kind) { - case ts.SyntaxKind.Identifier: - ns = (name as ts.Identifier).text; - break; - case ts.SyntaxKind.BindingElement: - ns = getName((name as ts.BindingElement).name); - break; - case ts.SyntaxKind.ArrayBindingPattern: - ns = `[ ${(name as ts.ArrayBindingPattern).elements.map( (n) => getName(n) ).join(", ")} ]`; - break; - case ts.SyntaxKind.ObjectBindingPattern: - ns = `{ ${(name as ts.ObjectBindingPattern).elements.map( (n) => getName(n) ).join(", ")} }`; - break; - default: - break; + private checkTypeAnnotation( + option: Option, + location: ts.Node | ts.NodeArray, + typeAnnotation: ts.TypeNode | undefined, + name?: ts.Node): void { + if (this.options[option] === true && typeAnnotation === undefined) { + const failure = `expected ${option}${name === undefined ? "" : `: '${name.getText()}'`} to have a typedef`; + if (Array.isArray(location)) { + this.addFailure(location.pos - 1, location.end + 1, failure); + } else { + this.addFailureAtNode(location, failure); + } } } - return ns === "" ? "" : `${prefix}${ns}${suffix}`; } function isTypedPropertyDeclaration(node: ts.Node): boolean { - return utils.isPropertyDeclaration(node) && node.type != null; + return utils.isPropertyDeclaration(node) && node.type !== undefined; } diff --git a/test/rules/typedef/all/test.ts.lint b/test/rules/typedef/all/test.ts.lint index 909f6c4b981..e4079e66d46 100644 --- a/test/rules/typedef/all/test.ts.lint +++ b/test/rules/typedef/all/test.ts.lint @@ -4,67 +4,65 @@ try { } var NoTypeObjectLiteralWithPropertyGetter = { - ~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] Prop: "some property", get PropDef() { - ~ [expected call-signature: 'PropDef' to have a typedef] + ~~~~~~~ [expected call-signature: 'PropDef' to have a typedef] return this.Prop; }, methodDef() { - ~ [expected call-signature: 'methodDef' to have a typedef] + ~~~~~~~~~ [expected call-signature: 'methodDef' to have a typedef] return 'untyped'; }, anotherMethodDef: function() { - ~ [expected call-signature to have a typedef] + ~~ [expected call-signature to have a typedef] return 'also untyped'; }, arrowMethodDef: () => { - ~ [expected arrow-call-signature to have a typedef] + ~~ [expected arrow-call-signature to have a typedef] return 'also untyped'; } }; interface NoTypeInterface { Prop; - ~ [expected property-declaration: 'Prop' to have a typedef] + ~~~~ [expected property-declaration: 'Prop' to have a typedef] PropWithType: string; } -var NoTypesFn = function ( - ~ [expected variable-declaration: 'NoTypesFn' to have a typedef] - a, - ~ [expected parameter: 'a' to have a typedef] - b) { - ~ [expected call-signature to have a typedef] - ~ [expected parameter: 'b' to have a typedef] +var NoTypesFn = function (a, b) { + ~~~~~~~~~ [expected variable-declaration: 'NoTypesFn' to have a typedef] + ~ [expected parameter: 'a' to have a typedef] + ~ [expected parameter: 'b' to have a typedef] + ~~~~~~ [expected call-signature to have a typedef] var c = a + b, - ~ [expected variable-declaration: 'c' to have a typedef] + ~ [expected variable-declaration: 'c' to have a typedef] d = a - b; - ~ [expected variable-declaration: 'd' to have a typedef] + ~ [expected variable-declaration: 'd' to have a typedef] class TsLint { helloWorld() { - ~ [expected call-signature: 'helloWorld' to have a typedef] + ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] return 'Hello World'; }; regularMemberWithType: string = this.getValue(); regularMemberWithoutType = this.getValue(); - ~ [expected member-variable-declaration: 'regularMemberWithoutType' to have a typedef] + ~~~~~~~~~~~~~~~~~~~~~~~~ [expected member-variable-declaration: 'regularMemberWithoutType' to have a typedef] arrowHelloWorld = () => { - ~ [expected arrow-call-signature to have a typedef] + ~~ [expected arrow-call-signature to have a typedef] return this.helloWorld(); }; arrowHelloWorldWithArgsNoTypedef = (arg1) => { - ~ [expected member-variable-declaration: 'arg1' to have a typedef] - ~ [expected arrow-call-signature to have a typedef] + ~~~~ [expected member-variable-declaration: 'arg1' to have a typedef] + ~~~~~~ [expected arrow-call-signature to have a typedef] return this.helloWorld(); }; @@ -79,28 +77,28 @@ class TsLint { setTimeout(() => {}, 1000); setTimeout(function() {}, 1000); - ~ [expected call-signature to have a typedef] + ~~ [expected call-signature to have a typedef] someFunc(n => n+1); - ~ [expected arrow-parameter: 'n' to have a typedef] + ~ [expected arrow-parameter: 'n' to have a typedef] someFunc(n => {}); - ~ [expected arrow-parameter: 'n' to have a typedef] + ~ [expected arrow-parameter: 'n' to have a typedef] class A { // property w/o an initializer public foo; - ~ [expected member-variable-declaration: 'foo' to have a typedef] + ~~~ [expected member-variable-declaration: 'foo' to have a typedef] private bar: number; } const { paramA, paramB } = { paramA: "test", paramB: 15 }; - ~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] + ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; const [ paramA, paramB ] = [15, 'test']; - ~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] + ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] const [ paramA3, paramB3 ]: [ number, string ] = [15, 'test']; diff --git a/test/rules/typedef/array-destructuring/test.ts.lint b/test/rules/typedef/array-destructuring/test.ts.lint index 840f1b72518..2781fce8f6a 100644 --- a/test/rules/typedef/array-destructuring/test.ts.lint +++ b/test/rules/typedef/array-destructuring/test.ts.lint @@ -1,4 +1,4 @@ const [ paramA, paramB ] = [15, 'test']; - ~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] + ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] const [ paramA3, paramB3 ]: { number: string, paramB1: string } = [15, 'test']; diff --git a/test/rules/typedef/arrow-call-signature/test.ts.lint b/test/rules/typedef/arrow-call-signature/test.ts.lint index 1e8a63f9432..2daafd0702a 100644 --- a/test/rules/typedef/arrow-call-signature/test.ts.lint +++ b/test/rules/typedef/arrow-call-signature/test.ts.lint @@ -6,7 +6,7 @@ class TsLint { }; arrowHelloWorld = () => { - ~ [expected arrow-call-signature to have a typedef] + ~~ [expected arrow-call-signature to have a typedef] return this.helloWorld(); }; } @@ -14,7 +14,7 @@ class TsLint { var obj = { foge: function() {}, bar: () => {} - ~ [expected arrow-call-signature to have a typedef] + ~~ [expected arrow-call-signature to have a typedef] } setTimeout(() => {}, 1000); diff --git a/test/rules/typedef/arrow-parameter/test.ts.lint b/test/rules/typedef/arrow-parameter/test.ts.lint index 5d083fe7834..3f72ea65885 100644 --- a/test/rules/typedef/arrow-parameter/test.ts.lint +++ b/test/rules/typedef/arrow-parameter/test.ts.lint @@ -1,5 +1,5 @@ var NoTypesFn = function (a, b) {} var NoTypesArrowFn = (a, b) => {} - ~ [expected arrow-parameter: 'a' to have a typedef] - ~ [expected arrow-parameter: 'b' to have a typedef] + ~ [expected arrow-parameter: 'a' to have a typedef] + ~ [expected arrow-parameter: 'b' to have a typedef] diff --git a/test/rules/typedef/call-signature/test.ts.lint b/test/rules/typedef/call-signature/test.ts.lint index c4d3dff263f..fe695835056 100644 --- a/test/rules/typedef/call-signature/test.ts.lint +++ b/test/rules/typedef/call-signature/test.ts.lint @@ -1,9 +1,9 @@ function foge() {} - ~ [expected call-signature: 'foge' to have a typedef] + ~~~~ [expected call-signature: 'foge' to have a typedef] class TsLint { helloWorld() { - ~ [expected call-signature: 'helloWorld' to have a typedef] + ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] return 'Hello World'; }; @@ -14,13 +14,13 @@ class TsLint { var obj = { foge: function() {}, - ~ [expected call-signature to have a typedef] + ~~ [expected call-signature to have a typedef] bar: () => {} } setTimeout(() => {}, 1000); setTimeout(function() {}, 1000); - ~ [expected call-signature to have a typedef] + ~~ [expected call-signature to have a typedef] someFunc(n => n+1); someFunc(n => {}); diff --git a/test/rules/typedef/member-variable-declaration/test.ts.lint b/test/rules/typedef/member-variable-declaration/test.ts.lint index 9307da0c01b..a437c7b7d58 100644 --- a/test/rules/typedef/member-variable-declaration/test.ts.lint +++ b/test/rules/typedef/member-variable-declaration/test.ts.lint @@ -12,5 +12,5 @@ class TypesInFunctionWithReturnMemberArrowFn { class NoTypesMemberArrowFn { fn = (param) => {} - ~ [expected member-variable-declaration: 'param' to have a typedef] + ~~~~~ [expected member-variable-declaration: 'param' to have a typedef] } diff --git a/test/rules/typedef/object-destructuring/test.ts.lint b/test/rules/typedef/object-destructuring/test.ts.lint index 9a89039bcc7..8f222db7f6d 100644 --- a/test/rules/typedef/object-destructuring/test.ts.lint +++ b/test/rules/typedef/object-destructuring/test.ts.lint @@ -1,7 +1,4 @@ - - const { paramA, paramB } = { paramA: "test", paramB: 15 }; - ~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] - + ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; diff --git a/test/rules/typedef/parameter/test.ts.lint b/test/rules/typedef/parameter/test.ts.lint index 916d7b24d49..309c04fcc93 100644 --- a/test/rules/typedef/parameter/test.ts.lint +++ b/test/rules/typedef/parameter/test.ts.lint @@ -1,6 +1,6 @@ var NoTypesFn = function (a, b) { - ~ [expected parameter: 'a' to have a typedef] - ~ [expected parameter: 'b' to have a typedef] + ~ [expected parameter: 'a' to have a typedef] + ~ [expected parameter: 'b' to have a typedef] } var NoTypesArrowFn = (a, b) => {} diff --git a/test/rules/typedef/variable-declaration/test.ts.lint b/test/rules/typedef/variable-declaration/test.ts.lint index c1a30f42398..0547e0b2013 100644 --- a/test/rules/typedef/variable-declaration/test.ts.lint +++ b/test/rules/typedef/variable-declaration/test.ts.lint @@ -1,6 +1,5 @@ -var NoTypeObjectLiteralWithPropertyGetter = { } - ~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] - +var v = { } + ~ [expected variable-declaration: 'v' to have a typedef] const { paramA, paramB } = { paramA: "test", paramB: 15 }; const [ paramA, paramB ] = [15, 'test'];