Typescript: Plugins - support a 'willSave' hook

Created on 17 May 2017  路  3Comments  路  Source: microsoft/TypeScript

Background angelozerr/tslint-language-service#32.

The tslint language server extension should support an option to auto fix lint rules with a fixer before a file is saved. The plugin API should support a willSave method that a plugin can use to perform an operation like auto fixing before the document is saved. In addition there needs to be request that the TypeScript language client like VS Code can use to inform the TypeScript language server that the user is about to save a file.

Awaiting More Feedback Suggestion

Most helpful comment

@RyanCavanaugh doing this as part of the getFormattingEditsForDocument request makes good sense and it blends well with format on save support. However, what is missing, is that the request has a some context information whether it was triggered as part of a save or not. For the tslint example the user would not want auto fix on each format request but only on save.

Modifying a file on save isn't really a user-apparent pattern.

Support for 'format on save' or 'auto fix on save' are common and supported by many editors IDEs. The key is that this is done as a pre-save operation so that a file is not saved twice.

All 3 comments

I'd rather this was handled as part of a Format Document request. Modifying a file on save isn't really a user-apparent pattern.

@RyanCavanaugh doing this as part of the getFormattingEditsForDocument request makes good sense and it blends well with format on save support. However, what is missing, is that the request has a some context information whether it was triggered as part of a save or not. For the tslint example the user would not want auto fix on each format request but only on save.

Modifying a file on save isn't really a user-apparent pattern.

Support for 'format on save' or 'auto fix on save' are common and supported by many editors IDEs. The key is that this is done as a pre-save operation so that a file is not saved twice.

Can/should this be investigated soon?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmaurer picture wmaurer  路  3Comments

bgrieder picture bgrieder  路  3Comments

jbondc picture jbondc  路  3Comments

blendsdk picture blendsdk  路  3Comments

dlaberge picture dlaberge  路  3Comments