Skip to content

Commit

Permalink
dprint the codebase (#54820)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Aug 16, 2023
1 parent ffec968 commit 5e8c261
Show file tree
Hide file tree
Showing 560 changed files with 28,486 additions and 23,296 deletions.
55 changes: 55 additions & 0 deletions .dprint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"indentWidth": 4,
"lineWidth": 1000,
"newLineKind": "auto",
"useTabs": false,
"typescript": {
"semiColons": "always",
"quoteStyle": "preferDouble",
"quoteProps": "consistent",
"useBraces": "whenNotSingleLine",
"bracePosition": "sameLineUnlessHanging",
"singleBodyPosition": "sameLine",
"nextControlFlowPosition": "nextLine", // Stroustrup style braces.
"trailingCommas": "onlyMultiLine",
"preferHanging": false,
"operatorPosition": "maintain",

"arrowFunction.useParentheses": "preferNone",
"conditionalExpression.linePerExpression": false, // Keep our "match/case"-ish conditionals.
"functionExpression.spaceAfterFunctionKeyword": true,
"importDeclaration.forceMultiLine": true,
"constructorType.spaceAfterNewKeyword": true,
"constructSignature.spaceAfterNewKeyword": true,

// Let eslint-plugin-simple-import-sort handle this.
"module.sortImportDeclarations": "maintain",
"module.sortExportDeclarations": "maintain",
"exportDeclaration.sortNamedExports": "maintain",
"importDeclaration.sortNamedImports": "maintain"
},
"prettier": {
"associations": [
"**/*.{yaml,yml}"
],
"yml.tabWidth": 2,
"yaml.tabWidth": 2,
"yml.singleQuote": true,
"yaml.singleQuote": true
},
"excludes": [
"**/node_modules",
"**/*-lock.json",
"coverage/**",
"lib/**",
"built/**",
"tests/**",
"internal/**",
"**/*.generated.*",
"scripts/*.d.*"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.86.1.wasm",
"https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe"
]
}
6 changes: 3 additions & 3 deletions .eslintplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const path = require("path");

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

