-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Domain: FormatterThe issue relates to the built-in formatterThe issue relates to the built-in formatterExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Suggestion
π Search Terms
semicolon at the start of a line
formatting spaces around semi
β Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
In setups where semicolons are not used and the code relies on ASI, there are certain statements which can confuse both the developer and the engine.
In such cases, some people prefer to use semicolon at the start of the particular statement that could potentially cause such behavior regardless of what is actually on the preceding line.
π Motivating Example
This adjustment will fix formatting issue and make it consistent.
π» Use Cases
With vscode formatting setting
"typescript.format.semicolons": "remove"
and eslint rules,
"semi-style": ["error", "first"],
"semi-spacing": "error"
"indent": ["error", 2],
I get this automatic eslint --fix
,
// before
console.log('hi');
(something ??= {_default: 0})[key] = 1
// after
console.log('hi')
;(something ??= {_default: 0})[key] = 1
^ ..... this is desired
which is then auto-formatted by vscode to this,
console.log('hi')
; (something ??= {_default: 0})[key] = 1
^^ ^ ..... spaces inserted, undesired
which in turn raises this eslint error.
Expected indentation of 14 spaces but found 16. eslint(indent)
Migrated from microsoft/vscode#146620
ChiriVulpes
Metadata
Metadata
Assignees
Labels
Domain: FormatterThe issue relates to the built-in formatterThe issue relates to the built-in formatterExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript