8000 feat(eslint-plugin): update types to allow parameter type inferrence by mohsen1 · Pull Request #272 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

feat(eslint-plugin): update types to allow parameter type inferrence #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/array-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSArrayType(node: TSESTree.TSArrayType) {
TSArrayType(node) {
if (
option === 'array' ||
(option === 'array-simple' && isSimpleType(node.elementType))
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/camelcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
Identifier(node: TSESTree.Identifier) {
Identifier(node) {
/*
* Leading and trailing underscores are commonly used to flag
* private/protected identifiers, strip them
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/generic-type-naming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @fileoverview Enforces naming of generic type variables.
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

type Options = [string?];
Expand Down Expand Up @@ -34,7 +33,7 @@ export default util.createRule<Options, MessageIds>({
const regex = new RegExp(rule!);

return {
TSTypeParameter(node: TSESTree.TSTypeParameter) {
TSTypeParameter(node) {
const name = node.name.name;

if (name && !regex.test(name)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/interface-name-prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Danny Fritz
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

type Options = ['never' | 'always'];
Expand Down Expand Up @@ -45,7 +44,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void {
TSInterfaceDeclaration(node): void {
if (never) {
if (isPrefixedWithI(node.id.name)) {
context.report({
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,28 +353,28 @@ export default util.createRule<Options, MessageIds>({
}

return {
ClassDeclaration(node: TSESTree.ClassDeclaration) {
ClassDeclaration(node) {
validateMembers(
node.body.body,
options.classes || options.default!,
true
);
},
ClassExpression(node: TSESTree.ClassExpression) {
ClassExpression(node) {
validateMembers(
node.body.body,
options.classExpressions || options.default!,
true
);
},
TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration) {
TSInterfaceDeclaration(node) {
validateMembers(
node.body.body,
options.interfaces || options.default!,
false
);
},
TSTypeLiteral(node: TSESTree.TSTypeLiteral) {
TSTypeLiteral(node) {
validateMembers(
node.members,
options.typeLiterals || options.default!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Patricio Trevino
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

export default util.createRule({
Expand All @@ -27,7 +26,7 @@ export default util.createRule({
create(context) {
const sourceCode = context.getSourceCode();
return {
TSTypeAssertion(node: TSESTree.TSTypeAssertion) {
TSTypeAssertion(node) {
context.report({
node,
messageId: 'preferAs',
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/no-empty-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Patricio Trevino
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

type Options = [
Expand Down Expand Up @@ -47,7 +46,7 @@ export default util.createRule<Options, MessageIds>({
],
create(context, [{ allowSingleExtends }]) {
return {
TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration) {
TSInterfaceDeclaration(node) {
if (node.body.body.length !== 0) {
// interface contains members --> Nothing to report
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-extraneous-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default util.createRule<Options, MessageIds>({
],
create(context, [{ allowConstructorOnly, allowEmpty, allowStaticOnly }]) {
return {
ClassBody(node: TSESTree.ClassBody) {
ClassBody(node) {
const parent = node.parent as
| TSESTree.ClassDeclaration
| TSESTree.ClassExpression
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/no-for-in-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Benjamin Lichtman
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import ts from 'typescript';
import * as util from '../util';

Expand All @@ -26,7 +25,7 @@ export default util.createRule({
defaultOptions: [],
create(context) {
return {
ForInStatement(node: TSESTree.ForInStatement) {
ForInStatement(node) {
const parserServices = util.getParserServices(context);
const checker = parserServices.program.getTypeChecker();
const originalNode = parserServices.esTreeNodeToTSNodeMap.get<
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/no-non-null-assertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Macklin Underdown
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

export default util.createRule({
Expand All @@ -25,7 +24,7 @@ export default util.createRule({
defaultOptions: [],
create(context) {
return {
TSNonNullExpression(node: TSESTree.TSNonNullExpression) {
TSNonNullExpression(node) {
context.report({
node,
messageId: 'noNonNull'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSParameterProperty(node: TSESTree.TSParameterProperty) {
TSParameterProperty(node) {
const modifiers = getModifiers(node);

if (allows.indexOf(modifiers) === -1) {
Expand Down
2 changes: 1 addition & 1 delet 10000 ion packages/eslint-plugin/src/rules/no-require-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default util.createRule({
messageId: 'noRequireImports'
});
},
TSExternalModuleReference(node: TSESTree.TSExternalModuleReference) {
TSExternalModuleReference(node) {
context.report({
node,
messageId: 'noRequireImports'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @author Danny Fritz
*/

import { TSESTree } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

export default util.createRule({
Expand All @@ -27,7 +26,7 @@ export default util.createRule({
const sourceCode = context.getSourceCode();

return {
Program(program: TSESTree.Program): void {
Program(program): void {
const commentsBefore = sourceCode.getCommentsBefore(program);

commentsBefore.forEach(comment => {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-type-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSTypeAliasDeclaration(node: TSESTree.TSTypeAliasDeclaration) {
TSTypeAliasDeclaration(node) {
if (isComposition(node.typeAnnotation)) {
validateCompositions(node.typeAnnotation);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ export default util.createRule<Options, MessageIds>({
const checker = parserServices.program.getTypeChecker();

return {
TSNonNullExpression(node: TSESTree.TSNonNullExpression) {
TSNonNullExpression(node) {
checkNonNullAssertion(node, checker);
},
TSTypeAssertion(node: TSESTree.TSTypeAssertion) {
TSTypeAssertion(node) {
verifyCast(node, checker);
},
TSAsExpression(node: TSESTree.TSAsExpression) {
TSAsExpression(node) {
verifyCast(node, checker);
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-useless-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default util.createRule<Options, MessageIds>({
create(context) {
const rules = baseRule.create(context);
return {
MethodDefinition(node: TSESTree.MethodDefinition) {
MethodDefinition(node) {
if (
node.value &&
node.value.type === AST_NODE_TYPES.FunctionExpression &&
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-var-requires.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Macklin Underdown
*/

import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import * as util from '../util';

type Options = [];
Expand All @@ -28,7 +28,7 @@ export default util.createRule<Options, MessageIds>({
defaultOptions: [],
create(context) {
return {
CallExpression(node: TSESTree.CallExpression) {
CallExpression(node) {
if (
node.callee.type === AST_NODE_TYPES.Identifier &&
node.callee.name === 'require' &&
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/prefer-function-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default util.createRule({
}

return {
TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration) {
TSInterfaceDeclaration(node) {
if (!hasOneSupertype(node) && node.body.body.length === 1) {
checkMember(node.body.body[0], node);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import {
AST_NODE_TYPES,
AST_TOKEN_TYPES,
TSESTree
AST_TOKEN_TYPES
} from '@typescript-eslint/typescript-estree';
import * as util from '../util';

Expand All @@ -34,7 +33,7 @@ export default util.createRule({
const sourceCode = context.getSourceCode();

return {
TSModuleDeclaration(node: TSESTree.TSModuleDeclaration) {
TSModuleDeclaration(node) {
// Do nothing if the name is a string.
if (!node.id || node.id.type === AST_NODE_TYPES.Literal) {
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/type-annotation-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSMappedType(node: TSESTree.TSMappedType) {
TSMappedType(node) {
if (node.typeAnnotation) {
checkTypeAnnotationSpacing(node.typeAnnotation);
}
},
TSTypeAnnotation(node: TSESTree.TSTypeAnnotation) {
TSTypeAnnotation(node) {
checkTypeAnnotationSpacing(node.typeAnnotation);
}
};
Expand Down
Loading
0