Skip to content

Commit 08c2317

Browse files
Simon Marchipaul-marechal
Simon Marchi
authored andcommitted
Add tsfmt rule to add space before parentheses of anonymous functions
Theia and VSCode format anonymous functions differently: Theia: function() VSCode: function () As people use both tools to edit the Theia code, we constantly get spurious diffs where these are changed back and forth. This patch adds a tsfmt.json (picked up by the typescript language server) to align the Theia behavior on what VSCode does. It also adds a tslint rule and fixes all problematic occurences. Change-Id: I6f1b99a8b53095597e8db2eadb056fa272b5af66 Signed-off-by: Simon Marchi <[email protected]>
1 parent c7b8840 commit 08c2317

File tree

8 files changed

+27
-18
lines changed

8 files changed

+27
-18
lines changed

configs/errors.tslint.json

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
"always",
7272
"ignore-interfaces"
7373
],
74+
"space-before-function-paren": [
75+
true,
76+
{
77+
"anonymous": "always"
78+
}
79+
],
7480
"trailing-comma": false,
7581
"triple-equals": [
7682
true,

examples/browser/test/cpp/cpp-change-build-config.ui-spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int main() {}
100100
*/
101101
function hasClangd() {
102102
try {
103-
const out = cp.execSync('clangd -version', {encoding: 'utf8'});
103+
const out = cp.execSync('clangd -version', { encoding: 'utf8' });
104104
// Match 'clangd version' at the start of
105105
// 'clangd version 8.0.0 (trunk 341484) (llvm/trunk 341481)'.
106106
return out.indexOf('clangd version') === 0;
@@ -124,8 +124,8 @@ function changeBuildConfig(name: string, driver: WebdriverIO.Client<void>) {
124124
driver.pause(300);
125125
}
126126

127-
describe('cpp extension', function() {
128-
it('should be able to change build config', function() {
127+
describe('cpp extension', function () {
128+
it('should be able to change build config', function () {
129129
if (!hasClangd()) {
130130
this.skip();
131131
return;

packages/core/src/browser/preferences/preference-proxy.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import { createPreferenceProxy } from './preference-proxy';
1818
import { MockPreferenceService } from './test/mock-preference-service';
1919
import { expect } from 'chai';
2020

21-
describe('preference proxy', function() {
21+
describe('preference proxy', function () {
2222
/** Verify the return type of the ready property. */
23-
it('.ready should return a promise', function() {
23+
it('.ready should return a promise', function () {
2424

2525
const proxy = createPreferenceProxy(new MockPreferenceService(), {
2626
properties: {}

packages/core/src/node/console-logger-server.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ beforeEach(() => {
4848
server = container.get<ConsoleLoggerServer>(ConsoleLoggerServer);
4949
});
5050

51-
describe('ConsoleLoggerServer', function() {
52-
it('should respect log level config', async function() {
51+
describe('ConsoleLoggerServer', function () {
52+
it('should respect log level config', async function () {
5353
expect(await server.getLogLevel('test-logger')).eq(LogLevel.DEBUG);
5454
await server.child('test-logger');
5555
expect(await server.getLogLevel('test-logger')).eq(LogLevel.DEBUG);

packages/cpp/src/browser/cpp-build-configurations.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { MockPreferenceService } from '@theia/core/lib/browser/preferences/test/
2828

2929
let container: Container;
3030

31-
beforeEach(function() {
31+
beforeEach(function () {
3232
const m = new ContainerModule(bind => {
3333
bind(CppBuildConfigurationManager).to(CppBuildConfigurationManagerImpl).inSingletonScope();
3434
bind(StorageService).to(MockStorageService).inSingletonScope();
@@ -76,8 +76,8 @@ async function initializeTest(buildConfigurations: CppBuildConfiguration[] | und
7676
return configs;
7777
}
7878

79-
describe('build-configurations', function() {
80-
it('should work with no preferences', async function() {
79+
describe('build-configurations', function () {
80+
it('should work with no preferences', async function () {
8181
const cppBuildConfigurations = await initializeTest(undefined, undefined);
8282

8383
const configs = cppBuildConfigurations.getConfigs();
@@ -87,7 +87,7 @@ describe('build-configurations', function() {
8787
expect(configs).lengthOf(0);
8888
});
8989

90-
it('should work with an empty list of builds', async function() {
90+
it('should work with an empty list of builds', async function () {
9191
const cppBuildConfigurations = await initializeTest([], undefined);
9292

9393
const configs = cppBuildConfigurations.getConfigs();
@@ -97,7 +97,7 @@ describe('build-configurations', function() {
9797
expect(configs).lengthOf(0);
9898
});
9999

100-
it('should work with a simple list of builds', async function() {
100+
it('should work with a simple list of builds', async function () {
101101
const builds = [{
102102
name: 'Release',
103103
directory: '/tmp/builds/release',
@@ -115,7 +115,7 @@ describe('build-configurations', function() {
115115
expect(configs).to.have.deep.members(builds);
116116
});
117117

118-
it('should work with a simple list of builds and an active config', async function() {
118+
it('should work with a simple list of builds and an active config', async function () {
119119
const builds = [{
120120
name: 'Release',
121121
directory: '/tmp/builds/release',
@@ -133,7 +133,7 @@ describe('build-configurations', function() {
133133
expect(configs).to.have.deep.members(builds);
134134
});
135135

136-
it("should ignore an active config that doesn't exist", async function() {
136+
it("should ignore an active config that doesn't exist", async function () {
137137
const builds = [{
138138
name: 'Release',
139139
directory: '/tmp/builds/release',

packages/cpp/src/browser/cpp-task-provider.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class MockCppBuildConfigurationManager implements CppBuildConfigurationManager {
6363
ready: Promise<void> = Promise.resolve();
6464
}
6565

66-
beforeEach(function() {
66+
beforeEach(function () {
6767
const container: Container = new Container();
6868
container.bind(CppTaskProvider).toSelf().inSingletonScope();
6969
container.bind(TaskResolverRegistry).toSelf().inSingletonScope();
@@ -80,8 +80,8 @@ beforeEach(function() {
8080
});
8181
});
8282

83-
describe('CppTaskProvider', function() {
84-
it('provide a task for each build config with a build command', async function() {
83+
describe('CppTaskProvider', function () {
84+
it('provide a task for each build config with a build command', async function () {
8585
const tasks = await taskProvider.provideTasks();
8686
expect(tasks).length(1);
8787
expect(tasks[0].config.name === 'Build 1');

packages/workspace/src/browser/workspace-service.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('WorkspaceService', () => {
229229
expect((<sinon.SinonStub>mockILogger.error).called).to.be.true;
230230
});
231231

232-
it('should use the workspace path in the URL fragment, if available', async function() {
232+
it('should use the workspace path in the URL fragment, if available', async function () {
233233
const workspacePath = '/home/somewhere';
234234
window.location.hash = '#' + workspacePath;
235235
const stat = <FileStat>{

tsfmt.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": true
3+
}

0 commit comments

Comments
 (0)