Skip to content

Commit 5e8c261

Browse files
authored
dprint the codebase (microsoft#54820)
1 parent ffec968 commit 5e8c261

File tree

560 files changed

+28486
-23296
lines changed

Some content is hidden

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

560 files changed

+28486
-23296
lines changed

.dprint.jsonc

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"indentWidth": 4,
3+
"lineWidth": 1000,
4+
"newLineKind": "auto",
5+
"useTabs": false,
6+
"typescript": {
7+
"semiColons": "always",
8+
"quoteStyle": "preferDouble",
9+
"quoteProps": "consistent",
10+
"useBraces": "whenNotSingleLine",
11+
"bracePosition": "sameLineUnlessHanging",
12+
"singleBodyPosition": "sameLine",
13+
"nextControlFlowPosition": "nextLine", // Stroustrup style braces.
14+
"trailingCommas": "onlyMultiLine",
15+
"preferHanging": false,
16+
"operatorPosition": "maintain",
17+
18+
"arrowFunction.useParentheses": "preferNone",
19+
"conditionalExpression.linePerExpression": false, // Keep our "match/case"-ish conditionals.
20+
"functionExpression.spaceAfterFunctionKeyword": true,
21+
"importDeclaration.forceMultiLine": true,
22+
"constructorType.spaceAfterNewKeyword": true,
23+
"constructSignature.spaceAfterNewKeyword": true,
24+
25+
// Let eslint-plugin-simple-import-sort handle this.
26+
"module.sortImportDeclarations": "maintain",
27+
"module.sortExportDeclarations": "maintain",
28+
"exportDeclaration.sortNamedExports": "maintain",
29+
"importDeclaration.sortNamedImports": "maintain"
30+
},
31+
"prettier": {
32+
"associations": [
33+
"**/*.{yaml,yml}"
34+
],
35+
"yml.tabWidth": 2,
36+
"yaml.tabWidth": 2,
37+
"yml.singleQuote": true,
38+
"yaml.singleQuote": true
39+
},
40+
"excludes": [
41+
"**/node_modules",
42+
"**/*-lock.json",
43+
"coverage/**",
44+
"lib/**",
45+
"built/**",
46+
"tests/**",
47+
"internal/**",
48+
"**/*.generated.*",
49+
"scripts/*.d.*"
50+
],
51+
"plugins": [
52+
"https://plugins.dprint.dev/typescript-0.86.1.wasm",
53+
"https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe"
54+
]
55+
}

.eslintplugin.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const path = require("path");
33

44
const rulesDir = path.join(__dirname, "scripts", "eslint", "rules");
55
const ext = ".cjs";
6-
const ruleFiles = fs.readdirSync(rulesDir).filter((p) => p.endsWith(ext));
6+
const ruleFiles = fs.readdirSync(rulesDir).filter(p => p.endsWith(ext));
77

88
module.exports = {
9-
rules: Object.fromEntries(ruleFiles.map((p) => {
9+
rules: Object.fromEntries(ruleFiles.map(p => {
1010
return [p.slice(0, -ext.length), require(path.join(rulesDir, p))];
1111
})),
12-
}
12+
};

.eslintrc.json

+1-27
Original file line numberDiff line numberDiff line change
@@ -128,33 +128,7 @@
128128

129129
// eslint-plugin-simple-import-sort
130130
"simple-import-sort/imports": "error",
131-
"simple-import-sort/exports": "error",
132-
133-
// Formatting rules; remove once a formatter enforces these.
134-
"curly": ["error", "multi-line"],
135-
"linebreak-style": ["error", "windows"],
136-
"max-statements-per-line": ["error", { "max": 1 }],
137-
"new-parens": "error",
138-
"no-trailing-spaces": "error",
139-
"quote-props": ["error", "consistent-as-needed"],
140-
"space-in-parens": "error",
141-
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
142-
"@typescript-eslint/no-extra-semi": "error",
143-
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
144-
"@typescript-eslint/semi": "error",
145-
"@typescript-eslint/space-before-function-paren": [
146-
"error",
147-
{
148-
"asyncArrow": "always",
149-
"anonymous": "always",
150-
"named": "never"
151-
}
152-
],
153-
"local/object-literal-surrounding-space": "error",
154-
"local/no-type-assertion-whitespace": "error",
155-
"local/type-operator-spacing": "error",
156-
"local/no-double-space": "error",
157-
"local/simple-indent": "error"
131+
"simple-import-sort/exports": "error"
158132
},
159133
"overrides": [
160134
// By default, the ESLint CLI only looks at .js files. But, it will also look at

.github/ISSUE_TEMPLATE/bug_report.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: "Bug report"
2-
description: "Create a report to help us improve TypeScript"
1+
name: 'Bug report'
2+
description: 'Create a report to help us improve TypeScript'
33
body:
44
- type: markdown
55
attributes:
66
value: Please fill in each section completely. Thank you!
77
- type: textarea
88
id: search_terms
99
attributes:
10-
label: "🔎 Search Terms"
10+
label: '🔎 Search Terms'
1111
description: |
1212
What search terms did you use when trying to find an existing bug report?
1313
@@ -22,7 +22,7 @@ body:
2222
- type: textarea
2323
id: version_info
2424
attributes:
25-
label: "🕗 Version & Regression Information"
25+
label: '🕗 Version & Regression Information'
2626
description: |
2727
When did you start seeing this bug occur?
2828
@@ -33,7 +33,7 @@ body:
3333
If possible, please try testing the nightly version of TS to see if it's already been fixed. For npm: `typescript@next`
3434
3535
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
36-
36+
3737
3838
Note: The TypeScript Playground can be used to try older versions of TypeScript.
3939
@@ -56,7 +56,7 @@ body:
5656
5757
5858
As a last resort, you can link to a repo, but these will be slower for us to investigate.
59-
placeholder: "Playground link with relevant code: https://www.typescriptlang.org/play?#code/PTAEFkE9QYwewCYFNQHM5IM6gBZIE5JA"
59+
placeholder: 'Playground link with relevant code: https://www.typescriptlang.org/play?#code/PTAEFkE9QYwewCYFNQHM5IM6gBZIE5JA'
6060
validations:
6161
required: false
6262
- type: textarea
@@ -87,7 +87,7 @@ body:
8787
id: actual_behavior
8888
attributes:
8989
label: 🙁 Actual behavior
90-
description: "What happened, and why it was wrong."
90+
description: 'What happened, and why it was wrong.'
9191
validations:
9292
required: true
9393
- type: textarea

.github/ISSUE_TEMPLATE/config.yml

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
---
1+
---
22
blank_issues_enabled: false
3-
contact_links:
4-
-
5-
about: "Please ask and answer usage questions on Stack Overflow."
3+
contact_links:
4+
- about: 'Please ask and answer usage questions on Stack Overflow.'
65
name: Question
7-
url: "https://stackoverflow.com/questions/tagged/typescript"
8-
-
9-
about: "Alternatively, you can use the TypeScript Community Discord."
6+
url: 'https://stackoverflow.com/questions/tagged/typescript'
7+
- about: 'Alternatively, you can use the TypeScript Community Discord.'
108
name: Chat
11-
url: "https://discord.gg/typescript"
12-
-
13-
about: "Please check the FAQ before filing new issues"
14-
name: "TypeScript FAQ"
15-
url: "https://github.com/microsoft/TypeScript/wiki/FAQ"
16-
-
17-
about: "Please raise issues about the site on its own repo."
9+
url: 'https://discord.gg/typescript'
10+
- about: 'Please check the FAQ before filing new issues'
11+
name: 'TypeScript FAQ'
12+
url: 'https://github.com/microsoft/TypeScript/wiki/FAQ'
13+
- about: 'Please raise issues about the site on its own repo.'
1814
name: Website
19-
url: "https://github.com/microsoft/TypeScript-Website/issues/new"
15+
url: 'https://github.com/microsoft/TypeScript-Website/issues/new'

.github/ISSUE_TEMPLATE/feature_request.yml

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
name: "Feature request"
2-
description: "Suggest an idea"
1+
name: 'Feature request'
2+
description: 'Suggest an idea'
33
body:
44
- type: markdown
55
attributes:
6-
value: "Please fill in each section completely. Thank you!"
6+
value: 'Please fill in each section completely. Thank you!'
77
- type: textarea
88
id: search_terms
99
attributes:
10-
label: "🔍 Search Terms"
10+
label: '🔍 Search Terms'
1111
description: |
12-
💡 Did you know? TypeScript has over 2,000 open suggestions!
12+
💡 Did you know? TypeScript has over 2,000 open suggestions!
1313
14-
🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
14+
🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
1515
16-
The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests
16+
The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests
1717
placeholder: |
1818
List of keywords you searched for before creating this issue.
1919
Write them down here so that others can find this suggestion more easily and help provide feedback.
@@ -24,44 +24,44 @@ body:
2424
- type: checkboxes
2525
id: viability_checklist
2626
attributes:
27-
label: "✅ Viability Checklist"
27+
label: '✅ Viability Checklist'
2828
description: |
2929
Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
3030
We always recommend reviewing the TypeScript design goals before investing time writing
3131
a proposal for ideas outside the scope of the project.
3232
3333
My suggestion meets the following guidelines.
3434
options:
35-
- label: This wouldn't be a breaking change in existing TypeScript/JavaScript code
36-
required: true
37-
- label: This wouldn't change the runtime behavior of existing JavaScript code
38-
required: true
39-
- label: This could be implemented without emitting different JS based on the types of the expressions
40-
required: true
41-
- label: This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
42-
required: true
43-
- label: "This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals"
44-
required: true
35+
- label: This wouldn't be a breaking change in existing TypeScript/JavaScript code
36+
required: true
37+
- label: This wouldn't change the runtime behavior of existing JavaScript code
38+
required: true
39+
- label: This could be implemented without emitting different JS based on the types of the expressions
40+
required: true
41+
- label: This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
42+
required: true
43+
- label: 'This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals'
44+
required: true
4545
- type: textarea
4646
id: suggestion_summary
4747
attributes:
48-
label: "⭐ Suggestion"
48+
label: '⭐ Suggestion'
4949
description: "A summary of what you'd like to see added or changed"
5050
validations:
5151
required: true
5252
- type: textarea
5353
id: motivating_example
5454
attributes:
55-
label: "📃 Motivating Example"
55+
label: '📃 Motivating Example'
5656
description: |
57-
If you were announcing this feature in a blog post, what's a short
58-
explanation that shows a developer why this feature improves the language?
57+
If you were announcing this feature in a blog post, what's a short
58+
explanation that shows a developer why this feature improves the language?
5959
validations:
6060
required: true
6161
- type: textarea
6262
id: use_cases
6363
attributes:
64-
label: "💻 Use Cases"
64+
label: '💻 Use Cases'
6565
value: |
6666
1. What do you want to use this for?
6767
2. What shortcomings exist with current approaches?

.github/ISSUE_TEMPLATE/lib_change.yml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: "Library change"
2-
description: "Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc."
1+
name: 'Library change'
2+
description: 'Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc.'
33
body:
44
- type: markdown
55
attributes:
@@ -18,45 +18,45 @@ body:
1818
- type: markdown
1919
attributes:
2020
value: |
21-
If you're missing common new methods like `Array.includes`, you may have a misconfigured project.
22-
Try setting `lib: "es2020"` and checking whether the type you want is present.
23-
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
21+
If you're missing common new methods like `Array.includes`, you may have a misconfigured project.
22+
Try setting `lib: "es2020"` and checking whether the type you want is present.
23+
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
2424
25-
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting or review your dependencies for lib/reference directives that might be polluting
26-
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
25+
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting or review your dependencies for lib/reference directives that might be polluting
26+
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
2727
- type: input
2828
id: compilation_target
2929
attributes:
30-
label: "⚙ Compilation target"
30+
label: '⚙ Compilation target'
3131
description: "What's your compilation target (e.g.: `ES2015`)?"
3232
validations:
3333
required: true
3434
- type: input
3535
id: current_lib
3636
attributes:
37-
label: "⚙ Library"
37+
label: '⚙ Library'
3838
description: "What's the current library you're using?"
3939
validations:
4040
required: true
4141
- type: textarea
4242
id: incorrect_definition
4343
attributes:
44-
label: "Missing / Incorrect Definition"
45-
description: "What property, method, function, etc. is missing or incorrect?"
44+
label: 'Missing / Incorrect Definition'
45+
description: 'What property, method, function, etc. is missing or incorrect?'
4646
validations:
4747
required: true
4848
- type: textarea
4949
id: sample_code
5050
attributes:
51-
label: "Sample Code"
51+
label: 'Sample Code'
5252
description: "What's some code using this that should work, but doesn't?"
5353
render: TypeScript
5454
validations:
5555
required: true
5656
- type: textarea
5757
id: documentation_link
5858
attributes:
59-
label: "Documentation Link"
59+
label: 'Documentation Link'
6060
description: |
6161
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
6262
Note that lib.dom.d.ts intentionally does not include browser-specific extensions or early experimental features.

.github/ISSUE_TEMPLATE/module_resolution.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Module resolution
22
description: Report a problem with module resolution
3-
title: "Module resolution:"
3+
title: 'Module resolution:'
44
labels: []
55
body:
66
- type: markdown
@@ -64,7 +64,7 @@ body:
6464
attributes:
6565
label: Run `tsc --showConfig` and paste its output here
6666
description: Repros that depend on running within external tools (yarn, pnpm, esbuild, etc.) are not TypeScript defects and will not be investigated.
67-
placeholder: "> tsc --showConfig"
67+
placeholder: '> tsc --showConfig'
6868
validations:
6969
required: true
7070

@@ -73,30 +73,30 @@ body:
7373
attributes:
7474
label: Run `tsc --traceResolution` and paste its output here
7575
description: Run `tsc --traceResolution` and paste the output here.
76-
placeholder: "> tsc --traceResolution"
76+
placeholder: '> tsc --traceResolution'
7777
validations:
7878
required: true
7979

8080
- type: textarea
8181
id: import-package-json
8282
attributes:
8383
label: Paste the `package.json` of the *importing* module, if it exists
84-
placeholder: "my_project/package.json"
84+
placeholder: 'my_project/package.json'
8585
validations:
8686
required: true
8787

8888
- type: textarea
8989
id: export-package-json
9090
attributes:
9191
label: Paste the `package.json` of the *target* module, if it exists
92-
placeholder: "node_modules/somepkg/package.json"
92+
placeholder: 'node_modules/somepkg/package.json'
9393
validations:
9494
required: true
9595

9696
- type: textarea
9797
id: comments
9898
attributes:
9999
label: Any other comments can go here
100-
placeholder: "Have a nice day!"
100+
placeholder: 'Have a nice day!'
101101
validations:
102102
required: true

0 commit comments

Comments
 (0)