Skip to content

Commit cd5f3a6

Browse files
committed
enable @typescript-eslint/space-before-function-paren
1 parent 6d72185 commit cd5f3a6

File tree

9 files changed

+26
-19
lines changed

9 files changed

+26
-19
lines changed

.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
"semi": "off",
4141
"@typescript-eslint/semi": "error",
4242

43+
"space-before-function-paren": "off",
44+
"@typescript-eslint/space-before-function-paren": ["error", {
45+
"asyncArrow": "always",
46+
"anonymous": "always",
47+
"named": "never"
48+
}],
49+
4350
"@typescript-eslint/triple-slash-reference": "error",
4451
"@typescript-eslint/type-annotation-spacing": "error",
4552
"@typescript-eslint/unified-signatures": "error",

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23216,7 +23216,7 @@ namespace ts {
2321623216
return true;
2321723217
}
2321823218

23219-
function getThisParameterFromNodeContext (node: Node) {
23219+
function getThisParameterFromNodeContext(node: Node) {
2322023220
const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false);
2322123221
return thisContainer && isFunctionLike(thisContainer) ? getThisParameter(thisContainer) : undefined;
2322223222
}

src/harness/harnessUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace Utils {
5454
export function memoize<T extends ts.AnyFunction>(f: T, memoKey: (...anything: any[]) => string): T {
5555
const cache = ts.createMap<any>();
5656

57-
return <any>(function(this: any, ...args: any[]) {
57+
return <any>(function (this: any, ...args: any[]) {
5858
const key = memoKey(...args);
5959
if (cache.has(key)) {
6060
return cache.get(key);
@@ -395,4 +395,4 @@ namespace Utils {
395395
function isHarness(line: string) {
396396
return /[\\/]src[\\/]harness[\\/]|[\\/]run\.js/.test(line);
397397
}
398-
}
398+
}

src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ts.codefix {
3333
return Debug.assertDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)), "There should be a containing class");
3434
}
3535

36-
function symbolPointsToNonPrivateMember (symbol: Symbol) {
36+
function symbolPointsToNonPrivateMember(symbol: Symbol) {
3737
return !symbol.valueDeclaration || !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private);
3838
}
3939

@@ -83,7 +83,7 @@ namespace ts.codefix {
8383
}
8484
}
8585

86-
function getHeritageClauseSymbolTable (classDeclaration: ClassLikeDeclaration, checker: TypeChecker): SymbolTable {
86+
function getHeritageClauseSymbolTable(classDeclaration: ClassLikeDeclaration, checker: TypeChecker): SymbolTable {
8787
const heritageClauseNode = getEffectiveBaseTypeNode(classDeclaration);
8888
if (!heritageClauseNode) return createSymbolTable();
8989
const heritageClauseType = checker.getTypeAtLocation(heritageClauseNode) as InterfaceType;

src/services/codefixes/fixSpelling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace ts.codefix {
9292
return flags;
9393
}
9494

95-
function getResolvedSourceFileFromImportDeclaration (sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined {
95+
function getResolvedSourceFileFromImportDeclaration(sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined {
9696
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined;
9797

9898
const resolvedModule = getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text);

src/services/codefixes/fixStrictClassInitialization.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ namespace ts.codefix {
4747
},
4848
});
4949

50-
function getPropertyDeclaration (sourceFile: SourceFile, pos: number): PropertyDeclaration | undefined {
50+
function getPropertyDeclaration(sourceFile: SourceFile, pos: number): PropertyDeclaration | undefined {
5151
const token = getTokenAtPosition(sourceFile, pos);
5252
return isIdentifier(token) ? cast(token.parent, isPropertyDeclaration) : undefined;
5353
}
5454

55-
function getActionForAddMissingDefiniteAssignmentAssertion (context: CodeFixContext, propertyDeclaration: PropertyDeclaration): CodeFixAction {
55+
function getActionForAddMissingDefiniteAssignmentAssertion(context: CodeFixContext, propertyDeclaration: PropertyDeclaration): CodeFixAction {
5656
const changes = textChanges.ChangeTracker.with(context, t => addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration));
5757
return createCodeFixAction(fixName, changes, [Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
5858
}
@@ -70,7 +70,7 @@ namespace ts.codefix {
7070
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
7171
}
7272

73-
function getActionForAddMissingUndefinedType (context: CodeFixContext, propertyDeclaration: PropertyDeclaration): CodeFixAction {
73+
function getActionForAddMissingUndefinedType(context: CodeFixContext, propertyDeclaration: PropertyDeclaration): CodeFixAction {
7474
const changes = textChanges.ChangeTracker.with(context, t => addUndefinedType(t, context.sourceFile, propertyDeclaration));
7575
return createCodeFixAction(fixName, changes, [Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
7676
}
@@ -91,7 +91,7 @@ namespace ts.codefix {
9191
return createCodeFixAction(fixName, changes, [Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, Diagnostics.Add_initializers_to_all_uninitialized_properties);
9292
}
9393

94-
function addInitializer (changeTracker: textChanges.ChangeTracker, propertyDeclarationSourceFile: SourceFile, propertyDeclaration: PropertyDeclaration, initializer: Expression): void {
94+
function addInitializer(changeTracker: textChanges.ChangeTracker, propertyDeclarationSourceFile: SourceFile, propertyDeclaration: PropertyDeclaration, initializer: Expression): void {
9595
const property = updateProperty(
9696
propertyDeclaration,
9797
propertyDeclaration.decorators,
@@ -108,7 +108,7 @@ namespace ts.codefix {
108108
return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type!)); // TODO: GH#18217
109109
}
110110

111-
function getDefaultValueFromType (checker: TypeChecker, type: Type): Expression | undefined {
111+
function getDefaultValueFromType(checker: TypeChecker, type: Type): Expression | undefined {
112112
if (type.flags & TypeFlags.BooleanLiteral) {
113113
return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? createFalse() : createTrue();
114114
}

src/services/refactors/generateGetAccessorAndSetAccessor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
8787
return { renameFilename, renameLocation, edits };
8888
}
8989

90-
function isConvertibleName (name: DeclarationName): name is AcceptedNameType {
90+
function isConvertibleName(name: DeclarationName): name is AcceptedNameType {
9191
return isIdentifier(name) || isStringLiteral(name);
9292
}
9393

9494
function isAcceptedDeclaration(node: Node): node is AcceptedDeclaration {
9595
return isParameterPropertyDeclaration(node, node.parent) || isPropertyDeclaration(node) || isPropertyAssignment(node);
9696
}
9797

98-
function createPropertyName (name: string, originalName: AcceptedNameType) {
98+
function createPropertyName(name: string, originalName: AcceptedNameType) {
9999
return isIdentifier(originalName) ? createIdentifier(name) : createLiteral(name);
100100
}
101101

102-
function createAccessorAccessExpression (fieldName: AcceptedNameType, isStatic: boolean, container: ContainerDeclaration) {
102+
function createAccessorAccessExpression(fieldName: AcceptedNameType, isStatic: boolean, container: ContainerDeclaration) {
103103
const leftHead = isStatic ? (<ClassLikeDeclaration>container).name! : createThis(); // TODO: GH#18217
104104
return isIdentifier(fieldName) ? createPropertyAccess(leftHead, fieldName) : createElementAccess(leftHead, createLiteral(fieldName));
105105
}

src/testRunner/externalCompileRunner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Harness {
3030

3131
// eslint-disable-next-line @typescript-eslint/no-this-alias
3232
const cls = this;
33-
describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) {
33+
describe(`${this.kind()} code samples`, function (this: Mocha.ISuiteCallbackContext) {
3434
this.timeout(600_000); // 10 minutes
3535
for (const test of testList) {
3636
cls.runTest(typeof test === "string" ? test : test.file);
@@ -41,7 +41,7 @@ namespace Harness {
4141
// eslint-disable-next-line @typescript-eslint/no-this-alias
4242
const cls = this;
4343
const timeout = 600_000; // 10 minutes
44-
describe(directoryName, function(this: Mocha.ISuiteCallbackContext) {
44+
describe(directoryName, function (this: Mocha.ISuiteCallbackContext) {
4545
this.timeout(timeout);
4646
const cp: typeof import("child_process") = require("child_process");
4747

@@ -123,7 +123,7 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
123123

124124
// eslint-disable-next-line @typescript-eslint/no-this-alias
125125
const cls = this;
126-
describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) {
126+
describe(`${this.kind()} code samples`, function (this: Mocha.ISuiteCallbackContext) {
127127
this.timeout(cls.timeout); // 20 minutes
128128
before(() => {
129129
cls.exec("docker", ["build", ".", "-t", "typescript/typescript"], { cwd: IO.getWorkspaceRoot() }); // cached because workspace is hashed to determine cacheability

src/testRunner/rwcRunner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace RWC {
4747
caseSensitive = false;
4848
});
4949

50-
it("can compile", function(this: Mocha.ITestCallbackContext) {
50+
it("can compile", function (this: Mocha.ITestCallbackContext) {
5151
this.timeout(800_000); // Allow long timeouts for RWC compilations
5252
let opts!: ts.ParsedCommandLine;
5353

@@ -145,7 +145,7 @@ namespace RWC {
145145
});
146146

147147

148-
it("has the expected emitted code", function(this: Mocha.ITestCallbackContext) {
148+
it("has the expected emitted code", function (this: Mocha.ITestCallbackContext) {
149149
this.timeout(100_000); // Allow longer timeouts for RWC js verification
150150
Harness.Baseline.runMultifileBaseline(baseName, "", () => {
151151
return Harness.Compiler.iterateOutputs(compilerResult.js.values());

0 commit comments

Comments
 (0)