module.exports = {
rules: Object.fromEntries(ruleFiles.map((p) => {
rules: Object.fromEntries(ruleFiles.map(p => {
return [p.slice(0, -ext.length), require(path.join(rulesDir, p))];
})),
}
};
28 changes: 1 addition & 27 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,7 @@

// eslint-plugin-simple-import-sort
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",

// Formatting rules; remove once a formatter enforces these.
"curly": ["error", "multi-line"],
"linebreak-style": ["error", "windows"],
"max-statements-per-line": ["error", { "max": 1 }],
"new-parens": "error",
"no-trailing-spaces": "error",
"quote-props": ["error", "consistent-as-needed"],
"space-in-parens": "error",
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"@typescript-eslint/no-extra-semi": "error",
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
"@typescript-eslint/semi": "error",
"@typescript-eslint/space-before-function-paren": [
"error",
{
"asyncArrow": "always",
"anonymous": "always",
"named": "never"
}
],
"local/object-literal-surrounding-space": "error",
"local/no-type-assertion-whitespace": "error",
"local/type-operator-spacing": "error",
"local/no-double-space": "error",
"local/simple-indent": "error"
"simple-import-sort/exports": "error"
},
"overrides": [
// By default, the ESLint CLI only looks at .js files. But, it will also look at
Expand Down
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "Bug report"
description: "Create a report to help us improve TypeScript"
name: 'Bug report'
description: 'Create a report to help us improve TypeScript'
body:
- type: markdown
attributes:
value: Please fill in each section completely. Thank you!
- type: textarea
id: search_terms
attributes:
label: "🔎 Search Terms"
label: '🔎 Search Terms'
description: |
What search terms did you use when trying to find an existing bug report?
Expand All @@ -22,7 +22,7 @@ body:
- type: textarea
id: version_info
attributes:
label: "🕗 Version & Regression Information"
label: '🕗 Version & Regression Information'
description: |
When did you start seeing this bug occur?
Expand All @@ -33,7 +33,7 @@ body:
If possible, please try testing the nightly version of TS to see if it's already been fixed. For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
Note: The TypeScript Playground can be used to try older versions of TypeScript.
Expand All @@ -56,7 +56,7 @@ body:
As a last resort, you can link to a repo, but these will be slower for us to investigate.
placeholder: "Playground link with relevant code: https://www.typescriptlang.org/play?#code/PTAEFkE9QYwewCYFNQHM5IM6gBZIE5JA"
placeholder: 'Playground link with relevant code: https://www.typescriptlang.org/play?#code/PTAEFkE9QYwewCYFNQHM5IM6gBZIE5JA'
validations:
required: false
- type: textarea
Expand Down Expand Up @@ -87,7 +87,7 @@ body:
id: actual_behavior
attributes:
label: 🙁 Actual behavior
description: "What happened, and why it was wrong."
description: 'What happened, and why it was wrong.'
validations:
required: true
- type: textarea
Expand Down
26 changes: 11 additions & 15 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
---
blank_issues_enabled: false
contact_links:
-
about: "Please ask and answer usage questions on Stack Overflow."
contact_links:
- about: 'Please ask and answer usage questions on Stack Overflow.'
name: Question
url: "https://stackoverflow.com/questions/tagged/typescript"
-
about: "Alternatively, you can use the TypeScript Community Discord."
url: 'https://stackoverflow.com/questions/tagged/typescript'
- about: 'Alternatively, you can use the TypeScript Community Discord.'
name: Chat
url: "https://discord.gg/typescript"
-
about: "Please check the FAQ before filing new issues"
name: "TypeScript FAQ"
url: "https://github.com/microsoft/TypeScript/wiki/FAQ"
-
about: "Please raise issues about the site on its own repo."
url: 'https://discord.gg/typescript'
- about: 'Please check the FAQ before filing new issues'
name: 'TypeScript FAQ'
url: 'https://github.com/microsoft/TypeScript/wiki/FAQ'
- about: 'Please raise issues about the site on its own repo.'
name: Website
url: "https://github.com/microsoft/TypeScript-Website/issues/new"
url: 'https://github.com/microsoft/TypeScript-Website/issues/new'
46 changes: 23 additions & 23 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: "Feature request"
description: "Suggest an idea"
name: 'Feature request'
description: 'Suggest an idea'
body:
- type: markdown
attributes:
value: "Please fill in each section completely. Thank you!"
value: 'Please fill in each section completely. Thank you!'
- type: textarea
id: search_terms
attributes:
label: "🔍 Search Terms"
label: '🔍 Search Terms'
description: |
💡 Did you know? TypeScript has over 2,000 open suggestions!
💡 Did you know? TypeScript has over 2,000 open suggestions!
🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests
The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests
placeholder: |
List of keywords you searched for before creating this issue.
Write them down here so that others can find this suggestion more easily and help provide feedback.
Expand All @@ -24,44 +24,44 @@ body:
- type: checkboxes
id: viability_checklist
attributes:
label: "✅ Viability Checklist"
label: '✅ Viability Checklist'
description: |
Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
We always recommend reviewing the TypeScript design goals before investing time writing
a proposal for ideas outside the scope of the project.
My suggestion meets the following guidelines.
options:
- label: This wouldn't be a breaking change in existing TypeScript/JavaScript code
required: true
- label: This wouldn't change the runtime behavior of existing JavaScript code
required: true
- label: This could be implemented without emitting different JS based on the types of the expressions
required: true
- label: This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
required: true
- label: "This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals"
required: true
- label: This wouldn't be a breaking change in existing TypeScript/JavaScript code
required: true
- label: This wouldn't change the runtime behavior of existing JavaScript code
required: true
- label: This could be implemented without emitting different JS based on the types of the expressions
required: true
- label: This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
required: true
- label: 'This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals'
required: true
- type: textarea
id: suggestion_summary
attributes:
label: "⭐ Suggestion"
label: '⭐ Suggestion'
description: "A summary of what you'd like to see added or changed"
validations:
required: true
- type: textarea
id: motivating_example
attributes:
label: "📃 Motivating Example"
label: '📃 Motivating Example'
description: |
If you were announcing this feature in a blog post, what's a short
explanation that shows a developer why this feature improves the language?
If you were announcing this feature in a blog post, what's a short
explanation that shows a developer why this feature improves the language?
validations:
required: true
- type: textarea
id: use_cases
attributes:
label: "💻 Use Cases"
label: '💻 Use Cases'
value: |
1. What do you want to use this for?
2. What shortcomings exist with current approaches?
Expand Down
26 changes: 13 additions & 13 deletions .github/ISSUE_TEMPLATE/lib_change.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Library change"
description: "Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc."
name: 'Library change'
description: 'Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc.'
body:
- type: markdown
attributes:
Expand All @@ -18,45 +18,45 @@ body:
- type: markdown
attributes:
value: |
If you're missing common new methods like `Array.includes`, you may have a misconfigured project.
Try setting `lib: "es2020"` and checking whether the type you want is present.
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
If you're missing common new methods like `Array.includes`, you may have a misconfigured project.
Try setting `lib: "es2020"` and checking whether the type you want is present.
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
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
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
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
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
- type: input
id: compilation_target
attributes:
label: "⚙ Compilation target"
label: '⚙ Compilation target'
description: "What's your compilation target (e.g.: `ES2015`)?"
validations:
required: true
- type: input
id: current_lib
attributes:
label: "⚙ Library"
label: '⚙ Library'
description: "What's the current library you're using?"
validations:
required: true
- type: textarea
id: incorrect_definition
attributes:
label: "Missing / Incorrect Definition"
description: "What property, method, function, etc. is missing or incorrect?"
label: 'Missing / Incorrect Definition'
description: 'What property, method, function, etc. is missing or incorrect?'
validations:
required: true
- type: textarea
id: sample_code
attributes:
label: "Sample Code"
label: 'Sample Code'
description: "What's some code using this that should work, but doesn't?"
render: TypeScript
validations:
required: true
- type: textarea
id: documentation_link
attributes:
label: "Documentation Link"
label: 'Documentation Link'
description: |
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
Note that lib.dom.d.ts intentionally does not include browser-specific extensions or early experimental features.
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/module_resolution.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Module resolution
description: Report a problem with module resolution
title: "Module resolution:"
title: 'Module resolution:'
labels: []
body:
- type: markdown
Expand Down Expand Up @@ -64,7 +64,7 @@ body:
attributes:
label: Run `tsc --showConfig` and paste its output here
description: Repros that depend on running within external tools (yarn, pnpm, esbuild, etc.) are not TypeScript defects and will not be investigated.
placeholder: "> tsc --showConfig"
placeholder: '> tsc --showConfig'
validations:
required: true

Expand All @@ -73,30 +73,30 @@ body:
attributes:
label: Run `tsc --traceResolution` and paste its output here
description: Run `tsc --traceResolution` and paste the output here.
placeholder: "> tsc --traceResolution"
placeholder: '> tsc --traceResolution'
validations:
required: true

- type: textarea
id: import-package-json
attributes:
label: Paste the `package.json` of the *importing* module, if it exists
placeholder: "my_project/package.json"
placeholder: 'my_project/package.json'
validations:
required: true

- type: textarea
id: export-package-json
attributes:
label: Paste the `package.json` of the *target* module, if it exists
placeholder: "node_modules/somepkg/package.json"
placeholder: 'node_modules/somepkg/package.json'
validations:
required: true

- type: textarea
id: comments
attributes:
label: Any other comments can go here
placeholder: "Have a nice day!"
placeholder: 'Have a nice day!'
validations:
required: true
Loading

0 comments on commit 5e8c261

Please sign in to comment.