microsoft / microsoft/TypeScript
Language services formatting for `else` on newline
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
Search Terms
- format else
- formatted else
- fomatter newline
- formatting newline
Suggestion
When the formatting option for the opening brace on newline for control blocks is true, it would make sense to have the else on it's online as well.
Use Cases
Using typescript-formatter with VS Code, and from command line.
Examples
My tsfmt.json is:
{
"baseIndentSize": 0,
"indentSize": 4,
"tabSize": 4,
"indentStyle": 2,
"newLineCharacter": "\n",
"convertTabsToSpaces": true,
"insertSpaceAfterCommaDelimiter": true,
"insertSpaceAfterSemicolonInForStatements": true,
"insertSpaceBeforeAndAfterBinaryOperators": true,
"insertSpaceAfterConstructor": false,
"insertSpaceAfterKeywordsInControlFlowStatements": true,
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"insertSpaceAfterTypeAssertion": false,
"insertSpaceBeforeFunctionParenthesis": false,
"insertSpaceBeforeTypeAnnotation": false,
"placeOpenBraceOnNewLineForFunctions": true,
"placeOpenBraceOnNewLineForControlBlocks": true
}
I get results like this:
if(condition)
{
console.log('condition true');
} else if(otherCondition)
{
console.log('other condition is true');
} else
{
console.log('condition not true');
}
For people using "placeOpenBraceOnNewLineForControlBlocks": true, the expected behaviour (IMHO) would be:
if(condition)
{
console.log('condition true');
}
else if(otherCondition)
{
console.log('other condition is true');
}
else
{
console.log('condition not true');
}
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách xác định các điểm vào của formatter được sử dụng để định dạng TypeScript trong VS Code và typescript-formatter dòng lệnh, sau đó theo dõi cách xử lý dấu ngoặc nhọn của các khối điều khiển. So sánh các ví dụ hiện tại và dự kiến; hoàn thành khi kiểu xuống dòng được cấu hình đặt else trên dòng riêng mà không thay đổi bất kỳ hành vi định dạng nào khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100