Skip to content

Commit 2b6a8f2

Browse files
authored
Format ts code using Prettier (#9359)
* Update config files and new entry * Format ts using prettier
1 parent 43d30fd commit 2b6a8f2

File tree

861 files changed

+32981
-31630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

861 files changed

+32981
-31630
lines changed

.eslintrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"no-cond-assign": 0,
1010
"no-unused-vars": 1,
1111
"no-extra-semi": "warn",
12-
"semi": "warn"
12+
"semi": "warn",
13+
"prettier/prettier": "error"
1314
},
14-
"extends": "eslint:recommended"
15+
"extends": ["eslint:recommended", "prettier"],
16+
"plugins": ["prettier"]
1517
}

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"[typescript]": {
3030
"editor.formatOnSave": true
3131
},
32+
"[javascript]": {
33+
"editor.formatOnSave": true
34+
},
3235
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
3336
"tslint.enable": true,
3437
"python.linting.enabled": false,
@@ -38,9 +41,12 @@
3841
"typescript.preferences.quoteStyle": "single",
3942
"javascript.preferences.quoteStyle": "single",
4043
"typescriptHero.imports.stringQuoteStyle": "'",
41-
"prettier.tslintIntegration": true,
4244
"prettier.printWidth": 180,
4345
"prettier.singleQuote": true,
46+
"editor.codeActionsOnSave": {
47+
"source.fixAll.eslint": true,
48+
"source.fixAll.tslint": true
49+
},
4450
"python.jediEnabled": false,
4551
"python.analysis.logLevel": "Trace",
4652
"python.analysis.downloadChannel": "beta",

