Skip to content

Reformat imports to be one identifier per line #51565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"@typescript-eslint", "no-null", "import", "eslint-plugin-local"
],
"rules": {
"sort-imports": ["error", {
"ignoreDeclarationSort": true,
"allowSeparatedGroups": true
}],

"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-array-constructor": "error",
Expand Down
6 changes: 3 additions & 3 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { task } from "hereby";
import _glob from "glob";
import util from "util";
import chalk from "chalk";
import { exec, readJson, getDiffTool, getDirSize, memoize, needsUpdate, Debouncer, Deferred } from "./scripts/build/utils.mjs";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file didn't get changed besides sorting because format-imports doens't seem to support this file type for some reason.

import { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline, cleanTestDirs } from "./scripts/build/tests.mjs";
import { buildProject as realBuildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
import { Debouncer, Deferred, exec, getDiffTool, getDirSize, memoize, needsUpdate, readJson } from "./scripts/build/utils.mjs";
import { cleanTestDirs, localBaseline, localRwcBaseline, refBaseline, refRwcBaseline, runConsoleTests } from "./scripts/build/tests.mjs";
import { cleanProject, buildProject as realBuildProject, watchProject } from "./scripts/build/projects.mjs";
import { localizationDirectories } from "./scripts/build/localization.mjs";
import cmdLineOptions from "./scripts/build/options.mjs";
import esbuild from "esbuild";
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/findUpDir.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, resolve, dirname } from "path";
import { dirname, join, resolve } from "path";
import { existsSync } from "fs";
import url from "url";

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/projects.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec, Debouncer } from "./utils.mjs";
import { Debouncer, exec } from "./utils.mjs";
import { resolve } from "path";
import { findUpRoot } from "./findUpDir.mjs";
import cmdLineOptions from "./options.mjs";
Expand Down
353 changes: 295 additions & 58 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,299 @@
import {
__String, AccessExpression, addRelatedInfo, append, appendIfUnique, ArrayBindingElement, ArrayLiteralExpression,
ArrowFunction, AssignmentDeclarationKind, BinaryExpression, BinaryOperatorToken, BindableAccessExpression,
BindableObjectDefinePropertyCall, BindablePropertyAssignmentExpression, BindableStaticAccessExpression,
BindableStaticNameExpression, BindableStaticPropertyAssignmentExpression, BindingElement, Block,
BreakOrContinueStatement, CallChain, CallExpression, CaseBlock, CaseClause, cast, CatchClause, ClassLikeDeclaration,
ClassStaticBlockDeclaration, CompilerOptions, concatenate, ConditionalExpression, ConditionalTypeNode, contains,
createBinaryExpressionTrampoline, createDiagnosticForNodeInSourceFile, createFileDiagnostic, createQueue,
createSymbolTable, Debug, Declaration, declarationNameToString, DeleteExpression, DestructuringAssignment,
DiagnosticCategory, DiagnosticMessage, DiagnosticRelatedInformation, Diagnostics, DiagnosticWithLocation,
DoStatement, DynamicNamedDeclaration, ElementAccessChain, ElementAccessExpression, EntityNameExpression,
EnumDeclaration, escapeLeadingUnderscores, every, ExportAssignment, exportAssignmentIsAlias,
ExportDeclaration, ExportSpecifier, Expression, ExpressionStatement, findAncestor, FlowFlags, FlowLabel, FlowNode,
FlowReduceLabel, forEach, forEachChild, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression,
FunctionLikeDeclaration, GetAccessorDeclaration, getAssignedExpandoInitializer, getAssignmentDeclarationKind,
getAssignmentDeclarationPropertyAccessKind, getCombinedModifierFlags, getCombinedNodeFlags, getContainingClass,
getEffectiveContainerForJSDocTemplateTag, getElementOrPropertyAccessName, getEmitScriptTarget,
getEnclosingBlockScopeContainer, getErrorSpanForNode, getEscapedTextOfIdentifierOrLiteral, getExpandoInitializer,
getHostSignatureFromJSDoc, getImmediatelyInvokedFunctionExpression, getJSDocTypeTag, getLeftmostAccessExpression,
getNameOfDeclaration, getNameOrArgument, getNodeId, getRangesWhere, getRightMostAssignedExpression,
getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, getSpanOfTokenAtPosition, getStrictOptionValue,
getSymbolNameForPrivateIdentifier, getTextOfIdentifierOrLiteral, getThisContainer, getTokenPosOfNode,
hasDynamicName, hasJSDocNodes, hasSyntacticModifier, Identifier, idText, IfStatement, ImportClause,
InternalSymbolName, isAliasableExpression, isAmbientModule, isAssignmentExpression, isAssignmentOperator,
isAssignmentTarget, isAsyncFunction, isAutoAccessorPropertyDeclaration, isBinaryExpression,
isBindableObjectDefinePropertyCall, isBindableStaticAccessExpression, isBindableStaticNameExpression,
isBindingPattern, isBlock, isBlockOrCatchScoped, isCallExpression, isClassStaticBlockDeclaration,
isConditionalTypeNode, isDeclaration, isDeclarationStatement, isDestructuringAssignment, isDottedName,
isElementAccessExpression, isEmptyObjectLiteral, isEntityNameExpression, isEnumConst, isEnumDeclaration,
isExportAssignment, isExportDeclaration, isExportsIdentifier, isExportSpecifier, isExpression,
isExpressionOfOptionalChainRoot, isExternalModule, isExternalOrCommonJsModule, isForInOrOfStatement,
isFunctionDeclaration, isFunctionLike, isFunctionLikeDeclaration, isFunctionLikeOrClassStaticBlockDeclaration,
isFunctionSymbol, isGlobalScopeAugmentation, isIdentifier, isIdentifierName, isInJSFile, isInTopLevelContext,
isJSDocConstructSignature, isJSDocEnumTag, isJSDocTemplateTag, isJSDocTypeAlias, isJsonSourceFile,
isLeftHandSideExpression, isLogicalOrCoalescingAssignmentOperator, isModuleAugmentationExternal, isModuleBlock,
isModuleDeclaration, isModuleExportsAccessExpression, isNamedDeclaration, isNamespaceExport, isNonNullExpression,
isNullishCoalesce, isObjectLiteralExpression, isObjectLiteralMethod,
isObjectLiteralOrClassExpressionMethodOrAccessor, isOmittedExpression, isOptionalChain, isOptionalChainRoot,
isOutermostOptionalChain, isParameterDeclaration, isParameterPropertyDeclaration, isParenthesizedExpression,
isPartOfTypeQuery, isPrefixUnaryExpression, isPrivateIdentifier, isPrologueDirective,
isPropertyAccessEntityNameExpression, isPropertyAccessExpression, isPropertyNameLiteral, isPrototypeAccess,
isPushOrUnshiftIdentifier, isRequireCall, isShorthandPropertyAssignment, isSignedNumericLiteral, isSourceFile,
isSpecialPropertyDeclaration, isStatement, isStatementButNotDeclaration, isStatic, isString, isStringLiteralLike,
isStringOrNumericLiteralLike, isThisInitializedDeclaration, isTypeAliasDeclaration, isTypeOfExpression,
isVariableDeclaration, isVariableDeclarationInitializedToBareOrAccessedRequire, isVariableStatement,
JSDocCallbackTag, JSDocClassTag, JSDocEnumTag, JSDocFunctionType, JSDocParameterTag, JSDocPropertyLikeTag,
JSDocSignature, JSDocTypedefTag, JSDocTypeLiteral, JsxAttribute, JsxAttributes, LabeledStatement, length,
LiteralLikeElementAccessExpression, MappedTypeNode, MethodDeclaration, ModifierFlags, ModuleBlock,
ModuleDeclaration, Mutable, NamespaceExportDeclaration, Node, NodeArray, NodeFlags, nodeHasName, nodeIsMissing,
nodeIsPresent, NonNullChain, NonNullExpression, NumericLiteral, objectAllocator, ObjectLiteralExpression,
OptionalChain, ParameterDeclaration, ParenthesizedExpression, Pattern, PatternAmbientModule, perfLogger,
PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessChain, PropertyAccessExpression,
PropertyDeclaration, PropertySignature, removeFileExtension, ReturnStatement, ScriptTarget,
SetAccessorDeclaration, setParent, setParentRecursive, setValueDeclaration, ShorthandPropertyAssignment,
shouldPreserveConstEnums, SignatureDeclaration, skipParentheses, sliceAfter, some, SourceFile, SpreadElement,
Statement, StringLiteral, SwitchStatement, Symbol, SymbolFlags, symbolName, SymbolTable, SyntaxKind, TextRange,
ThrowStatement, TokenFlags, tokenToString, tracing, TracingNode, tryCast, tryParsePattern, TryStatement,
TypeLiteralNode, TypeOfExpression, TypeParameterDeclaration, unescapeLeadingUnderscores, unreachableCodeIsError,
unusedLabelIsError, VariableDeclaration, WhileStatement, WithStatement,
AccessExpression,
ArrayBindingElement,
ArrayLiteralExpression,
ArrowFunction,
AssignmentDeclarationKind,
BinaryExpression,
BinaryOperatorToken,
BindableAccessExpression,
BindableObjectDefinePropertyCall,
BindablePropertyAssignmentExpression,
BindableStaticAccessExpression,
BindableStaticNameExpression,
BindableStaticPropertyAssignmentExpression,
BindingElement,
Block,
BreakOrContinueStatement,
CallChain,
CallExpression,
CaseBlock,
CaseClause,
CatchClause,
ClassLikeDeclaration,
ClassStaticBlockDeclaration,
CompilerOptions,
ConditionalExpression,
ConditionalTypeNode,
Debug,
Declaration,
DeleteExpression,
DestructuringAssignment,
DiagnosticCategory,
DiagnosticMessage,
DiagnosticRelatedInformation,
DiagnosticWithLocation,
Diagnostics,
DoStatement,
DynamicNamedDeclaration,
ElementAccessChain,
ElementAccessExpression,
EntityNameExpression,
EnumDeclaration,
ExportAssignment,
ExportDeclaration,
ExportSpecifier,
Expression,
ExpressionStatement,
FlowFlags,
FlowLabel,
FlowNode,
FlowReduceLabel,
ForInOrOfStatement,
ForStatement,
FunctionDeclaration,
FunctionExpression,
FunctionLikeDeclaration,
GetAccessorDeclaration,
Identifier,
IfStatement,
ImportClause,
InternalSymbolName,
JSDocCallbackTag,
JSDocClassTag,
JSDocEnumTag,
JSDocFunctionType,
JSDocParameterTag,
JSDocPropertyLikeTag,
JSDocSignature,
JSDocTypeLiteral,
JSDocTypedefTag,
JsxAttribute,
JsxAttributes,
LabeledStatement,
LiteralLikeElementAccessExpression,
MappedTypeNode,
MethodDeclaration,
ModifierFlags,
ModuleBlock,
ModuleDeclaration,
Mutable,
NamespaceExportDeclaration,
Node,
NodeArray,
NodeFlags,
NonNullChain,
NonNullExpression,
NumericLiteral,
ObjectLiteralExpression,
OptionalChain,
ParameterDeclaration,
ParenthesizedExpression,
Pattern,
PatternAmbientModule,
PostfixUnaryExpression,
PrefixUnaryExpression,
PrivateIdentifier,
PropertyAccessChain,
PropertyAccessExpression,
PropertyDeclaration,
PropertySignature,
ReturnStatement,
ScriptTarget,
SetAccessorDeclaration,
ShorthandPropertyAssignment,
SignatureDeclaration,
SourceFile,
SpreadElement,
Statement,
StringLiteral,
SwitchStatement,
Symbol,
SymbolFlags,
SymbolTable,
SyntaxKind,
TextRange,
ThrowStatement,
TokenFlags,
TracingNode,
TryStatement,
TypeLiteralNode,
TypeOfExpression,
TypeParameterDeclaration,
VariableDeclaration,
WhileStatement,
WithStatement,
__String,
addRelatedInfo,
append,
appendIfUnique,
cast,
concatenate,
contains,
createBinaryExpressionTrampoline,
createDiagnosticForNodeInSourceFile,
createFileDiagnostic,
createQueue,
createSymbolTable,
declarationNameToString,
escapeLeadingUnderscores,
every,
exportAssignmentIsAlias,
findAncestor,
forEach,
forEachChild,
getAssignedExpandoInitializer,
getAssignmentDeclarationKind,
getAssignmentDeclarationPropertyAccessKind,
getCombinedModifierFlags,
getCombinedNodeFlags,
getContainingClass,
getEffectiveContainerForJSDocTemplateTag,
getElementOrPropertyAccessName,
getEmitScriptTarget,
getEnclosingBlockScopeContainer,
getErrorSpanForNode,
getEscapedTextOfIdentifierOrLiteral,
getExpandoInitializer,
getHostSignatureFromJSDoc,
getImmediatelyInvokedFunctionExpression,
getJSDocTypeTag,
getLeftmostAccessExpression,
getNameOfDeclaration,
getNameOrArgument,
getNodeId,
getRangesWhere,
getRightMostAssignedExpression,
getSourceFileOfNode,
getSourceTextOfNodeFromSourceFile,
getSpanOfTokenAtPosition,
getStrictOptionValue,
getSymbolNameForPrivateIdentifier,
getTextOfIdentifierOrLiteral,
getThisContainer,
getTokenPosOfNode,
hasDynamicName,
hasJSDocNodes,
hasSyntacticModifier,
idText,
isAliasableExpression,
isAmbientModule,
isAssignmentExpression,
isAssignmentOperator,
isAssignmentTarget,
isAsyncFunction,
isAutoAccessorPropertyDeclaration,
isBinaryExpression,
isBindableObjectDefinePropertyCall,
isBindableStaticAccessExpression,
isBindableStaticNameExpression,
isBindingPattern,
isBlock,
isBlockOrCatchScoped,
isCallExpression,
isClassStaticBlockDeclaration,
isConditionalTypeNode,
isDeclaration,
isDeclarationStatement,
isDestructuringAssignment,
isDottedName,
isElementAccessExpression,
isEmptyObjectLiteral,
isEntityNameExpression,
isEnumConst,
isEnumDeclaration,
isExportAssignment,
isExportDeclaration,
isExportSpecifier,
isExportsIdentifier,
isExpression,
isExpressionOfOptionalChainRoot,
isExternalModule,
isExternalOrCommonJsModule,
isForInOrOfStatement,
isFunctionDeclaration,
isFunctionLike,
isFunctionLikeDeclaration,
isFunctionLikeOrClassStaticBlockDeclaration,
isFunctionSymbol,
isGlobalScopeAugmentation,
isIdentifier,
isIdentifierName,
isInJSFile,
isInTopLevelContext,
isJSDocConstructSignature,
isJSDocEnumTag,
isJSDocTemplateTag,
isJSDocTypeAlias,
isJsonSourceFile,
isLeftHandSideExpression,
isLogicalOrCoalescingAssignmentOperator,
isModuleAugmentationExternal,
isModuleBlock,
isModuleDeclaration,
isModuleExportsAccessExpression,
isNamedDeclaration,
isNamespaceExport,
isNonNullExpression,
isNullishCoalesce,
isObjectLiteralExpression,
isObjectLiteralMethod,
isObjectLiteralOrClassExpressionMethodOrAccessor,
isOmittedExpression,
isOptionalChain,
isOptionalChainRoot,
isOutermostOptionalChain,
isParameterDeclaration,
isParameterPropertyDeclaration,
isParenthesizedExpression,
isPartOfTypeQuery,
isPrefixUnaryExpression,
isPrivateIdentifier,
isPrologueDirective,
isPropertyAccessEntityNameExpression,
isPropertyAccessExpression,
isPropertyNameLiteral,
isPrototypeAccess,
isPushOrUnshiftIdentifier,
isRequireCall,
isShorthandPropertyAssignment,
isSignedNumericLiteral,
isSourceFile,
isSpecialPropertyDeclaration,
isStatement,
isStatementButNotDeclaration,
isStatic,
isString,
isStringLiteralLike,
isStringOrNumericLiteralLike,
isThisInitializedDeclaration,
isTypeAliasDeclaration,
isTypeOfExpression,
isVariableDeclaration,
isVariableDeclarationInitializedToBareOrAccessedRequire,
isVariableStatement,
length,
nodeHasName,
nodeIsMissing,
nodeIsPresent,
objectAllocator,
perfLogger,
removeFileExtension,
setParent,
setParentRecursive,
setValueDeclaration,
shouldPreserveConstEnums,
skipParentheses,
sliceAfter,
some,
symbolName,
tokenToString,
tracing,
tryCast,
tryParsePattern,
unescapeLeadingUnderscores,
unreachableCodeIsError,
unusedLabelIsError,
} from "./_namespaces/ts";
import * as performance from "./_namespaces/ts.performance";

Expand Down
Loading