mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 15:25:47 +01:00
[typescript-language-features] Add formatter option for semicolons (#80828)
* Add formatter option for semicolons * Add compatibility note * Make it compile without TS 3.7
This commit is contained in:
committed by
Matt Bierner
parent
3890a199a2
commit
8774e0bb05
@@ -264,6 +264,22 @@
|
||||
"description": "%format.placeOpenBraceOnNewLineForControlBlocks%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"typescript.format.semicolons": {
|
||||
"type": "string",
|
||||
"default": "ignore",
|
||||
"description": "%format.semicolons%",
|
||||
"scope": "resource",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"insert",
|
||||
"remove"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"%format.semicolons.ignore%",
|
||||
"%format.semicolons.insert%",
|
||||
"%format.semicolons.remove%"
|
||||
]
|
||||
},
|
||||
"javascript.validate.enable": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
@@ -360,6 +376,22 @@
|
||||
"description": "%format.placeOpenBraceOnNewLineForControlBlocks%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"javascript.format.semicolons": {
|
||||
"type": "string",
|
||||
"default": "ignore",
|
||||
"description": "%format.semicolons%",
|
||||
"scope": "resource",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"insert",
|
||||
"remove"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"%format.semicolons.ignore%",
|
||||
"%format.semicolons.insert%",
|
||||
"%format.semicolons.remove%"
|
||||
]
|
||||
},
|
||||
"javascript.implicitProjectConfig.checkJs": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
"format.insertSpaceAfterTypeAssertion": "Defines space handling after type assertions in TypeScript. Requires using TypeScript 2.4 or newer in the workspace.",
|
||||
"format.placeOpenBraceOnNewLineForFunctions": "Defines whether an open brace is put onto a new line for functions or not.",
|
||||
"format.placeOpenBraceOnNewLineForControlBlocks": "Defines whether an open brace is put onto a new line for control blocks or not.",
|
||||
"format.semicolons": "Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace.",
|
||||
"format.semicolons.ignore": "Don’t insert or remove any semicolons.",
|
||||
"format.semicolons.insert": "Insert semicolons at statement ends.",
|
||||
"format.semicolons.remove": "Remove unnecessary semicolons.",
|
||||
"javascript.validate.enable": "Enable/disable JavaScript validation.",
|
||||
"goToProjectConfig.title": "Go to Project Configuration",
|
||||
"javascript.referencesCodeLens.enabled": "Enable/disable references CodeLens in JavaScript files.",
|
||||
@@ -70,4 +74,4 @@
|
||||
"configuration.surveys.enabled": "Enabled/disable occasional surveys that help us improve VS Code's JavaScript and TypeScript support.",
|
||||
"configuration.suggest.completeJSDocs": "Enable/disable suggestion to complete JSDoc comments.",
|
||||
"typescript.preferences.renameShorthandProperties": "Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,9 @@ export default class FileConfigurationManager extends Disposable {
|
||||
isTypeScriptDocument(document) ? 'typescript.format' : 'javascript.format',
|
||||
document.uri);
|
||||
|
||||
return {
|
||||
// `semicolons` added to `Proto.FormatCodeSettings` in TypeScript 3.7:
|
||||
// remove intersection type after upgrading TypeScript.
|
||||
const settings: Proto.FormatCodeSettings & { semicolons?: string } = {
|
||||
tabSize: options.tabSize,
|
||||
indentSize: options.tabSize,
|
||||
convertTabsToSpaces: options.insertSpaces,
|
||||
@@ -165,7 +167,10 @@ export default class FileConfigurationManager extends Disposable {
|
||||
insertSpaceAfterTypeAssertion: config.get<boolean>('insertSpaceAfterTypeAssertion'),
|
||||
placeOpenBraceOnNewLineForFunctions: config.get<boolean>('placeOpenBraceOnNewLineForFunctions'),
|
||||
placeOpenBraceOnNewLineForControlBlocks: config.get<boolean>('placeOpenBraceOnNewLineForControlBlocks'),
|
||||
semicolons: config.get<string>('semicolons'),
|
||||
};
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
private getPreferences(document: vscode.TextDocument): Proto.UserPreferences {
|
||||
@@ -201,4 +206,4 @@ function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguratio
|
||||
case 'non-relative': return 'non-relative';
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user