news/3 Code Health/2012.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use [prettier](https://prettier.io/) as the formatter for `TypeScript` code within the extension.

package-lock.json

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@
10941094
"runtime": "node",
10951095
"variables": {
10961096
"pickProcess": "python.pickLocalProcess"
1097-
},
1097+
},
10981098
"configurationSnippets": [],
10991099
"configurationAttributes": {
11001100
"launch": {
@@ -2892,6 +2892,8 @@
28922892
"electron-download": "^4.1.1",
28932893
"enzyme": "^3.7.0",
28942894
"enzyme-adapter-react-16": "^1.6.0",
2895+
"eslint-config-prettier": "^6.9.0",
2896+
"eslint-plugin-prettier": "^3.1.2",
28952897
"event-stream": "3.3.4",
28962898
"expose-loader": "^0.7.5",
28972899
"extract-zip": "^1.6.7",
@@ -2927,6 +2929,7 @@
29272929
"node-has-native-dependencies": "^1.0.2",
29282930
"node-html-parser": "^1.1.13",
29292931
"nyc": "^14.1.1",
2932+
"prettier": "^1.19.1",
29302933
"raw-loader": "^0.5.1",
29312934
"react": "^16.5.2",
29322935
"react-data-grid": "^6.0.2-0",
@@ -2954,8 +2957,10 @@
29542957
"ts-mockito": "^2.3.1",
29552958
"ts-node": "^8.3.0",
29562959
"tsconfig-paths-webpack-plugin": "^3.2.0",
2960+
"tslint-config-prettier": "^1.18.0",
29572961
"tslint-eslint-rules": "^5.1.0",
29582962
"tslint-microsoft-contrib": "^5.0.3",
2963+
"tslint-plugin-prettier": "^2.1.0",
29592964
"typed-react-markdown": "^0.1.0",
29602965
"typemoq": "^2.1.0",
29612966
"typescript": "^3.7.2",

src/client/activation/aaTesting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IExtensionSingleActivationService } from './types';
1010

1111
@injectable()
1212
export class AATesting implements IExtensionSingleActivationService {
13-
constructor(@inject(IExperimentsManager) private experiments: IExperimentsManager) { }
13+
constructor(@inject(IExperimentsManager) private experiments: IExperimentsManager) {}
1414

1515
public async activate(): Promise<void> {
1616
this.experiments.sendTelemetryIfInExperiment(ValidateABTesting.experiment);

src/client/activation/activationManager.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
2828
@inject(IApplicationDiagnostics) private readonly appDiagnostics: IApplicationDiagnostics,
2929
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
3030
@inject(IActiveResourceService) private readonly activeResourceService: IActiveResourceService
31-
) { }
31+
) {}
3232

3333
public dispose() {
3434
while (this.disposables.length > 0) {
@@ -43,10 +43,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
4343
public async activate(): Promise<void> {
4444
await this.initialize();
4545
// Activate all activation services together.
46-
await Promise.all([
47-
Promise.all(this.singleActivationServices.map(item => item.activate())),
48-
this.activateWorkspace(this.activeResourceService.getActiveResource())
49-
]);
46+
await Promise.all([Promise.all(this.singleActivationServices.map(item => item.activate())), this.activateWorkspace(this.activeResourceService.getActiveResource())]);
5047
await this.autoSelection.autoSelectInterpreter(undefined);
5148
}
5249
@traceDecorators.error('Failed to activate a workspace')

src/client/activation/activationService.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common
1111
import { STANDARD_OUTPUT_CHANNEL } from '../common/constants';
1212
import { LSControl, LSEnabled } from '../common/experimentGroups';
1313
import { traceError } from '../common/logger';
14-
import {
15-
IConfigurationService,
16-
IDisposableRegistry,
17-
IExperimentsManager,
18-
IOutputChannel,
19-
IPersistentStateFactory,
20-
IPythonSettings,
21-
Resource
22-
} from '../common/types';
14+
import { IConfigurationService, IDisposableRegistry, IExperimentsManager, IOutputChannel, IPersistentStateFactory, IPythonSettings, Resource } from '../common/types';
2315
import { swallowExceptions } from '../common/utils/decorators';
2416
import { noop } from '../common/utils/misc';
2517
import { IInterpreterService, PythonInterpreter } from '../interpreter/contracts';
@@ -28,12 +20,7 @@ import { sendTelemetryEvent } from '../telemetry';
2820
import { EventName } from '../telemetry/constants';
2921
import { Commands } from './languageServer/constants';
3022
import { RefCountedLanguageServer } from './refCountedLanguageServer';
31-
import {
32-
IExtensionActivationService,
33-
ILanguageServerActivator,
34-
ILanguageServerCache,
35-
LanguageServerType
36-
} from './types';
23+
import { IExtensionActivationService, ILanguageServerActivator, ILanguageServerCache, LanguageServerType } from './types';
3724

3825
const jediEnabledSetting: keyof IPythonSettings = 'jediEnabled';
3926
const languageServerSetting: keyof IPythonSettings = 'languageServer';
@@ -56,17 +43,16 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
5643
private readonly interpreterService: IInterpreterService;
5744
private resource!: Resource;
5845

59-
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer,
46+
constructor(
47+
@inject(IServiceContainer) private serviceContainer: IServiceContainer,
6048
@inject(IPersistentStateFactory) private stateFactory: IPersistentStateFactory,
61-
@inject(IExperimentsManager) private readonly abExperiments: IExperimentsManager) {
49+
@inject(IExperimentsManager) private readonly abExperiments: IExperimentsManager
50+
) {
6251
this.workspaceService = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
6352
this.interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
6453
this.output = this.serviceContainer.get<OutputChannel>(IOutputChannel, STANDARD_OUTPUT_CHANNEL);
6554
this.appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
66-
this.lsNotSupportedDiagnosticService = this.serviceContainer.get<IDiagnosticsService>(
67-
IDiagnosticsService,
68-
LSNotSupportedDiagnosticServiceId
69-
);
55+
this.lsNotSupportedDiagnosticService = this.serviceContainer.get<IDiagnosticsService>(IDiagnosticsService, LSNotSupportedDiagnosticServiceId);
7056
const commandManager = this.serviceContainer.get<ICommandManager>(ICommandManager);
7157
const disposables = serviceContainer.get<IDisposableRegistry>(IDisposableRegistry);
7258
disposables.push(this);
@@ -154,7 +140,7 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
154140
traceError('WorkspaceConfiguration.inspect returns `undefined` for setting `python.jediEnabled`');
155141
return false;
156142
}
157-
return (settings.globalValue === undefined && settings.workspaceValue === undefined && settings.workspaceFolderValue === undefined);
143+
return settings.globalValue === undefined && settings.workspaceValue === undefined && settings.workspaceFolderValue === undefined;
158144
}
159145

160146
/**
@@ -172,7 +158,7 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
172158
const configurationService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
173159
let enabled = configurationService.getSettings(this.resource).jediEnabled;
174160
const languageServerType = configurationService.getSettings(this.resource).languageServer;
175-
enabled = enabled || (languageServerType === LanguageServerType.Jedi);
161+
enabled = enabled || languageServerType === LanguageServerType.Jedi;
176162
this.sendTelemetryForChosenLanguageServer(enabled).ignoreErrors();
177163
return enabled;
178164
}
@@ -269,8 +255,10 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
269255
const workspacesUris: (Uri | undefined)[] = this.workspaceService.hasWorkspaceFolders
270256
? this.workspaceService.workspaceFolders!.map(workspace => workspace.uri)
271257
: [undefined];
272-
if (workspacesUris.findIndex(uri => event.affectsConfiguration(`python.${jediEnabledSetting}`, uri)) === -1 &&
273-
workspacesUris.findIndex(uri => event.affectsConfiguration(`python.${languageServerSetting}`, uri)) === -1) {
258+
if (
259+
workspacesUris.findIndex(uri => event.affectsConfiguration(`python.${jediEnabledSetting}`, uri)) === -1 &&
260+
workspacesUris.findIndex(uri => event.affectsConfiguration(`python.${languageServerSetting}`, uri)) === -1
261+
) {
274262
return;
275263
}
276264
const jedi = this.useJedi();
@@ -285,10 +273,7 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
285273
}
286274
}
287275

288-
const item = await this.appShell.showInformationMessage(
289-
'Please reload the window switching between language engines.',
290-
'Reload'
291-
);
276+
const item = await this.appShell.showInformationMessage('Please reload the window switching between language engines.', 'Reload');
292277
if (item === 'Reload') {
293278
this.serviceContainer.get<ICommandManager>(ICommandManager).executeCommand('workbench.action.reloadWindow');
294279
}
@@ -302,6 +287,6 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
302287

303288
private async onClearAnalysisCaches() {
304289
const values = await Promise.all([...this.cache.values()]);
305-
values.forEach(v => v.clearAnalysisCache ? v.clearAnalysisCache() : noop());
290+
values.forEach(v => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop()));
306291
}
307292
}

src/client/activation/extensionSurvey.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import { ShowExtensionSurveyPrompt } from '../common/experimentGroups';
1010
import '../common/extensions';
1111
import { traceDecorators } from '../common/logger';
1212
import { IPlatformService } from '../common/platform/types';
13-
import {
14-
IBrowserService, IExperimentsManager, IPersistentStateFactory, IRandom
15-
} from '../common/types';
13+
import { IBrowserService, IExperimentsManager, IPersistentStateFactory, IRandom } from '../common/types';
1614
import { Common, ExtensionSurveyBanner, LanguageService } from '../common/utils/localize';
1715
import { sendTelemetryEvent } from '../telemetry';
1816
import { EventName } from '../telemetry/constants';
@@ -38,7 +36,8 @@ export class ExtensionSurveyPrompt implements IExtensionSingleActivationService
3836
@inject(IApplicationEnvironment) private appEnvironment: IApplicationEnvironment,
3937
@inject(IPlatformService) private platformService: IPlatformService,
4038
@optional() private sampleSizePerOneHundredUsers: number = 10,
41-
@optional() private waitTimeToShowSurvey: number = WAIT_TIME_TO_SHOW_SURVEY) { }
39+
@optional() private waitTimeToShowSurvey: number = WAIT_TIME_TO_SHOW_SURVEY
40+
) {}
4241

4342
public async activate(): Promise<void> {
4443
if (!this.experiments.inExperiment(ShowExtensionSurveyPrompt.enabled)) {

0 commit comments

Comments
 (0)