regression checks for #11103
sosukesuzuki opened this issue · comments
run #11103
prettier/prettier#11103 VS prettier/prettier@main :: babel/babel@2ae19d0
Diff (640 lines)
diff --git ORI/babel/eslint/babel-eslint-plugin/src/rules/no-invalid-this.js ALT/babel/eslint/babel-eslint-plugin/src/rules/no-invalid-this.js
index b51b5af6..d29eea2c 100644
--- ORI/babel/eslint/babel-eslint-plugin/src/rules/no-invalid-this.js
+++ ALT/babel/eslint/babel-eslint-plugin/src/rules/no-invalid-this.js
@@ -13,8 +13,10 @@ export default ruleComposer.filterReports(noInvalidThisRule, problem => {
node.type === "ClassPrivateProperty" ||
node.type === "ClassProperty" ||
node.type === "PropertyDefinition" ||
- (node.type === "MethodDefinition" &&
- node.key.type === "PrivateIdentifier")
+ (
+ node.type === "MethodDefinition" &&
+ node.key.type === "PrivateIdentifier"
+ )
) {
inClassMember = true;
return;
diff --git ORI/babel/packages/babel-core/src/config/config-chain.js ALT/babel/packages/babel-core/src/config/config-chain.js
index 01f60b6d..d4d8eae0 100644
--- ORI/babel/packages/babel-core/src/config/config-chain.js
+++ ALT/babel/packages/babel-core/src/config/config-chain.js
@@ -750,12 +750,18 @@ function configIsApplicable(
context: ConfigContext,
): boolean {
return (
- (options.test === undefined ||
- configFieldIsApplicable(context, options.test, dirname)) &&
- (options.include === undefined ||
- configFieldIsApplicable(context, options.include, dirname)) &&
- (options.exclude === undefined ||
- !configFieldIsApplicable(context, options.exclude, dirname))
+ (
+ options.test === undefined ||
+ configFieldIsApplicable(context, options.test, dirname)
+ ) &&
+ (
+ options.include === undefined ||
+ configFieldIsApplicable(context, options.include, dirname)
+ ) &&
+ (
+ options.exclude === undefined ||
+ !configFieldIsApplicable(context, options.exclude, dirname)
+ )
);
}
diff --git ORI/babel/packages/babel-helper-compilation-targets/src/debug.js ALT/babel/packages/babel-helper-compilation-targets/src/debug.js
index aec840d2..5ccc9d8a 100644
--- ORI/babel/packages/babel-helper-compilation-targets/src/debug.js
+++ ALT/babel/packages/babel-helper-compilation-targets/src/debug.js
@@ -28,8 +28,10 @@ export function getInclusionReasons(
if (
!targetIsUnreleased &&
- (minIsUnreleased ||
- semver.lt(targetVersion.toString(), semverify(minVersion)))
+ (
+ minIsUnreleased ||
+ semver.lt(targetVersion.toString(), semverify(minVersion))
+ )
) {
result[env] = prettifyVersion(targetVersion);
}
diff --git ORI/babel/packages/babel-helper-create-class-features-plugin/src/index.js ALT/babel/packages/babel-helper-create-class-features-plugin/src/index.js
index 47c84171..0a024fdf 100644
--- ORI/babel/packages/babel-helper-create-class-features-plugin/src/index.js
+++ ALT/babel/packages/babel-helper-create-class-features-plugin/src/index.js
@@ -129,11 +129,15 @@ export function createClassFeaturePlugin({
privateNames.add(setName).add(name);
} else {
if (
- (privateNames.has(name) &&
+ (
+ privateNames.has(name) &&
!privateNames.has(getName) &&
- !privateNames.has(setName)) ||
- (privateNames.has(name) &&
- (privateNames.has(getName) || privateNames.has(setName)))
+ !privateNames.has(setName)
+ ) ||
+ (
+ privateNames.has(name) &&
+ (privateNames.has(getName) || privateNames.has(setName))
+ )
) {
throw path.buildCodeFrameError("Duplicate private field");
}
diff --git ORI/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js ALT/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js
index 0f7af46a..a685af31 100644
--- ORI/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js
+++ ALT/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js
@@ -186,9 +186,11 @@ const rewriteReferencesVisitor = {
ref.loc = path.node.loc;
if (
- (path.parentPath.isCallExpression({ callee: path.node }) ||
+ (
+ path.parentPath.isCallExpression({ callee: path.node }) ||
path.parentPath.isOptionalCallExpression({ callee: path.node }) ||
- path.parentPath.isTaggedTemplateExpression({ tag: path.node })) &&
+ path.parentPath.isTaggedTemplateExpression({ tag: path.node })
+ ) &&
t.isMemberExpression(ref)
) {
path.replaceWith(t.sequenceExpression([t.numericLiteral(0), ref]));
diff --git ORI/babel/packages/babel-helper-plugin-utils/src/index.js ALT/babel/packages/babel-helper-plugin-utils/src/index.js
index 5347c247..d931220d 100644
--- ORI/babel/packages/babel-helper-plugin-utils/src/index.js
+++ ALT/babel/packages/babel-helper-plugin-utils/src/index.js
@@ -42,10 +42,12 @@ function copyApiObject(api) {
proto = Object.getPrototypeOf(api);
if (
proto &&
- (!has(proto, "version") ||
+ (
+ !has(proto, "version") ||
!has(proto, "transform") ||
!has(proto, "template") ||
- !has(proto, "types"))
+ !has(proto, "types")
+ )
) {
proto = null;
}
diff --git ORI/babel/packages/babel-parser/src/parser/comments.js ALT/babel/packages/babel-parser/src/parser/comments.js
index c990c9e0..bd4423e8 100644
--- ORI/babel/packages/babel-parser/src/parser/comments.js
+++ ALT/babel/packages/babel-parser/src/parser/comments.js
@@ -169,10 +169,16 @@ export default class CommentsParser extends BaseParser {
}
} else if (
this.state.commentPreviousNode &&
- ((this.state.commentPreviousNode.type === "ImportSpecifier" &&
- node.type !== "ImportSpecifier") ||
- (this.state.commentPreviousNode.type === "ExportSpecifier" &&
- node.type !== "ExportSpecifier"))
+ (
+ (
+ this.state.commentPreviousNode.type === "ImportSpecifier" &&
+ node.type !== "ImportSpecifier"
+ ) ||
+ (
+ this.state.commentPreviousNode.type === "ExportSpecifier" &&
+ node.type !== "ExportSpecifier"
+ )
+ )
) {
this.adjustCommentsAfterTrailingComma(node, [
this.state.commentPreviousNode,
diff --git ORI/babel/packages/babel-parser/src/parser/expression.js ALT/babel/packages/babel-parser/src/parser/expression.js
index e976098f..599a8cec 100644
--- ORI/babel/packages/babel-parser/src/parser/expression.js
+++ ALT/babel/packages/babel-parser/src/parser/expression.js
@@ -402,8 +402,10 @@ export default class ExpressionParser extends LValParser {
if (
op === tt.exponent &&
left.type === "UnaryExpression" &&
- (this.options.createParenthesizedExpressions ||
- !(left.extra && left.extra.parenthesized))
+ (
+ this.options.createParenthesizedExpressions ||
+ !(left.extra && left.extra.parenthesized)
+ )
) {
this.raise(
left.argument.start,
@@ -1687,9 +1689,11 @@ export default class ExpressionParser extends LValParser {
return (
!prop.computed &&
prop.key.type === "Identifier" &&
- (this.isLiteralPropertyName() ||
+ (
+ this.isLiteralPropertyName() ||
this.match(tt.bracketL) ||
- this.match(tt.star))
+ this.match(tt.star)
+ )
);
}
@@ -2309,8 +2313,10 @@ export default class ExpressionParser extends LValParser {
const curContext = this.curContext();
if (
(type === tt._class || type === tt._function) &&
- (curContext === ct.functionStatement ||
- curContext === ct.functionExpression)
+ (
+ curContext === ct.functionStatement ||
+ curContext === ct.functionExpression
+ )
) {
this.state.context.pop();
}
diff --git ORI/babel/packages/babel-parser/src/parser/statement.js ALT/babel/packages/babel-parser/src/parser/statement.js
index e8473742..1a9f1dd2 100644
--- ORI/babel/packages/babel-parser/src/parser/statement.js
+++ ALT/babel/packages/babel-parser/src/parser/statement.js
@@ -261,10 +261,14 @@ export default class StatementParser extends ExpressionParser {
result = this.parseExport(node);
if (
- (result.type === "ExportNamedDeclaration" &&
- (!result.exportKind || result.exportKind === "value")) ||
- (result.type === "ExportAllDeclaration" &&
- (!result.exportKind || result.exportKind === "value")) ||
+ (
+ result.type === "ExportNamedDeclaration" &&
+ (!result.exportKind || result.exportKind === "value")
+ ) ||
+ (
+ result.type === "ExportAllDeclaration" &&
+ (!result.exportKind || result.exportKind === "value")
+ ) ||
result.type === "ExportDefaultDeclaration"
) {
this.sawUnambiguousESM = true;
@@ -960,10 +964,12 @@ export default class StatementParser extends ExpressionParser {
if (
init.type === "VariableDeclaration" &&
init.declarations[0].init != null &&
- (!isForIn ||
+ (
+ !isForIn ||
this.state.strict ||
init.kind !== "var" ||
- init.declarations[0].id.type !== "Identifier")
+ init.declarations[0].id.type !== "Identifier"
+ )
) {
this.raise(
init.start,
@@ -1187,8 +1193,10 @@ export default class StatementParser extends ExpressionParser {
return (
!method.computed &&
!method.static &&
- (method.key.name === "constructor" || // Identifier
- method.key.value === "constructor") // String literal
+ (
+ method.key.name === "constructor" || // Identifier
+ method.key.value === "constructor"
+ ) // String literal
);
}
@@ -1495,8 +1503,10 @@ export default class StatementParser extends ExpressionParser {
if (
!member.computed &&
member.static &&
- ((key: $FlowSubtype<N.Identifier>).name === "prototype" ||
- (key: $FlowSubtype<N.StringLiteral>).value === "prototype")
+ (
+ (key: $FlowSubtype<N.Identifier>).name === "prototype" ||
+ (key: $FlowSubtype<N.StringLiteral>).value === "prototype"
+ )
) {
this.raise(key.start, Errors.StaticPrototype);
}
diff --git ORI/babel/packages/babel-parser/src/parser/util.js ALT/babel/packages/babel-parser/src/parser/util.js
index 53156c57..97258598 100644
--- ORI/babel/packages/babel-parser/src/parser/util.js
+++ ALT/babel/packages/babel-parser/src/parser/util.js
@@ -73,8 +73,10 @@ export default class UtilParser extends Tokenizer {
const nameEnd = nameStart + name.length;
return (
this.input.slice(nameStart, nameEnd) === name &&
- (nameEnd === this.input.length ||
- !isIdentifierChar(this.input.charCodeAt(nameEnd)))
+ (
+ nameEnd === this.input.length ||
+ !isIdentifierChar(this.input.charCodeAt(nameEnd))
+ )
);
}
@@ -299,8 +301,10 @@ export default class UtilParser extends Tokenizer {
*/
hasPropertyAsPrivateName(node: Node): boolean {
return (
- (node.type === "MemberExpression" ||
- node.type === "OptionalMemberExpression") &&
+ (
+ node.type === "MemberExpression" ||
+ node.type === "OptionalMemberExpression"
+ ) &&
this.isPrivateName(node.property)
);
}
diff --git ORI/babel/packages/babel-parser/src/plugins/flow/index.js ALT/babel/packages/babel-parser/src/plugins/flow/index.js
index 9dfa320e..bd3aa5d4 100644
--- ORI/babel/packages/babel-parser/src/plugins/flow/index.js
+++ ALT/babel/packages/babel-parser/src/plugins/flow/index.js
@@ -138,10 +138,16 @@ const FlowErrors = Object.freeze({
function isEsModuleType(bodyElement: N.Node): boolean {
return (
bodyElement.type === "DeclareExportAllDeclaration" ||
- (bodyElement.type === "DeclareExportDeclaration" &&
- (!bodyElement.declaration ||
- (bodyElement.declaration.type !== "TypeAlias" &&
- bodyElement.declaration.type !== "InterfaceDeclaration")))
+ (
+ bodyElement.type === "DeclareExportDeclaration" &&
+ (
+ !bodyElement.declaration ||
+ (
+ bodyElement.declaration.type !== "TypeAlias" &&
+ bodyElement.declaration.type !== "InterfaceDeclaration"
+ )
+ )
+ )
);
}
@@ -485,8 +491,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (
this.match(tt._const) ||
this.isLet() ||
- ((this.isContextual("type") || this.isContextual("interface")) &&
- !insideModule)
+ (
+ (this.isContextual("type") || this.isContextual("interface")) &&
+ !insideModule
+ )
) {
const label = this.state.value;
const suggestion = exportSuggestions[label];
@@ -1862,10 +1870,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
isExportDefaultSpecifier(): boolean {
if (
this.match(tt.name) &&
- (this.state.value === "type" ||
+ (
+ this.state.value === "type" ||
this.state.value === "interface" ||
this.state.value === "opaque" ||
- (this.shouldParseEnums() && this.state.value === "enum"))
+ (this.shouldParseEnums() && this.state.value === "enum")
+ )
) {
return false;
}
@@ -2068,10 +2078,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
assertModuleNodeAllowed(node: N.Node) {
if (
- (node.type === "ImportDeclaration" &&
- (node.importKind === "type" || node.importKind === "typeof")) ||
- (node.type === "ExportNamedDeclaration" &&
- node.exportKind === "type") ||
+ (
+ node.type === "ImportDeclaration" &&
+ (node.importKind === "type" || node.importKind === "typeof")
+ ) ||
+ (
+ node.type === "ExportNamedDeclaration" &&
+ node.exportKind === "type"
+ ) ||
(node.type === "ExportAllDeclaration" && node.exportKind === "type")
) {
// Allow Flowtype imports and exports in all conditions because
diff --git ORI/babel/packages/babel-parser/src/plugins/typescript/index.js ALT/babel/packages/babel-parser/src/plugins/typescript/index.js
index a562e8cb..cabce09f 100644
--- ORI/babel/packages/babel-parser/src/plugins/typescript/index.js
+++ ALT/babel/packages/babel-parser/src/plugins/typescript/index.js
@@ -178,12 +178,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// TODO: Would be nice to avoid lookahead. Want a hasLineBreakUpNext() method...
this.next();
return (
- (this.match(tt.bracketL) ||
+ (
+ this.match(tt.bracketL) ||
this.match(tt.braceL) ||
this.match(tt.star) ||
this.match(tt.ellipsis) ||
this.match(tt.hash) ||
- this.isLiteralPropertyName()) &&
+ this.isLiteralPropertyName()
+ ) &&
!this.hasPrecedingLineBreak()
);
}
@@ -2378,9 +2380,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
if (
declaration &&
- (declaration.type === "TSInterfaceDeclaration" ||
+ (
+ declaration.type === "TSInterfaceDeclaration" ||
declaration.type === "TSTypeAliasDeclaration" ||
- isDeclare)
+ isDeclare
+ )
) {
node.exportKind = "type";
}
diff --git ORI/babel/packages/babel-parser/src/tokenizer/index.js ALT/babel/packages/babel-parser/src/tokenizer/index.js
index 7c119c7d..8fb05c39 100644
--- ORI/babel/packages/babel-parser/src/tokenizer/index.js
+++ ALT/babel/packages/babel-parser/src/tokenizer/index.js
@@ -1268,9 +1268,10 @@ export default class Tokenizer extends ParserErrors {
const ch = this.input.charCodeAt(this.state.pos);
if (
ch === charCodes.graveAccent ||
- (ch === charCodes.dollarSign &&
- this.input.charCodeAt(this.state.pos + 1) ===
- charCodes.leftCurlyBrace)
+ (
+ ch === charCodes.dollarSign &&
+ this.input.charCodeAt(this.state.pos + 1) === charCodes.leftCurlyBrace
+ )
) {
if (this.state.pos === this.state.start && this.match(tt.template)) {
if (ch === charCodes.dollarSign) {
diff --git ORI/babel/packages/babel-parser/src/util/scope.js ALT/babel/packages/babel-parser/src/util/scope.js
index bd3fc8cc..f00f24bd 100644
--- ORI/babel/packages/babel-parser/src/util/scope.js
+++ ALT/babel/packages/babel-parser/src/util/scope.js
@@ -160,16 +160,22 @@ export default class ScopeHandler<IScope: Scope = Scope> {
if (bindingType & BIND_SCOPE_FUNCTION) {
return (
scope.lexical.indexOf(name) > -1 ||
- (!this.treatFunctionsAsVarInScope(scope) &&
- scope.var.indexOf(name) > -1)
+ (
+ !this.treatFunctionsAsVarInScope(scope) &&
+ scope.var.indexOf(name) > -1
+ )
);
}
return (
- (scope.lexical.indexOf(name) > -1 &&
- !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||
- (!this.treatFunctionsAsVarInScope(scope) &&
- scope.functions.indexOf(name) > -1)
+ (
+ scope.lexical.indexOf(name) > -1 &&
+ !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)
+ ) ||
+ (
+ !this.treatFunctionsAsVarInScope(scope) &&
+ scope.functions.indexOf(name) > -1
+ )
);
}
diff --git ORI/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js ALT/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js
index 2f353271..f7f6dfec 100644
--- ORI/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js
+++ ALT/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js
@@ -67,9 +67,11 @@ export default declare((api, opts) => {
const parentType = path.parent.type;
if (
(parentType === "AssignmentPattern" && path.key === "right") ||
- (parentType === "ObjectProperty" &&
+ (
+ parentType === "ObjectProperty" &&
path.parent.computed &&
- path.key === "key")
+ path.key === "key"
+ )
) {
path.skip();
}
diff --git ORI/babel/packages/babel-plugin-proposal-optional-chaining/src/transform.js ALT/babel/packages/babel-plugin-proposal-optional-chaining/src/transform.js
index 656b4ea0..69e6bbbc 100644
--- ORI/babel/packages/babel-plugin-proposal-optional-chaining/src/transform.js
+++ ALT/babel/packages/babel-plugin-proposal-optional-chaining/src/transform.js
@@ -12,9 +12,11 @@ function isSimpleMemberExpression(expression) {
return (
t.isIdentifier(expression) ||
t.isSuper(expression) ||
- (t.isMemberExpression(expression) &&
+ (
+ t.isMemberExpression(expression) &&
!expression.computed &&
- isSimpleMemberExpression(expression.object))
+ isSimpleMemberExpression(expression.object)
+ )
);
}
diff --git ORI/babel/packages/babel-plugin-transform-instanceof/src/index.js ALT/babel/packages/babel-plugin-transform-instanceof/src/index.js
index 442bd3f8..3c306aaf 100644
--- ORI/babel/packages/babel-plugin-transform-instanceof/src/index.js
+++ ALT/babel/packages/babel-plugin-transform-instanceof/src/index.js
@@ -15,9 +15,11 @@ export default declare(api => {
const isUnderHelper = path.findParent(path => {
return (
(path.isVariableDeclarator() && path.node.id === helper) ||
- (path.isFunctionDeclaration() &&
+ (
+ path.isFunctionDeclaration() &&
path.node.id &&
- path.node.id.name === helper.name)
+ path.node.id.name === helper.name
+ )
);
});
diff --git ORI/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js ALT/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js
index 0004c3c7..a5ec930d 100644
--- ORI/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js
+++ ALT/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js
@@ -75,8 +75,10 @@ export default declare((api, options) => {
if (
// redeclared in this scope
rootBinding !== localBinding ||
- (path.parentPath.isObjectProperty({ value: path.node }) &&
- path.parentPath.parentPath.isObjectPattern()) ||
+ (
+ path.parentPath.isObjectProperty({ value: path.node }) &&
+ path.parentPath.parentPath.isObjectPattern()
+ ) ||
path.parentPath.isAssignmentExpression({ left: path.node }) ||
path.isAssignmentExpression({ left: path.node })
) {
diff --git ORI/babel/packages/babel-plugin-transform-parameters/src/params.js ALT/babel/packages/babel-plugin-transform-parameters/src/params.js
index aac3e64b..da94d6ff 100644
--- ORI/babel/packages/babel-plugin-transform-parameters/src/params.js
+++ ALT/babel/packages/babel-plugin-transform-parameters/src/params.js
@@ -29,8 +29,10 @@ const iifeVisitor = {
if (
name === "eval" ||
- (scope.getBinding(name) === state.scope.parent.getBinding(name) &&
- state.scope.hasOwnBinding(name))
+ (
+ scope.getBinding(name) === state.scope.parent.getBinding(name) &&
+ state.scope.hasOwnBinding(name)
+ )
) {
state.needsOuterBinding = true;
path.stop();
diff --git ORI/babel/packages/babel-plugin-transform-parameters/src/rest.js ALT/babel/packages/babel-plugin-transform-parameters/src/rest.js
index cfba76ce..301ac7f0 100644
--- ORI/babel/packages/babel-plugin-transform-parameters/src/rest.js
+++ ALT/babel/packages/babel-plugin-transform-parameters/src/rest.js
@@ -90,8 +90,10 @@ const memberExpressionOptimisationVisitor = {
!(
// ex: `args[0] = "whatever"`
(
- (grandparentPath.isAssignmentExpression() &&
- parentPath.node === grandparentPath.node.left) ||
+ (
+ grandparentPath.isAssignmentExpression() &&
+ parentPath.node === grandparentPath.node.left
+ ) ||
// ex: `[args[0]] = ["whatever"]`
grandparentPath.isLVal() ||
// ex: `for (rest[0] in this)`
@@ -105,9 +107,13 @@ const memberExpressionOptimisationVisitor = {
// ex: `args[0]()`
// ex: `new args[0]()`
// ex: `new args[0]`
- ((grandparentPath.isCallExpression() ||
- grandparentPath.isNewExpression()) &&
- parentPath.node === grandparentPath.node.callee)
+ (
+ (
+ grandparentPath.isCallExpression() ||
+ grandparentPath.isNewExpression()
+ ) &&
+ parentPath.node === grandparentPath.node.callee
+ )
)
);
diff --git ORI/babel/packages/babel-plugin-transform-react-constant-elements/src/index.js ALT/babel/packages/babel-plugin-transform-react-constant-elements/src/index.js
index 2e486772..552401a2 100644
--- ORI/babel/packages/babel-plugin-transform-react-constant-elements/src/index.js
+++ ALT/babel/packages/babel-plugin-transform-react-constant-elements/src/index.js
@@ -82,9 +82,11 @@ export default declare((api, options) => {
// We know the result; check its mutability.
const { value } = expressionResult;
const isMutable =
- (!state.mutablePropsAllowed &&
+ (
+ !state.mutablePropsAllowed &&
value &&
- typeof value === "object") ||
+ typeof value === "object"
+ ) ||
typeof value === "function";
if (!isMutable) {
// It evaluated to an immutable value, so we can hoist it.
diff --git ORI/babel/packages/babel-plugin-transform-typeof-symbol/src/index.js ALT/babel/packages/babel-plugin-transform-typeof-symbol/src/index.js
index 1faea61b..68e6a1da 100644
--- ORI/babel/packages/babel-plugin-transform-typeof-symbol/src/index.js
+++ ALT/babel/packages/babel-plugin-transform-typeof-symbol/src/index.js
@@ -55,9 +55,11 @@ export default declare(api => {
isUnderHelper = path.findParent(path => {
return (
(path.isVariableDeclarator() && path.node.id === helper) ||
- (path.isFunctionDeclaration() &&
+ (
+ path.isFunctionDeclaration() &&
path.node.id &&
- path.node.id.name === helper.name)
+ path.node.id.name === helper.name
+ )
);
});
diff --git ORI/babel/packages/babel-plugin-transform-typescript/src/index.js ALT/babel/packages/babel-plugin-transform-typescript/src/index.js
index 4073d96c..429cc4e5 100644
--- ORI/babel/packages/babel-plugin-transform-typescript/src/index.js
+++ ALT/babel/packages/babel-plugin-transform-typescript/src/index.js
@@ -277,8 +277,10 @@ export default declare((api, opts) => {
stmt.isTSInterfaceDeclaration() ||
stmt.isClassDeclaration({ declare: true }) ||
stmt.isTSEnumDeclaration({ declare: true }) ||
- (stmt.isTSModuleDeclaration({ declare: true }) &&
- stmt.get("id").isIdentifier())
+ (
+ stmt.isTSModuleDeclaration({ declare: true }) &&
+ stmt.get("id").isIdentifier()
+ )
) {
registerGlobalType(path.scope, stmt.node.id.name);
}
diff --git ORI/babel/packages/babel-preset-env/src/index.js ALT/babel/packages/babel-preset-env/src/index.js
index 5e3a9e5e..9e11cc94 100644
--- ORI/babel/packages/babel-preset-env/src/index.js
+++ ALT/babel/packages/babel-preset-env/src/index.js
@@ -346,12 +346,14 @@ option \`forceAllTransforms: true\` instead.
const compatData = getPluginList(shippedProposals, bugfixes);
const shouldSkipExportNamespaceFrom =
(modules === "auto" && api.caller?.(supportsExportNamespaceFrom)) ||
- (modules === false &&
+ (
+ modules === false &&
!isRequired("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins,
- }));
+ })
+ );
const modulesPluginNames = getModulesPluginNames({
modules,
transformations: moduleTransformations,
prettier/prettier#11103 VS prettier/prettier@main :: vuejs/eslint-plugin-vue@62f577d
Diff (666 lines)
diff --git ORI/eslint-plugin-vue/eslint-internal-rules/require-meta-docs-url.js ALT/eslint-plugin-vue/eslint-internal-rules/require-meta-docs-url.js
index 88cd9de..d0e46b6 100644
--- ORI/eslint-plugin-vue/eslint-internal-rules/require-meta-docs-url.js
+++ ALT/eslint-plugin-vue/eslint-internal-rules/require-meta-docs-url.js
@@ -27,8 +27,10 @@ const path = require('path')
*/
function isNormalFunctionExpression(node) {
return (
- (node.type === 'FunctionExpression' ||
- node.type === 'ArrowFunctionExpression') &&
+ (
+ node.type === 'FunctionExpression' ||
+ node.type === 'ArrowFunctionExpression'
+ ) &&
!node.generator &&
!node.async
)
diff --git ORI/eslint-plugin-vue/lib/rules/attributes-order.js ALT/eslint-plugin-vue/lib/rules/attributes-order.js
index 5af387d..9515257 100644
--- ORI/eslint-plugin-vue/lib/rules/attributes-order.js
+++ ALT/eslint-plugin-vue/lib/rules/attributes-order.js
@@ -298,8 +298,10 @@ function create(context) {
const attributes = node.attributes.filter((node, index, attributes) => {
if (
isVBindObject(node) &&
- (isVAttributeOrVBind(attributes[index - 1]) ||
- isVAttributeOrVBind(attributes[index + 1]))
+ (
+ isVAttributeOrVBind(attributes[index - 1]) ||
+ isVAttributeOrVBind(attributes[index + 1])
+ )
) {
// In Vue 3, ignore the `v-bind:foo=" ... "` and `v-bind ="object"` syntax
// as they behave differently if you change the order.
diff --git ORI/eslint-plugin-vue/lib/rules/component-definition-name-casing.js ALT/eslint-plugin-vue/lib/rules/component-definition-name-casing.js
index 8e192df..93d0f3f 100644
--- ORI/eslint-plugin-vue/lib/rules/component-definition-name-casing.js
+++ ALT/eslint-plugin-vue/lib/rules/component-definition-name-casing.js
@@ -78,9 +78,11 @@ module.exports = {
function canConvert(node) {
return (
node.type === 'Literal' ||
- (node.type === 'TemplateLiteral' &&
+ (
+ node.type === 'TemplateLiteral' &&
node.expressions.length === 0 &&
- node.quasis.length === 1)
+ node.quasis.length === 1
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/html-comment-indent.js ALT/eslint-plugin-vue/lib/rules/html-comment-indent.js
index d5992b5..2aeb8b9 100644
--- ORI/eslint-plugin-vue/lib/rules/html-comment-indent.js
+++ ALT/eslint-plugin-vue/lib/rules/html-comment-indent.js
@@ -193,8 +193,10 @@ module.exports = {
// validate base indent
if (
baseIndentText &&
- (actualIndentText.length < baseIndentText.length ||
- !actualIndentText.startsWith(baseIndentText))
+ (
+ actualIndentText.length < baseIndentText.length ||
+ !actualIndentText.startsWith(baseIndentText)
+ )
) {
context.report({
loc: {
diff --git ORI/eslint-plugin-vue/lib/rules/match-component-file-name.js ALT/eslint-plugin-vue/lib/rules/match-component-file-name.js
index 8428516..541c926 100644
--- ORI/eslint-plugin-vue/lib/rules/match-component-file-name.js
+++ ALT/eslint-plugin-vue/lib/rules/match-component-file-name.js
@@ -113,9 +113,11 @@ module.exports = {
function canVerify(node) {
return (
node.type === 'Literal' ||
- (node.type === 'TemplateLiteral' &&
+ (
+ node.type === 'TemplateLiteral' &&
node.expressions.length === 0 &&
- node.quasis.length === 1)
+ node.quasis.length === 1
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/max-len.js ALT/eslint-plugin-vue/lib/rules/max-len.js
index 773b626..3668f87 100644
--- ORI/eslint-plugin-vue/lib/rules/max-len.js
+++ ALT/eslint-plugin-vue/lib/rules/max-len.js
@@ -115,8 +115,10 @@ function isTrailingComment(line, lineNumber, comment) {
comment &&
comment.loc.start.line === lineNumber &&
lineNumber <= comment.loc.end.line &&
- (comment.loc.end.line > lineNumber ||
- comment.loc.end.column === line.length)
+ (
+ comment.loc.end.line > lineNumber ||
+ comment.loc.end.column === line.length
+ )
)
}
@@ -137,10 +139,14 @@ function isFullLineComment(line, lineNumber, comment) {
return (
comment &&
- (start.line < lineNumber ||
- (start.line === lineNumber && isFirstTokenOnLine)) &&
- (end.line > lineNumber ||
- (end.line === lineNumber && end.column === line.length))
+ (
+ start.line < lineNumber ||
+ (start.line === lineNumber && isFirstTokenOnLine)
+ ) &&
+ (
+ end.line > lineNumber ||
+ (end.line === lineNumber && end.column === line.length)
+ )
)
}
@@ -290,9 +296,11 @@ module.exports = {
return tokens.filter(
(token) =>
token.type === 'String' ||
- (token.type === 'JSXText' &&
+ (
+ token.type === 'JSXText' &&
sourceCode.getNodeByRangeIndex(token.range[0] - 1).type ===
- 'JSXAttribute')
+ 'JSXAttribute'
+ )
)
}
@@ -453,8 +461,10 @@ module.exports = {
(ignoreStrings && stringsByLine[lineNumber]) ||
(ignoreTemplateLiterals && templateLiteralsByLine[lineNumber]) ||
(ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) ||
- (ignoreHTMLAttributeValues &&
- htmlAttributeValuesByLine[lineNumber]) ||
+ (
+ ignoreHTMLAttributeValues &&
+ htmlAttributeValuesByLine[lineNumber]
+ ) ||
(ignoreHTMLTextContents && htmlTextContentsByLine[lineNumber])
) {
// ignore this line
diff --git ORI/eslint-plugin-vue/lib/rules/next-tick-style.js ALT/eslint-plugin-vue/lib/rules/next-tick-style.js
index d015bb5..162ff57 100644
--- ORI/eslint-plugin-vue/lib/rules/next-tick-style.js
+++ ALT/eslint-plugin-vue/lib/rules/next-tick-style.js
@@ -78,9 +78,11 @@ function getVueNextTickCallExpression(identifier, context) {
function isAwaitedPromise(callExpression) {
return (
callExpression.parent.type === 'AwaitExpression' ||
- (callExpression.parent.type === 'MemberExpression' &&
+ (
+ callExpression.parent.type === 'MemberExpression' &&
callExpression.parent.property.type === 'Identifier' &&
- callExpression.parent.property.name === 'then')
+ callExpression.parent.property.name === 'then'
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/no-async-in-computed-properties.js ALT/eslint-plugin-vue/lib/rules/no-async-in-computed-properties.js
index b12fa34..8dd6b34 100644
--- ORI/eslint-plugin-vue/lib/rules/no-async-in-computed-properties.js
+++ ALT/eslint-plugin-vue/lib/rules/no-async-in-computed-properties.js
@@ -28,11 +28,15 @@ const TIMED_FUNCTIONS = new Set([
function isTimedFunction(node) {
const callee = utils.skipChainExpression(node.callee)
return (
- ((callee.type === 'Identifier' && TIMED_FUNCTIONS.has(callee.name)) ||
- (callee.type === 'MemberExpression' &&
+ (
+ (callee.type === 'Identifier' && TIMED_FUNCTIONS.has(callee.name)) ||
+ (
+ callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' &&
callee.object.name === 'window' &&
- TIMED_FUNCTIONS.has(utils.getStaticPropertyName(callee) || ''))) &&
+ TIMED_FUNCTIONS.has(utils.getStaticPropertyName(callee) || '')
+ )
+ ) &&
node.arguments.length > 0
)
}
@@ -47,11 +51,15 @@ function isPromise(node) {
return (
name &&
// hello.PROMISE_FUNCTION()
- (PROMISE_FUNCTIONS.has(name) ||
+ (
+ PROMISE_FUNCTIONS.has(name) ||
// Promise.PROMISE_METHOD()
- (callee.object.type === 'Identifier' &&
+ (
+ callee.object.type === 'Identifier' &&
callee.object.name === 'Promise' &&
- PROMISE_METHODS.has(name)))
+ PROMISE_METHODS.has(name)
+ )
+ )
)
}
return false
diff --git ORI/eslint-plugin-vue/lib/rules/no-duplicate-attributes.js ALT/eslint-plugin-vue/lib/rules/no-duplicate-attributes.js
index 4a3309b..3918f0a 100644
--- ORI/eslint-plugin-vue/lib/rules/no-duplicate-attributes.js
+++ ALT/eslint-plugin-vue/lib/rules/no-duplicate-attributes.js
@@ -26,9 +26,11 @@ function getName(attribute) {
}
if (attribute.key.name.name === 'bind') {
return (
- (attribute.key.argument &&
+ (
+ attribute.key.argument &&
attribute.key.argument.type === 'VIdentifier' &&
- attribute.key.argument.name) ||
+ attribute.key.argument.name
+ ) ||
null
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/no-ref-as-operand.js ALT/eslint-plugin-vue/lib/rules/no-ref-as-operand.js
index 465ec50..50b255e 100644
--- ORI/eslint-plugin-vue/lib/rules/no-ref-as-operand.js
+++ ALT/eslint-plugin-vue/lib/rules/no-ref-as-operand.js
@@ -91,9 +91,11 @@ module.exports = {
continue
}
const variableDeclaration =
- (variableDeclarator.parent &&
+ (
+ variableDeclarator.parent &&
variableDeclarator.parent.type === 'VariableDeclaration' &&
- variableDeclarator.parent) ||
+ variableDeclarator.parent
+ ) ||
null
for (const reference of variable.references) {
if (!reference.isRead()) {
diff --git ORI/eslint-plugin-vue/lib/rules/no-reserved-component-names.js ALT/eslint-plugin-vue/lib/rules/no-reserved-component-names.js
index 890f1a3..ed9c8eb 100644
--- ORI/eslint-plugin-vue/lib/rules/no-reserved-component-names.js
+++ ALT/eslint-plugin-vue/lib/rules/no-reserved-component-names.js
@@ -117,9 +117,11 @@ module.exports = {
function canVerify(node) {
return (
node.type === 'Literal' ||
- (node.type === 'TemplateLiteral' &&
+ (
+ node.type === 'TemplateLiteral' &&
node.expressions.length === 0 &&
- node.quasis.length === 1)
+ node.quasis.length === 1
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/no-unused-components.js ALT/eslint-plugin-vue/lib/rules/no-unused-components.js
index e067e3e..317b741 100644
--- ORI/eslint-plugin-vue/lib/rules/no-unused-components.js
+++ ALT/eslint-plugin-vue/lib/rules/no-unused-components.js
@@ -113,8 +113,10 @@ module.exports = {
return ![...usedComponents].some((n) => {
return (
n.indexOf('_') === -1 &&
- (name === casing.pascalCase(n) ||
- casing.camelCase(n) === name)
+ (
+ name === casing.pascalCase(n) ||
+ casing.camelCase(n) === name
+ )
)
})
} else {
diff --git ORI/eslint-plugin-vue/lib/rules/order-in-components.js ALT/eslint-plugin-vue/lib/rules/order-in-components.js
index 5f33734..3c00e38 100644
--- ORI/eslint-plugin-vue/lib/rules/order-in-components.js
+++ ALT/eslint-plugin-vue/lib/rules/order-in-components.js
@@ -175,12 +175,18 @@ function isNotSideEffectsNode(node, visitorKeys) {
node.type !== 'Property' &&
node.type !== 'ObjectExpression' &&
node.type !== 'ArrayExpression' &&
- (node.type !== 'UnaryExpression' ||
- !['!', '~', '+', '-', 'typeof'].includes(node.operator)) &&
- (node.type !== 'BinaryExpression' ||
- !ALL_BINARY_OPERATORS.includes(node.operator)) &&
- (node.type !== 'LogicalExpression' ||
- !LOGICAL_OPERATORS.includes(node.operator)) &&
+ (
+ node.type !== 'UnaryExpression' ||
+ !['!', '~', '+', '-', 'typeof'].includes(node.operator)
+ ) &&
+ (
+ node.type !== 'BinaryExpression' ||
+ !ALL_BINARY_OPERATORS.includes(node.operator)
+ ) &&
+ (
+ node.type !== 'LogicalExpression' ||
+ !LOGICAL_OPERATORS.includes(node.operator)
+ ) &&
node.type !== 'MemberExpression' &&
node.type !== 'ConditionalExpression' &&
// es2015
diff --git ORI/eslint-plugin-vue/lib/rules/require-default-prop.js ALT/eslint-plugin-vue/lib/rules/require-default-prop.js
index e0e29b6..8e16513 100644
--- ORI/eslint-plugin-vue/lib/rules/require-default-prop.js
+++ ALT/eslint-plugin-vue/lib/rules/require-default-prop.js
@@ -133,14 +133,16 @@ module.exports = {
return (
isValueNodeOfBooleanType(value) ||
- (value.type === 'ObjectExpression' &&
+ (
+ value.type === 'ObjectExpression' &&
value.properties.some(
(p) =>
p.type === 'Property' &&
p.key.type === 'Identifier' &&
p.key.name === 'type' &&
isValueNodeOfBooleanType(p.value)
- ))
+ )
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/require-direct-export.js ALT/eslint-plugin-vue/lib/rules/require-direct-export.js
index 18897eb..0998e9f 100644
--- ORI/eslint-plugin-vue/lib/rules/require-direct-export.js
+++ ALT/eslint-plugin-vue/lib/rules/require-direct-export.js
@@ -62,13 +62,17 @@ module.exports = {
} = node
if (firstArg && firstArg.type === 'ObjectExpression') {
if (
- (callee.type === 'Identifier' &&
- callee.name === 'defineComponent') ||
- (callee.type === 'MemberExpression' &&
+ (
+ callee.type === 'Identifier' &&
+ callee.name === 'defineComponent'
+ ) ||
+ (
+ callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' &&
callee.object.name === 'Vue' &&
callee.property.type === 'Identifier' &&
- callee.property.name === 'extend')
+ callee.property.name === 'extend'
+ )
) {
return
}
diff --git ORI/eslint-plugin-vue/lib/rules/sort-keys.js ALT/eslint-plugin-vue/lib/rules/sort-keys.js
index 664186b..99a2657 100644
--- ORI/eslint-plugin-vue/lib/rules/sort-keys.js
+++ ALT/eslint-plugin-vue/lib/rules/sort-keys.js
@@ -136,14 +136,10 @@ module.exports = {
const order = context.options[0] || 'asc'
/** @type {string[]} */
- const ignoreGrandchildrenOf = (options &&
- options.ignoreGrandchildrenOf) || [
- 'computed',
- 'directives',
- 'inject',
- 'props',
- 'watch'
- ]
+ const ignoreGrandchildrenOf = (
+ options &&
+ options.ignoreGrandchildrenOf
+ ) || ['computed', 'directives', 'inject', 'props', 'watch']
/** @type {string[]} */
const ignoreChildrenOf = (options && options.ignoreChildrenOf) || ['model']
const insensitive = options && options.caseSensitive === false
diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js
index d5fa618..0fe7a26 100644
--- ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js
+++ ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js
@@ -65,8 +65,10 @@ module.exports = {
(attr) =>
attr.directive === true &&
attr.key.name &&
- (attr.key.name.name === 'slot-scope' ||
- attr.key.name.name === 'scope')
+ (
+ attr.key.name.name === 'slot-scope' ||
+ attr.key.name.name === 'scope'
+ )
)
const nameArgument = slotName
? vBind
diff --git ORI/eslint-plugin-vue/lib/rules/v-on-function-call.js ALT/eslint-plugin-vue/lib/rules/v-on-function-call.js
index 90da5ed..c1f738c 100644
--- ORI/eslint-plugin-vue/lib/rules/v-on-function-call.js
+++ ALT/eslint-plugin-vue/lib/rules/v-on-function-call.js
@@ -195,8 +195,10 @@ module.exports = {
}
const value = method.property.value
if (
- (value.type === 'FunctionExpression' ||
- value.type === 'ArrowFunctionExpression') &&
+ (
+ value.type === 'FunctionExpression' ||
+ value.type === 'ArrowFunctionExpression'
+ ) &&
value.params.length > 0
) {
useArgsMethods.add(method.name)
diff --git ORI/eslint-plugin-vue/lib/rules/valid-v-model.js ALT/eslint-plugin-vue/lib/rules/valid-v-model.js
index adfe9c2..9e47bb6 100644
--- ORI/eslint-plugin-vue/lib/rules/valid-v-model.js
+++ ALT/eslint-plugin-vue/lib/rules/valid-v-model.js
@@ -28,11 +28,13 @@ function isValidElement(node) {
name === 'input' ||
name === 'select' ||
name === 'textarea' ||
- (name !== 'keep-alive' &&
+ (
+ name !== 'keep-alive' &&
name !== 'slot' &&
name !== 'transition' &&
name !== 'transition-group' &&
- utils.isCustomComponent(node))
+ utils.isCustomComponent(node)
+ )
)
}
diff --git ORI/eslint-plugin-vue/lib/rules/valid-v-slot.js ALT/eslint-plugin-vue/lib/rules/valid-v-slot.js
index 4914ede..4877e84 100644
--- ORI/eslint-plugin-vue/lib/rules/valid-v-slot.js
+++ ALT/eslint-plugin-vue/lib/rules/valid-v-slot.js
@@ -323,8 +323,10 @@ module.exports = {
"VAttribute[directive=true][key.name.name='slot']"(node) {
const isDefaultSlot =
node.key.argument == null ||
- (node.key.argument.type === 'VIdentifier' &&
- node.key.argument.name === 'default')
+ (
+ node.key.argument.type === 'VIdentifier' &&
+ node.key.argument.name === 'default'
+ )
const element = node.parent.parent
const parentElement = element.parent
const ownerElement =
@@ -418,9 +420,11 @@ module.exports = {
if (
ownerElement === element &&
isDefaultSlot &&
- (!node.value ||
+ (
+ !node.value ||
utils.isEmptyValueDirective(node, context) ||
- utils.isEmptyExpressionValueDirective(node, context))
+ utils.isEmptyExpressionValueDirective(node, context)
+ )
) {
context.report({
node,
diff --git ORI/eslint-plugin-vue/lib/utils/indent-common.js ALT/eslint-plugin-vue/lib/utils/indent-common.js
index 5f1e236..5321683 100644
--- ORI/eslint-plugin-vue/lib/utils/indent-common.js
+++ ALT/eslint-plugin-vue/lib/utils/indent-common.js
@@ -331,12 +331,16 @@ function isNotWhitespace(token) {
function isComment(token) {
return (
token != null &&
- (token.type === 'Block' ||
+ (
+ token.type === 'Block' ||
token.type === 'Line' ||
token.type === 'Shebang' ||
- (typeof token.type ===
- 'string' /* Although acorn supports new tokens, espree may not yet support new tokens.*/ &&
- token.type.endsWith('Comment')))
+ (
+ typeof token.type ===
+ 'string' /* Although acorn supports new tokens, espree may not yet support new tokens.*/ &&
+ token.type.endsWith('Comment')
+ )
+ )
)
}
@@ -416,10 +420,14 @@ function isBeginningOfLine(node, index, nodes) {
function isClosingToken(token) {
return (
token != null &&
- (token.type === 'HTMLEndTagOpen' ||
+ (
+ token.type === 'HTMLEndTagOpen' ||
token.type === 'VExpressionEnd' ||
- (token.type === 'Punctuator' &&
- (token.value === ')' || token.value === '}' || token.value === ']')))
+ (
+ token.type === 'Punctuator' &&
+ (token.value === ')' || token.value === '}' || token.value === ']')
+ )
+ )
)
}
@@ -504,11 +512,13 @@ module.exports.defineVisitor = function create(
includeComments: true,
filter: (token) =>
token != null &&
- (token.type === 'HTMLText' ||
+ (
+ token.type === 'HTMLText' ||
token.type === 'HTMLRCDataText' ||
token.type === 'HTMLTagOpen' ||
token.type === 'HTMLEndTagOpen' ||
- token.type === 'HTMLComment')
+ token.type === 'HTMLComment'
+ )
}
for (const token of tokenStore.getTokensBetween(
node.startTag,
@@ -964,8 +974,10 @@ module.exports.defineVisitor = function create(
if (
actualIndent !== expectedIndent &&
- (optionalExpectedIndents == null ||
- !optionalExpectedIndents.includes(actualIndent))
+ (
+ optionalExpectedIndents == null ||
+ !optionalExpectedIndents.includes(actualIndent)
+ )
) {
context.report({
loc: {
@@ -1325,11 +1337,17 @@ module.exports.defineVisitor = function create(
/** @param {BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement} node */
'BreakStatement, ContinueStatement, ReturnStatement, ThrowStatement'(node) {
if (
- ((node.type === 'ReturnStatement' || node.type === 'ThrowStatement') &&
- node.argument != null) ||
- ((node.type === 'BreakStatement' ||
- node.type === 'ContinueStatement') &&
- node.label != null)
+ (
+ (node.type === 'ReturnStatement' || node.type === 'ThrowStatement') &&
+ node.argument != null
+ ) ||
+ (
+ (
+ node.type === 'BreakStatement' ||
+ node.type === 'ContinueStatement'
+ ) &&
+ node.label != null
+ )
) {
const firstToken = tokenStore.getFirstToken(node)
const nextToken = tokenStore.getTokenAfter(firstToken)
@@ -1505,9 +1523,11 @@ module.exports.defineVisitor = function create(
'ForInStatement, ForOfStatement'(node) {
const forToken = tokenStore.getFirstToken(node)
const awaitToken =
- (node.type === 'ForOfStatement' &&
+ (
+ node.type === 'ForOfStatement' &&
node.await &&
- tokenStore.getTokenAfter(forToken)) ||
+ tokenStore.getTokenAfter(forToken)
+ ) ||
null
const leftParenToken = tokenStore.getTokenAfter(awaitToken || forToken)
const leftToken = tokenStore.getTokenAfter(leftParenToken)
diff --git ORI/eslint-plugin-vue/lib/utils/index.js ALT/eslint-plugin-vue/lib/utils/index.js
index e78238e..397f793 100644
--- ORI/eslint-plugin-vue/lib/utils/index.js
+++ ALT/eslint-plugin-vue/lib/utils/index.js
@@ -473,8 +473,10 @@ module.exports = {
return (
!node.directive &&
node.key.name === name &&
- (value === undefined ||
- (node.value != null && node.value.value === value))
+ (
+ value === undefined ||
+ (node.value != null && node.value.value === value)
+ )
)
}
) || null
@@ -518,10 +520,12 @@ module.exports = {
return (
node.directive &&
node.key.name.name === name &&
- (argument === undefined ||
+ (
+ argument === undefined ||
(node.key.argument &&
node.key.argument.type === 'VIdentifier' &&
- node.key.argument.name) === argument)
+ node.key.argument.name) === argument
+ )
)
}
) || null
@@ -585,10 +589,14 @@ module.exports = {
*/
isCustomComponent(node) {
return (
- (this.isHtmlElementNode(node) &&
- !this.isHtmlWellKnownElementName(node.rawName)) ||
- (this.isSvgElementNode(node) &&
- !this.isSvgWellKnownElementName(node.rawName)) ||
+ (
+ this.isHtmlElementNode(node) &&
+ !this.isHtmlWellKnownElementName(node.rawName)
+ ) ||
+ (
+ this.isSvgElementNode(node) &&
+ !this.isSvgWellKnownElementName(node.rawName)
+ ) ||
this.hasAttribute(node, 'is') ||
this.hasDirective(node, 'bind', 'is') ||
this.hasDirective(node, 'is')
@@ -675,8 +683,10 @@ module.exports = {
return (
p.type === 'Property' &&
getStaticPropertyName(p) === 'props' &&
- (p.value.type === 'ObjectExpression' ||
- p.value.type === 'ArrayExpression')
+ (
+ p.value.type === 'ObjectExpression' ||
+ p.value.type === 'ArrayExpression'
+ )
)
}
)
@@ -745,8 +755,10 @@ module.exports = {
return (
p.type === 'Property' &&
getStaticPropertyName(p) === 'emits' &&
- (p.value.type === 'ObjectExpression' ||
- p.value.type === 'ArrayExpression')
+ (
+ p.value.type === 'ObjectExpression' ||
+ p.value.type === 'ArrayExpression'
+ )
)
}
)
@@ -1905,9 +1917,11 @@ function getVueComponentDefinitionType(node) {
propName && isObjectArgument(parent)
return maybeFullVueComponentForVue2 &&
- (propName === 'component' ||
+ (
+ propName === 'component' ||
propName === 'mixin' ||
- propName === 'extend')
+ propName === 'extend'
+ )
? propName
: null
}
prettier/prettier#11103 VS prettier/prettier@main :: excalidraw/excalidraw@25fd275
Diff (448 lines)
diff --git ORI/excalidraw/src/actions/actionFinalize.tsx ALT/excalidraw/src/actions/actionFinalize.tsx
index 54ad8fd..e3dad74 100644
--- ORI/excalidraw/src/actions/actionFinalize.tsx
+++ ALT/excalidraw/src/actions/actionFinalize.tsx
@@ -153,11 +153,17 @@ export const actionFinalize = register({
};
},
keyTest: (event, appState) =>
- (event.key === KEYS.ESCAPE &&
- (appState.editingLinearElement !== null ||
- (!appState.draggingElement && appState.multiElement === null))) ||
- ((event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) &&
- appState.multiElement !== null),
+ (
+ event.key === KEYS.ESCAPE &&
+ (
+ appState.editingLinearElement !== null ||
+ (!appState.draggingElement && appState.multiElement === null)
+ )
+ ) ||
+ (
+ (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) &&
+ appState.multiElement !== null
+ ),
PanelComponent: ({ appState, updateData }) => (
<ToolButton
type="button"
diff --git ORI/excalidraw/src/actions/actionHistory.tsx ALT/excalidraw/src/actions/actionHistory.tsx
index c0971c2..535f1da 100644
--- ORI/excalidraw/src/actions/actionHistory.tsx
+++ ALT/excalidraw/src/actions/actionHistory.tsx
@@ -85,9 +85,11 @@ export const createRedoAction: ActionCreator = (history) => ({
perform: (elements, appState) =>
writeData(elements, appState, () => history.redoOnce()),
keyTest: (event) =>
- (event[KEYS.CTRL_OR_CMD] &&
+ (
+ event[KEYS.CTRL_OR_CMD] &&
event.shiftKey &&
- event.key.toLowerCase() === KEYS.Z) ||
+ event.key.toLowerCase() === KEYS.Z
+ ) ||
(isWindows && event.ctrlKey && !event.shiftKey && event.key === KEYS.Y),
PanelComponent: ({ updateData }) => (
<ToolButton
diff --git ORI/excalidraw/src/actions/actionProperties.tsx ALT/excalidraw/src/actions/actionProperties.tsx
index 07072ba..bc51866 100644
--- ORI/excalidraw/src/actions/actionProperties.tsx
+++ ALT/excalidraw/src/actions/actionProperties.tsx
@@ -626,10 +626,12 @@ export const actionChangeSharpness = register({
elements,
appState,
(element) => element.strokeSharpness,
- (canChangeSharpness(appState.elementType) &&
+ (
+ canChangeSharpness(appState.elementType) &&
(isLinearElementType(appState.elementType)
? appState.currentItemLinearStrokeSharpness
- : appState.currentItemStrokeSharpness)) ||
+ : appState.currentItemStrokeSharpness)
+ ) ||
null,
)}
onChange={(value) => updateData(value)}
diff --git ORI/excalidraw/src/appState.ts ALT/excalidraw/src/appState.ts
index aa0351e..73ccf68 100644
--- ORI/excalidraw/src/appState.ts
+++ ALT/excalidraw/src/appState.ts
@@ -89,8 +89,9 @@ const APP_STATE_STORAGE_CONF = (<
export: boolean;
},
T extends Record<keyof AppState, Values>,
->(config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }) =>
- config)({
+>(
+ config: { [K in keyof T]: K extends keyof AppState ? T[K] : never },
+) => config)({
theme: { browser: true, export: false },
collaborators: { browser: false, export: false },
currentChartType: { browser: true, export: false },
diff --git ORI/excalidraw/src/components/Actions.tsx ALT/excalidraw/src/components/Actions.tsx
index 03ecd51..1a1d12f 100644
--- ORI/excalidraw/src/components/Actions.tsx
+++ ALT/excalidraw/src/components/Actions.tsx
@@ -53,8 +53,10 @@ export const SelectedShapeActions = ({
{showChangeBackgroundIcons && renderAction("changeBackgroundColor")}
{showFillIcons && renderAction("changeFillStyle")}
- {(hasStroke(elementType) ||
- targetElements.some((element) => hasStroke(element.type))) && (
+ {(
+ hasStroke(elementType) ||
+ targetElements.some((element) => hasStroke(element.type))
+ ) && (
<>
{renderAction("changeStrokeWidth")}
{renderAction("changeStrokeStyle")}
@@ -62,13 +64,15 @@ export const SelectedShapeActions = ({
</>
)}
- {(canChangeSharpness(elementType) ||
- targetElements.some((element) => canChangeSharpness(element.type))) && (
- <>{renderAction("changeSharpness")}</>
- )}
+ {(
+ canChangeSharpness(elementType) ||
+ targetElements.some((element) => canChangeSharpness(element.type))
+ ) && <>{renderAction("changeSharpness")}</>}
- {(hasText(elementType) ||
- targetElements.some((element) => hasText(element.type))) && (
+ {(
+ hasText(elementType) ||
+ targetElements.some((element) => hasText(element.type))
+ ) && (
<>
{renderAction("changeFontSize")}
@@ -78,10 +82,10 @@ export const SelectedShapeActions = ({
</>
)}
- {(canHaveArrowheads(elementType) ||
- targetElements.some((element) => canHaveArrowheads(element.type))) && (
- <>{renderAction("changeArrowhead")}</>
- )}
+ {(
+ canHaveArrowheads(elementType) ||
+ targetElements.some((element) => canHaveArrowheads(element.type))
+ ) && <>{renderAction("changeArrowhead")}</>}
{renderAction("changeOpacity")}
diff --git ORI/excalidraw/src/components/App.tsx ALT/excalidraw/src/components/App.tsx
index 22949b1..1f271ae 100644
--- ORI/excalidraw/src/components/App.tsx
+++ ALT/excalidraw/src/components/App.tsx
@@ -1159,8 +1159,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
// if no ClipboardEvent supplied, assume we're pasting via contextMenu
// thus these checks don't make sense
event &&
- (!(elementUnderCursor instanceof HTMLCanvasElement) ||
- isWritableElement(target))
+ (
+ !(elementUnderCursor instanceof HTMLCanvasElement) ||
+ isWritableElement(target)
+ )
) {
return;
}
@@ -1386,8 +1388,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
// normalize `event.key` when CapsLock is pressed #2372
if (
"Proxy" in window &&
- ((!event.shiftKey && /^[A-Z]$/.test(event.key)) ||
- (event.shiftKey && /^[a-z]$/.test(event.key)))
+ (
+ (!event.shiftKey && /^[A-Z]$/.test(event.key)) ||
+ (event.shiftKey && /^[a-z]$/.test(event.key))
+ )
) {
event = new Proxy(event, {
get(ev: any, prop) {
@@ -1439,8 +1443,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
if (isArrowKey(event.key)) {
const step =
- (this.state.gridSize &&
- (event.shiftKey ? ELEMENT_TRANSLATE_AMOUNT : this.state.gridSize)) ||
+ (
+ this.state.gridSize &&
+ (event.shiftKey ? ELEMENT_TRANSLATE_AMOUNT : this.state.gridSize)
+ ) ||
(event.shiftKey
? ELEMENT_SHIFT_TRANSLATE_AMOUNT
: ELEMENT_TRANSLATE_AMOUNT);
@@ -2079,8 +2085,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const hasDeselectedButton = Boolean(event.buttons);
if (
hasDeselectedButton ||
- (this.state.elementType !== "selection" &&
- this.state.elementType !== "text")
+ (
+ this.state.elementType !== "selection" &&
+ this.state.elementType !== "text"
+ )
) {
return;
}
@@ -2305,9 +2313,11 @@ class App extends React.Component<ExcalidrawProps, AppState> {
if (
!(
gesture.pointers.size === 0 &&
- (event.button === POINTER_BUTTON.WHEEL ||
+ (
+ event.button === POINTER_BUTTON.WHEEL ||
(event.button === POINTER_BUTTON.MAIN && isHoldingSpace) ||
- this.state.viewModeEnabled)
+ this.state.viewModeEnabled
+ )
)
) {
return false;
@@ -2943,8 +2953,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
// triggering pointermove)
if (
!pointerDownState.drag.hasOccurred &&
- (this.state.elementType === "arrow" ||
- this.state.elementType === "line")
+ (
+ this.state.elementType === "arrow" ||
+ this.state.elementType === "line"
+ )
) {
if (
distance2d(
@@ -3047,8 +3059,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
this.state.selectedElementIds[element.id] ||
// case: the state.selectedElementIds might not have been
// updated yet by the time this mousemove event is fired
- (element.id === hitElement?.id &&
- pointerDownState.hit.wasAddedToSelection)
+ (
+ element.id === hitElement?.id &&
+ pointerDownState.hit.wasAddedToSelection
+ )
) {
const duplicatedElement = duplicateElement(
this.state.editingGroupId,
@@ -3439,15 +3453,21 @@ class App extends React.Component<ExcalidrawProps, AppState> {
!this.state.editingLinearElement &&
!pointerDownState.drag.hasOccurred &&
!this.state.isResizing &&
- ((hitElement &&
- isHittingElementBoundingBoxWithoutHittingElement(
- hitElement,
- this.state,
- pointerDownState.origin.x,
- pointerDownState.origin.y,
- )) ||
- (!hitElement &&
- pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements))
+ (
+ (
+ hitElement &&
+ isHittingElementBoundingBoxWithoutHittingElement(
+ hitElement,
+ this.state,
+ pointerDownState.origin.x,
+ pointerDownState.origin.y,
+ )
+ ) ||
+ (
+ !hitElement &&
+ pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements
+ )
+ )
) {
// Deselect selected elements
this.setState({
@@ -3868,8 +3888,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
probablySupportsClipboardWriteText &&
elements.length > 0 &&
actionCopyAsSvg,
- ((probablySupportsClipboardBlob && elements.length > 0) ||
- (probablySupportsClipboardWriteText && elements.length > 0)) &&
+ (
+ (probablySupportsClipboardBlob && elements.length > 0) ||
+ (probablySupportsClipboardWriteText && elements.length > 0)
+ ) &&
separator,
actionSelectAll,
separator,
diff --git ORI/excalidraw/src/components/LayerUI.tsx ALT/excalidraw/src/components/LayerUI.tsx
index b976f38..dd2d5e3 100644
--- ORI/excalidraw/src/components/LayerUI.tsx
+++ ALT/excalidraw/src/components/LayerUI.tsx
@@ -79,8 +79,10 @@ const useOnClickOutside = (
if (
event.target instanceof Element &&
- (ref.current.contains(event.target) ||
- !document.body.contains(event.target))
+ (
+ ref.current.contains(event.target) ||
+ !document.body.contains(event.target)
+ )
) {
return;
}
diff --git ORI/excalidraw/src/data/json.ts ALT/excalidraw/src/data/json.ts
index 4ecaccb..e545ed5 100644
--- ORI/excalidraw/src/data/json.ts
+++ ALT/excalidraw/src/data/json.ts
@@ -70,9 +70,13 @@ export const isValidExcalidrawData = (data?: {
}): data is ImportedDataState => {
return (
data?.type === EXPORT_DATA_TYPES.excalidraw &&
- (!data.elements ||
- (Array.isArray(data.elements) &&
- (!data.appState || typeof data.appState === "object")))
+ (
+ !data.elements ||
+ (
+ Array.isArray(data.elements) &&
+ (!data.appState || typeof data.appState === "object")
+ )
+ )
);
};
diff --git ORI/excalidraw/src/element/resizeElements.ts ALT/excalidraw/src/element/resizeElements.ts
index 6279978..f635ff1 100644
--- ORI/excalidraw/src/element/resizeElements.ts
+++ ALT/excalidraw/src/element/resizeElements.ts
@@ -65,10 +65,12 @@ export const transformElements = (
} else if (
isLinearElement(element) &&
element.points.length === 2 &&
- (transformHandleType === "nw" ||
+ (
+ transformHandleType === "nw" ||
transformHandleType === "ne" ||
transformHandleType === "sw" ||
- transformHandleType === "se")
+ transformHandleType === "se"
+ )
) {
reshapeSingleTwoPointElement(
element,
@@ -79,10 +81,12 @@ export const transformElements = (
);
} else if (
isTextElement(element) &&
- (transformHandleType === "nw" ||
+ (
+ transformHandleType === "nw" ||
transformHandleType === "ne" ||
transformHandleType === "sw" ||
- transformHandleType === "se")
+ transformHandleType === "se"
+ )
) {
resizeSingleTextElement(
element,
diff --git ORI/excalidraw/src/element/showSelectedShapeActions.ts ALT/excalidraw/src/element/showSelectedShapeActions.ts
index 5452898..212aa3b 100644
--- ORI/excalidraw/src/element/showSelectedShapeActions.ts
+++ ALT/excalidraw/src/element/showSelectedShapeActions.ts
@@ -8,7 +8,9 @@ export const showSelectedShapeActions = (
) =>
Boolean(
!appState.viewModeEnabled &&
- (appState.editingElement ||
+ (
+ appState.editingElement ||
getSelectedElements(elements, appState).length ||
- appState.elementType !== "selection"),
+ appState.elementType !== "selection"
+ ),
);
diff --git ORI/excalidraw/src/element/textWysiwyg.tsx ALT/excalidraw/src/element/textWysiwyg.tsx
index 862a957..7679ba6 100644
--- ORI/excalidraw/src/element/textWysiwyg.tsx
+++ ALT/excalidraw/src/element/textWysiwyg.tsx
@@ -207,8 +207,10 @@ export const textWysiwyg = ({
// prevent blur when changing properties from the menu
const onPointerDown = (event: MouseEvent) => {
if (
- (event.target instanceof HTMLElement ||
- event.target instanceof SVGElement) &&
+ (
+ event.target instanceof HTMLElement ||
+ event.target instanceof SVGElement
+ ) &&
event.target.closest(`.${CLASSES.SHAPE_ACTIONS_MENU}`) &&
!isWritableElement(event.target)
) {
diff --git ORI/excalidraw/src/element/transformHandles.ts ALT/excalidraw/src/element/transformHandles.ts
index 55d40ed..1a8b546 100644
--- ORI/excalidraw/src/element/transformHandles.ts
+++ ALT/excalidraw/src/element/transformHandles.ts
@@ -17,9 +17,11 @@ export type TransformHandleDirection =
export type TransformHandleType = TransformHandleDirection | "rotation";
export type TransformHandle = [number, number, number, number];
-export type TransformHandles = Partial<{
- [T in TransformHandleType]: TransformHandle;
-}>;
+export type TransformHandles = Partial<
+ {
+ [T in TransformHandleType]: TransformHandle;
+ }
+>;
export type MaybeTransformHandleType = TransformHandleType | false;
const transformHandleSizes: { [k in PointerType]: number } = {
diff --git ORI/excalidraw/src/element/typeChecks.ts ALT/excalidraw/src/element/typeChecks.ts
index 97b008b..8507404 100644
--- ORI/excalidraw/src/element/typeChecks.ts
+++ ALT/excalidraw/src/element/typeChecks.ts
@@ -11,10 +11,12 @@ export const isGenericElement = (
): element is ExcalidrawGenericElement => {
return (
element != null &&
- (element.type === "selection" ||
+ (
+ element.type === "selection" ||
element.type === "rectangle" ||
element.type === "diamond" ||
- element.type === "ellipse")
+ element.type === "ellipse"
+ )
);
};
@@ -55,10 +57,12 @@ export const isBindableElement = (
): element is ExcalidrawBindableElement => {
return (
element != null &&
- (element.type === "rectangle" ||
+ (
+ element.type === "rectangle" ||
element.type === "diamond" ||
element.type === "ellipse" ||
- element.type === "text")
+ element.type === "text"
+ )
);
};
diff --git ORI/excalidraw/src/utils.ts ALT/excalidraw/src/utils.ts
index a10da4c..bd2476f 100644
--- ORI/excalidraw/src/utils.ts
+++ ALT/excalidraw/src/utils.ts
@@ -65,8 +65,10 @@ export const isWritableElement = (
(target instanceof HTMLElement && target.dataset.type === "wysiwyg") ||
target instanceof HTMLBRElement || // newline in wysiwyg
target instanceof HTMLTextAreaElement ||
- (target instanceof HTMLInputElement &&
- (target.type === "text" || target.type === "number"));
+ (
+ target instanceof HTMLInputElement &&
+ (target.type === "text" || target.type === "number")
+ );
export const getFontFamilyString = ({
fontFamily,
prettier/prettier#11103 VS prettier/prettier@main :: prettier/prettier@5f8bad8
Diff (3022 lines)
diff --git ORI/prettier/scripts/build/bundler.js ALT/prettier/scripts/build/bundler.js
index c23e912..c8e3de5 100644
--- ORI/prettier/scripts/build/bundler.js
+++ ALT/prettier/scripts/build/bundler.js
@@ -131,9 +131,13 @@ function getRollupConfig(bundle) {
warning.code === "EVAL" ||
// ignore `MIXED_EXPORTS` warn
warning.code === "MIXED_EXPORTS" ||
- (warning.code === "CIRCULAR_DEPENDENCY" &&
- (warning.importer.startsWith("node_modules") ||
- warning.importer.startsWith("\x00polyfill-node:"))) ||
+ (
+ warning.code === "CIRCULAR_DEPENDENCY" &&
+ (
+ warning.importer.startsWith("node_modules") ||
+ warning.importer.startsWith("\x00polyfill-node:")
+ )
+ ) ||
warning.code === "SOURCEMAP_ERROR" ||
warning.code === "THIS_IS_UNDEFINED"
) {
diff --git ORI/prettier/src/cli/create-minimist-options.js ALT/prettier/src/cli/create-minimist-options.js
index 91b8d1c..0577736 100644
--- ORI/prettier/src/cli/create-minimist-options.js
+++ ALT/prettier/src/cli/create-minimist-options.js
@@ -19,9 +19,11 @@ module.exports = function createMinimistOptions(detailedOptions) {
.filter(
(option) =>
!option.deprecated &&
- (!option.forwardToApi ||
+ (
+ !option.forwardToApi ||
option.name === "plugin" ||
- option.name === "plugin-search-dir") &&
+ option.name === "plugin-search-dir"
+ ) &&
option.default !== undefined
)
.map((option) => [option.name, option.default])
diff --git ORI/prettier/src/cli/format.js ALT/prettier/src/cli/format.js
index e9aef8e..36bcfe6 100644
--- ORI/prettier/src/cli/format.js
+++ ALT/prettier/src/cli/format.js
@@ -296,10 +296,12 @@ function formatFiles(context) {
const fileIgnored = ignorer.ignores(fixWindowsSlashes(ignoreFilename));
if (
fileIgnored &&
- (context.argv["debug-check"] ||
+ (
+ context.argv["debug-check"] ||
context.argv.write ||
context.argv.check ||
- context.argv["list-different"])
+ context.argv["list-different"]
+ )
) {
continue;
}
diff --git ORI/prettier/src/common/util.js ALT/prettier/src/common/util.js
index 41bf497..937e196 100644
--- ORI/prettier/src/common/util.js
+++ ALT/prettier/src/common/util.js
@@ -389,9 +389,11 @@ function printString(raw, options) {
/** @type {Quote} */
const enclosingQuote =
options.parser === "json" ||
- (options.parser === "json5" &&
+ (
+ options.parser === "json5" &&
options.quoteProps === "preserve" &&
- !options.singleQuote)
+ !options.singleQuote
+ )
? '"'
: options.__isInHtmlAttribute
? "'"
@@ -632,8 +634,10 @@ function describeNodeForDebugging(node) {
node.name ||
(node.id && (typeof node.id === "object" ? node.id.name : node.id)) ||
(node.key && (typeof node.key === "object" ? node.key.name : node.key)) ||
- (node.value &&
- (typeof node.value === "object" ? "" : String(node.value))) ||
+ (
+ node.value &&
+ (typeof node.value === "object" ? "" : String(node.value))
+ ) ||
node.operator ||
""
);
diff --git ORI/prettier/src/language-css/clean.js ALT/prettier/src/language-css/clean.js
index 3e10345..4c39226 100644
--- ORI/prettier/src/language-css/clean.js
+++ ALT/prettier/src/language-css/clean.js
@@ -73,11 +73,15 @@ function clean(ast, newObj, parent) {
}
if (
- (ast.type === "value-word" &&
- ((ast.isColor && ast.isHex) ||
+ (
+ ast.type === "value-word" &&
+ (
+ (ast.isColor && ast.isHex) ||
["initial", "inherit", "unset", "revert"].includes(
newObj.value.replace().toLowerCase()
- ))) ||
+ )
+ )
+ ) ||
ast.type === "media-feature" ||
ast.type === "selector-root-invalid" ||
ast.type === "selector-pseudo"
@@ -95,7 +99,8 @@ function clean(ast, newObj, parent) {
}
if (
- (ast.type === "media-feature" ||
+ (
+ ast.type === "media-feature" ||
ast.type === "media-keyword" ||
ast.type === "media-type" ||
ast.type === "media-unknown" ||
@@ -105,7 +110,8 @@ function clean(ast, newObj, parent) {
ast.type === "selector-string" ||
ast.type === "selector-class" ||
ast.type === "selector-combinator" ||
- ast.type === "value-string") &&
+ ast.type === "value-string"
+ ) &&
newObj.value
) {
newObj.value = cleanCSSStrings(newObj.value);
@@ -131,13 +137,15 @@ function clean(ast, newObj, parent) {
}
if (
- (ast.type === "media-value" ||
+ (
+ ast.type === "media-value" ||
ast.type === "media-type" ||
ast.type === "value-number" ||
ast.type === "selector-root-invalid" ||
ast.type === "selector-class" ||
ast.type === "selector-combinator" ||
- ast.type === "selector-tag") &&
+ ast.type === "selector-tag"
+ ) &&
newObj.value
) {
newObj.value = newObj.value.replace(
diff --git ORI/prettier/src/language-css/printer-postcss.js ALT/prettier/src/language-css/printer-postcss.js
index 11632ce..91c16a8 100644
--- ORI/prettier/src/language-css/printer-postcss.js
+++ ALT/prettier/src/language-css/printer-postcss.js
@@ -282,13 +282,17 @@ function genericPrint(path, options, print) {
? [
isSCSSControlDirectiveNode(node)
? ""
- : (node.selector &&
+ : (
+ node.selector &&
!node.selector.nodes &&
typeof node.selector.value === "string" &&
- lastLineHasInlineComment(node.selector.value)) ||
- (!node.selector &&
+ lastLineHasInlineComment(node.selector.value)
+ ) ||
+ (
+ !node.selector &&
typeof node.params === "string" &&
- lastLineHasInlineComment(node.params))
+ lastLineHasInlineComment(node.params)
+ )
? line
: " ",
"{",
@@ -517,8 +521,10 @@ function genericPrint(path, options, print) {
const isGridValue =
declAncestorProp &&
parentNode.type === "value-value" &&
- (declAncestorProp === "grid" ||
- declAncestorProp.startsWith("grid-template"));
+ (
+ declAncestorProp === "grid" ||
+ declAncestorProp.startsWith("grid-template")
+ );
const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
const isControlDirective =
atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
@@ -655,8 +661,10 @@ function genericPrint(path, options, print) {
// (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
// (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
if (
- ((isMathOperator && isHashNode(iNextNode)) ||
- (isNextMathOperator && isRightCurlyBraceNode(iNode))) &&
+ (
+ (isMathOperator && isHashNode(iNextNode)) ||
+ (isNextMathOperator && isRightCurlyBraceNode(iNode))
+ ) &&
hasEmptyRawBefore(iNextNode)
) {
continue;
@@ -674,10 +682,12 @@ function genericPrint(path, options, print) {
// (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
if (
insideValueFunctionNode(path, "calc") &&
- (isAdditionNode(iNode) ||
+ (
+ isAdditionNode(iNode) ||
isAdditionNode(iNextNode) ||
isSubtractionNode(iNode) ||
- isSubtractionNode(iNextNode)) &&
+ isSubtractionNode(iNextNode)
+ ) &&
hasEmptyRawBefore(iNextNode)
) {
continue;
@@ -709,15 +719,21 @@ function genericPrint(path, options, print) {
!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) &&
!insideValueFunctionNode(path, "calc") &&
!isColorAdjusterNode &&
- ((isDivisionNode(iNextNode) && !requireSpaceBeforeOperator) ||
+ (
+ (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator) ||
(isDivisionNode(iNode) && !requireSpaceAfterOperator) ||
(isAdditionNode(iNextNode) && !requireSpaceBeforeOperator) ||
(isAdditionNode(iNode) && !requireSpaceAfterOperator) ||
isSubtractionNode(iNextNode) ||
- isSubtractionNode(iNode)) &&
- (hasEmptyRawBefore(iNextNode) ||
- (isMathOperator &&
- (!iPrevNode || (iPrevNode && isMathOperatorNode(iPrevNode)))))
+ isSubtractionNode(iNode)
+ ) &&
+ (
+ hasEmptyRawBefore(iNextNode) ||
+ (
+ isMathOperator &&
+ (!iPrevNode || (iPrevNode && isMathOperatorNode(iPrevNode)))
+ )
+ )
) {
continue;
}
@@ -735,11 +751,13 @@ function genericPrint(path, options, print) {
// Handle keywords in SCSS control directive
if (
isControlDirective &&
- (isEqualityOperatorNode(iNextNode) ||
+ (
+ isEqualityOperatorNode(iNextNode) ||
isRelationalOperatorNode(iNextNode) ||
isIfElseKeywordNode(iNextNode) ||
isEachKeywordNode(iNode) ||
- isForKeywordNode(iNode))
+ isForKeywordNode(iNode)
+ )
) {
parts.push(" ");
@@ -826,12 +844,16 @@ function genericPrint(path, options, print) {
if (
parentNode &&
isURLFunctionNode(parentNode) &&
- (node.groups.length === 1 ||
- (node.groups.length > 0 &&
+ (
+ node.groups.length === 1 ||
+ (
+ node.groups.length > 0 &&
node.groups[0].type === "value-comma_group" &&
node.groups[0].groups.length > 0 &&
node.groups[0].groups[0].type === "value-word" &&
- node.groups[0].groups[0].value.startsWith("data:")))
+ node.groups[0].groups[0].value.startsWith("data:")
+ )
+ )
) {
return [
node.open ? print("open") : "",
@@ -940,9 +962,11 @@ function genericPrint(path, options, print) {
return [
node.value,
// Don't add spaces on escaped colon `:`, e.g: grid-template-rows: [row-1-00\:00] auto;
- (prevNode &&
+ (
+ prevNode &&
typeof prevNode.value === "string" &&
- getLast(prevNode.value) === "\\") ||
+ getLast(prevNode.value) === "\\"
+ ) ||
// Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
insideValueFunctionNode(path, "url")
? ""
@@ -994,14 +1018,18 @@ function printNodeSequence(path, options, print) {
if (i !== nodes.length - 1) {
if (
- (nodes[i + 1].type === "css-comment" &&
+ (
+ nodes[i + 1].type === "css-comment" &&
!hasNewline(options.originalText, locStart(nodes[i + 1]), {
backwards: true,
}) &&
- !isFrontMatterNode(nodes[i])) ||
- (nodes[i + 1].type === "css-atrule" &&
+ !isFrontMatterNode(nodes[i])
+ ) ||
+ (
+ nodes[i + 1].type === "css-atrule" &&
nodes[i + 1].name === "else" &&
- nodes[i].type !== "css-comment")
+ nodes[i].type !== "css-comment"
+ )
) {
parts.push(" ");
} else {
diff --git ORI/prettier/src/language-css/utils.js ALT/prettier/src/language-css/utils.js
index 62e38a4..ab95fa5 100644
--- ORI/prettier/src/language-css/utils.js
+++ ALT/prettier/src/language-css/utils.js
@@ -143,8 +143,10 @@ function insideICSSRuleNode(path) {
ruleAncestorNode &&
ruleAncestorNode.raws &&
ruleAncestorNode.raws.selector &&
- (ruleAncestorNode.raws.selector.startsWith(":import") ||
- ruleAncestorNode.raws.selector.startsWith(":export"))
+ (
+ ruleAncestorNode.raws.selector.startsWith(":import") ||
+ ruleAncestorNode.raws.selector.startsWith(":export")
+ )
);
}
diff --git ORI/prettier/src/language-handlebars/utils.js ALT/prettier/src/language-handlebars/utils.js
index 807a8cc..ebc0927 100644
--- ORI/prettier/src/language-handlebars/utils.js
+++ ALT/prettier/src/language-handlebars/utils.js
@@ -39,8 +39,10 @@ function isGlimmerComponent(node) {
const voidTags = new Set(htmlVoidElements);
function isVoid(node) {
return (
- (isGlimmerComponent(node) &&
- node.children.every((node) => isWhitespaceNode(node))) ||
+ (
+ isGlimmerComponent(node) &&
+ node.children.every((node) => isWhitespaceNode(node))
+ ) ||
voidTags.has(node.tag)
);
}
diff --git ORI/prettier/src/language-html/parser-html.js ALT/prettier/src/language-html/parser-html.js
index a3002ee..2a5d822 100644
--- ORI/prettier/src/language-html/parser-html.js
+++ ALT/prettier/src/language-html/parser-html.js
@@ -210,9 +210,11 @@ function ngHtmlParser(
if (node instanceof Element) {
if (
normalizeTagName &&
- (!node.namespace ||
+ (
+ !node.namespace ||
node.namespace === node.tagDefinition.implicitNamespacePrefix ||
- isUnknownNamespace(node))
+ isUnknownNamespace(node)
+ )
) {
node.name = lowerCaseIfFn(
node.name,
@@ -229,8 +231,10 @@ function ngHtmlParser(
attr.name,
(lowerCasedAttrName) =>
node.name in HTML_ELEMENT_ATTRIBUTES &&
- (lowerCasedAttrName in HTML_ELEMENT_ATTRIBUTES["*"] ||
- lowerCasedAttrName in CURRENT_HTML_ELEMENT_ATTRIBUTES)
+ (
+ lowerCasedAttrName in HTML_ELEMENT_ATTRIBUTES["*"] ||
+ lowerCasedAttrName in CURRENT_HTML_ELEMENT_ATTRIBUTES
+ )
);
}
}
@@ -387,10 +391,10 @@ module.exports = {
if (
tagName.toLowerCase() !== "html" &&
!hasParent &&
- (tagName !== "template" ||
- attrs.some(
- ({ name, value }) => name === "lang" && value !== "html"
- ))
+ (
+ tagName !== "template" ||
+ attrs.some(({ name, value }) => name === "lang" && value !== "html")
+ )
) {
return require("angular-html-parser").TagContentType.RAW_TEXT;
}
diff --git ORI/prettier/src/language-html/print-preprocess.js ALT/prettier/src/language-html/print-preprocess.js
index 041db5c..89ebc37 100644
--- ORI/prettier/src/language-html/print-preprocess.js
+++ ALT/prettier/src/language-html/print-preprocess.js
@@ -312,9 +312,11 @@ function extractWhitespaces(ast /*, options*/) {
if (
node.children.length === 0 ||
- (node.children.length === 1 &&
+ (
+ node.children.length === 1 &&
node.children[0].type === "text" &&
- htmlTrim(node.children[0].value).length === 0)
+ htmlTrim(node.children[0].value).length === 0
+ )
) {
return node.clone({
children: [],
@@ -391,10 +393,14 @@ function addIsSelfClosing(ast /*, options */) {
Object.assign(node, {
isSelfClosing:
!node.children ||
- (node.type === "element" &&
- (node.tagDefinition.isVoid ||
+ (
+ node.type === "element" &&
+ (
+ node.tagDefinition.isVoid ||
// self-closing
- node.startSourceSpan === node.endSourceSpan)),
+ node.startSourceSpan === node.endSourceSpan
+ )
+ ),
})
);
}
diff --git ORI/prettier/src/language-html/printer-html.js ALT/prettier/src/language-html/printer-html.js
index 553329d..133d123 100644
--- ORI/prettier/src/language-html/printer-html.js
+++ ALT/prettier/src/language-html/printer-html.js
@@ -110,9 +110,13 @@ function embed(path, print, textToDoc, options) {
const { attrMap } = node.parent;
if (
attrMap &&
- (attrMap.type === "module" ||
- (attrMap.type === "text/babel" &&
- attrMap["data-type"] === "module"))
+ (
+ attrMap.type === "module" ||
+ (
+ attrMap.type === "text/babel" &&
+ attrMap["data-type"] === "module"
+ )
+ )
) {
sourceType = "module";
}
@@ -280,8 +284,10 @@ function genericPrint(path, options, print) {
((childrenDoc) =>
shouldHugContent
? indentIfBreak(childrenDoc, { groupId: attrGroupId })
- : (isScriptLikeTag(node) ||
- isVueCustomBlock(node, options)) &&
+ : (
+ isScriptLikeTag(node) ||
+ isVueCustomBlock(node, options)
+ ) &&
node.parent.type === "root" &&
options.parser === "vue" &&
!options.vueIndentScriptAndStyle
@@ -313,10 +319,14 @@ function genericPrint(path, options, print) {
: node.lastChild.hasTrailingSpaces &&
node.lastChild.isTrailingSpaceSensitive
? line
- : (node.lastChild.type === "comment" ||
- (node.lastChild.type === "text" &&
+ : (
+ node.lastChild.type === "comment" ||
+ (
+ node.lastChild.type === "text" &&
node.isWhitespaceSensitive &&
- node.isIndentationSensitive)) &&
+ node.isIndentationSensitive
+ )
+ ) &&
new RegExp(
`\\n[\\t ]{${
options.tabWidth *
@@ -560,8 +570,10 @@ function printChildren(path, options, print) {
: preferHardlineAsLeadingSpaces(nextNode)
? hardline
: softline
- : (needsToBorrowNextOpeningTagStartMarker(prevNode) &&
- (hasPrettierIgnore(nextNode) ||
+ : (
+ needsToBorrowNextOpeningTagStartMarker(prevNode) &&
+ (
+ hasPrettierIgnore(nextNode) ||
/**
* 123<a
* ~
@@ -579,16 +591,20 @@ function printChildren(path, options, print) {
* ~
* attr
*/
- (nextNode.type === "element" && nextNode.attrs.length > 0))) ||
+ (nextNode.type === "element" && nextNode.attrs.length > 0)
+ )
+ ) ||
/**
* <img
* src="long"
* ~
* />123
*/
- (prevNode.type === "element" &&
+ (
+ prevNode.type === "element" &&
prevNode.isSelfClosing &&
- needsToBorrowPrevClosingTagEndMarker(nextNode))
+ needsToBorrowPrevClosingTagEndMarker(nextNode)
+ )
? ""
: !nextNode.isLeadingSpaceSensitive ||
preferHardlineAsLeadingSpaces(nextNode) ||
@@ -598,13 +614,13 @@ function printChildren(path, options, print) {
* ~
* >.
*/
- (needsToBorrowPrevClosingTagEndMarker(nextNode) &&
+ (
+ needsToBorrowPrevClosingTagEndMarker(nextNode) &&
prevNode.lastChild &&
needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) &&
prevNode.lastChild.lastChild &&
- needsToBorrowParentClosingTagStartMarker(
- prevNode.lastChild.lastChild
- ))
+ needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild)
+ )
? hardline
: nextNode.hasLeadingSpaces
? line
@@ -690,16 +706,20 @@ function printAttributes(path, options, print) {
* ~
* >456
*/
- (node.firstChild &&
- needsToBorrowParentOpeningTagEndMarker(node.firstChild)) ||
+ (
+ node.firstChild &&
+ needsToBorrowParentOpeningTagEndMarker(node.firstChild)
+ ) ||
/**
* <span
* >123<meta
* ~
* /></span>
*/
- (node.isSelfClosing &&
- needsToBorrowLastChildClosingTagEndMarker(node.parent)) ||
+ (
+ node.isSelfClosing &&
+ needsToBorrowLastChildClosingTagEndMarker(node.parent)
+ ) ||
forceNotToBreakAttrContent
) {
parts.push(node.isSelfClosing ? " " : "");
@@ -977,11 +997,17 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
: root;
if (
rootNode &&
- (rootNode.type === "ObjectExpression" ||
+ (
+ rootNode.type === "ObjectExpression" ||
rootNode.type === "ArrayExpression" ||
- (options.parser === "__vue_expression" &&
- (rootNode.type === "TemplateLiteral" ||
- rootNode.type === "StringLiteral")))
+ (
+ options.parser === "__vue_expression" &&
+ (
+ rootNode.type === "TemplateLiteral" ||
+ rootNode.type === "StringLiteral"
+ )
+ )
+ )
) {
shouldHug = true;
}
diff --git ORI/prettier/src/language-html/utils.js ALT/prettier/src/language-html/utils.js
index 06b85e3..82bc1f6 100644
--- ORI/prettier/src/language-html/utils.js
+++ ALT/prettier/src/language-html/utils.js
@@ -136,11 +136,15 @@ function isTextLikeNode(node) {
function isScriptLikeTag(node) {
return (
node.type === "element" &&
- (node.fullName === "script" ||
+ (
+ node.fullName === "script" ||
node.fullName === "style" ||
node.fullName === "svg:style" ||
- (isUnknownNamespace(node) &&
- (node.name === "script" || node.name === "style")))
+ (
+ isUnknownNamespace(node) &&
+ (node.name === "script" || node.name === "style")
+ )
+ )
);
}
@@ -198,11 +202,13 @@ function isLeadingSpaceSensitiveNode(node, options) {
if (
!node.prev &&
- (node.parent.type === "root" ||
+ (
+ node.parent.type === "root" ||
(isPreLikeNode(node) && node.parent) ||
isScriptLikeTag(node.parent) ||
isVueCustomBlock(node.parent, options) ||
- !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))
+ !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay)
+ )
) {
return false;
}
@@ -241,11 +247,13 @@ function isTrailingSpaceSensitiveNode(node, options) {
if (
!node.next &&
- (node.parent.type === "root" ||
+ (
+ node.parent.type === "root" ||
(isPreLikeNode(node) && node.parent) ||
isScriptLikeTag(node.parent) ||
isVueCustomBlock(node.parent, options) ||
- !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))
+ !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay)
+ )
) {
return false;
}
@@ -270,9 +278,11 @@ function isDanglingSpaceSensitiveNode(node) {
function forceNextEmptyLine(node) {
return (
isFrontMatterNode(node) ||
- (node.next &&
+ (
+ node.next &&
node.sourceSpan.end &&
- node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line)
+ node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line
+ )
);
}
@@ -280,16 +290,24 @@ function forceNextEmptyLine(node) {
function forceBreakContent(node) {
return (
forceBreakChildren(node) ||
- (node.type === "element" &&
+ (
+ node.type === "element" &&
node.children.length > 0 &&
- (["body", "script", "style"].includes(node.name) ||
- node.children.some((child) => hasNonTextChild(child)))) ||
- (node.firstChild &&
+ (
+ ["body", "script", "style"].includes(node.name) ||
+ node.children.some((child) => hasNonTextChild(child))
+ )
+ ) ||
+ (
+ node.firstChild &&
node.firstChild === node.lastChild &&
node.firstChild.type !== "text" &&
hasLeadingLineBreak(node.firstChild) &&
- (!node.lastChild.isTrailingSpaceSensitive ||
- hasTrailingLineBreak(node.lastChild)))
+ (
+ !node.lastChild.isTrailingSpaceSensitive ||
+ hasTrailingLineBreak(node.lastChild)
+ )
+ )
);
}
@@ -298,8 +316,10 @@ function forceBreakChildren(node) {
return (
node.type === "element" &&
node.children.length > 0 &&
- (["html", "head", "ul", "ol", "select"].includes(node.name) ||
- (node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell"))
+ (
+ ["html", "head", "ul", "ol", "select"].includes(node.name) ||
+ (node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell")
+ )
);
}
@@ -339,8 +359,10 @@ function hasTrailingLineBreak(node) {
(node.next
? node.next.sourceSpan.start.line > node.sourceSpan.end.line
: node.parent.type === "root" ||
- (node.parent.endSourceSpan &&
- node.parent.endSourceSpan.start.line > node.sourceSpan.end.line))
+ (
+ node.parent.endSourceSpan &&
+ node.parent.endSourceSpan.start.line > node.sourceSpan.end.line
+ ))
);
}
@@ -427,8 +449,10 @@ function inferScriptParser(node, options) {
if (options && isVueNonHtmlBlock(node, options)) {
return (
_inferScriptParser(node) ||
- (!("src" in node.attrMap) &&
- inferParserByLanguage(node.attrMap.lang, options))
+ (
+ !("src" in node.attrMap) &&
+ inferParserByLanguage(node.attrMap.lang, options)
+ )
);
}
}
@@ -528,11 +552,15 @@ function getNodeCssStyleDisplay(node, options) {
return "block";
}
return (
- (node.type === "element" &&
- (!node.namespace ||
+ (
+ node.type === "element" &&
+ (
+ !node.namespace ||
isInSvgForeignObject ||
- isUnknownNamespace(node)) &&
- CSS_DISPLAY_TAGS[node.name]) ||
+ isUnknownNamespace(node)
+ ) &&
+ CSS_DISPLAY_TAGS[node.name]
+ ) ||
CSS_DISPLAY_DEFAULT
);
}
@@ -549,9 +577,11 @@ function isUnknownNamespace(node) {
function getNodeCssStyleWhiteSpace(node) {
return (
- (node.type === "element" &&
+ (
+ node.type === "element" &&
(!node.namespace || isUnknownNamespace(node)) &&
- CSS_WHITE_SPACE_TAGS[node.name]) ||
+ CSS_WHITE_SPACE_TAGS[node.name]
+ ) ||
CSS_WHITE_SPACE_DEFAULT
);
}
@@ -632,8 +662,10 @@ function isVueSfcBlock(node, options) {
function isVueNonHtmlBlock(node, options) {
return (
isVueSfcBlock(node, options) &&
- (isVueCustomBlock(node, options) ||
- (node.attrMap.lang && node.attrMap.lang !== "html"))
+ (
+ isVueCustomBlock(node, options) ||
+ (node.attrMap.lang && node.attrMap.lang !== "html")
+ )
);
}
diff --git ORI/prettier/src/language-js/clean.js ALT/prettier/src/language-js/clean.js
index 903988e..5d8660d 100644
--- ORI/prettier/src/language-js/clean.js
+++ ALT/prettier/src/language-js/clean.js
@@ -58,8 +58,10 @@ function clean(ast, newObj, parent) {
}
if (
ast.type === "JSXExpressionContainer" &&
- (ast.expression.type === "Literal" ||
- ast.expression.type === "StringLiteral") &&
+ (
+ ast.expression.type === "Literal" ||
+ ast.expression.type === "StringLiteral"
+ ) &&
ast.expression.value === " "
) {
return null;
@@ -69,7 +71,8 @@ function clean(ast, newObj, parent) {
// And {key: value} into {'key': value}.
// Also for (some) number keys.
if (
- (ast.type === "Property" ||
+ (
+ ast.type === "Property" ||
ast.type === "ObjectProperty" ||
ast.type === "MethodDefinition" ||
ast.type === "ClassProperty" ||
@@ -77,13 +80,16 @@ function clean(ast, newObj, parent) {
ast.type === "PropertyDefinition" ||
ast.type === "TSDeclareMethod" ||
ast.type === "TSPropertySignature" ||
- ast.type === "ObjectTypeProperty") &&
+ ast.type === "ObjectTypeProperty"
+ ) &&
typeof ast.key === "object" &&
ast.key &&
- (ast.key.type === "Literal" ||
+ (
+ ast.key.type === "Literal" ||
ast.key.type === "NumericLiteral" ||
ast.key.type === "StringLiteral" ||
- ast.key.type === "Identifier")
+ ast.key.type === "Identifier"
+ )
) {
delete newObj.key;
}
@@ -156,15 +162,21 @@ function clean(ast, newObj, parent) {
// styled-components, graphql, markdown
if (
ast.type === "TaggedTemplateExpression" &&
- (ast.tag.type === "MemberExpression" ||
- (ast.tag.type === "Identifier" &&
- (ast.tag.name === "gql" ||
+ (
+ ast.tag.type === "MemberExpression" ||
+ (
+ ast.tag.type === "Identifier" &&
+ (
+ ast.tag.name === "gql" ||
ast.tag.name === "graphql" ||
ast.tag.name === "css" ||
ast.tag.name === "md" ||
ast.tag.name === "markdown" ||
- ast.tag.name === "html")) ||
- ast.tag.type === "CallExpression")
+ ast.tag.name === "html"
+ )
+ ) ||
+ ast.tag.type === "CallExpression"
+ )
) {
removeTemplateElementsValue(newObj.quasi);
}
diff --git ORI/prettier/src/language-js/comments.js ALT/prettier/src/language-js/comments.js
index b0366e8..495f29e 100644
--- ORI/prettier/src/language-js/comments.js
+++ ALT/prettier/src/language-js/comments.js
@@ -283,8 +283,10 @@ function handleTryStatementComments({
}) {
if (
!enclosingNode ||
- (enclosingNode.type !== "TryStatement" &&
- enclosingNode.type !== "CatchClause") ||
+ (
+ enclosingNode.type !== "TryStatement" &&
+ enclosingNode.type !== "CatchClause"
+ ) ||
!followingNode
) {
return false;
@@ -344,8 +346,10 @@ function handleConditionalExpressionComments({
if (
(!precedingNode || !isSameLineAsPrecedingNode) &&
enclosingNode &&
- (enclosingNode.type === "ConditionalExpression" ||
- enclosingNode.type === "TSConditionalType") &&
+ (
+ enclosingNode.type === "ConditionalExpression" ||
+ enclosingNode.type === "TSConditionalType"
+ ) &&
followingNode
) {
addLeadingComment(followingNode, comment);
@@ -361,8 +365,10 @@ function handleObjectPropertyAssignment({
}) {
if (
enclosingNode &&
- (enclosingNode.type === "ObjectProperty" ||
- enclosingNode.type === "Property") &&
+ (
+ enclosingNode.type === "ObjectProperty" ||
+ enclosingNode.type === "Property"
+ ) &&
enclosingNode.shorthand &&
enclosingNode.key === precedingNode &&
enclosingNode.value.type === "AssignmentPattern"
@@ -381,12 +387,14 @@ function handleClassComments({
}) {
if (
enclosingNode &&
- (enclosingNode.type === "ClassDeclaration" ||
+ (
+ enclosingNode.type === "ClassDeclaration" ||
enclosingNode.type === "ClassExpression" ||
enclosingNode.type === "DeclareClass" ||
enclosingNode.type === "DeclareInterface" ||
enclosingNode.type === "InterfaceDeclaration" ||
- enclosingNode.type === "TSInterfaceDeclaration")
+ enclosingNode.type === "TSInterfaceDeclaration"
+ )
) {
if (
isNonEmptyArray(enclosingNode.decorators) &&
@@ -408,9 +416,11 @@ function handleClassComments({
if (enclosingNode[prop] && followingNode === enclosingNode[prop][0]) {
if (
precedingNode &&
- (precedingNode === enclosingNode.id ||
+ (
+ precedingNode === enclosingNode.id ||
precedingNode === enclosingNode.typeParameters ||
- precedingNode === enclosingNode.superClass)
+ precedingNode === enclosingNode.superClass
+ )
) {
addTrailingComment(precedingNode, comment);
} else {
@@ -437,9 +447,11 @@ function handleMethodNameComments({
enclosingNode &&
precedingNode &&
// "MethodDefinition" is handled in getCommentChildNodes
- (enclosingNode.type === "Property" ||
+ (
+ enclosingNode.type === "Property" ||
enclosingNode.type === "TSDeclareMethod" ||
- enclosingNode.type === "TSAbstractMethodDefinition") &&
+ enclosingNode.type === "TSAbstractMethodDefinition"
+ ) &&
precedingNode.type === "Identifier" &&
enclosingNode.key === precedingNode &&
// special Property case: { key: /*comment*/(value) };
@@ -456,13 +468,15 @@ function handleMethodNameComments({
precedingNode &&
enclosingNode &&
precedingNode.type === "Decorator" &&
- (enclosingNode.type === "ClassMethod" ||
+ (
+ enclosingNode.type === "ClassMethod" ||
enclosingNode.type === "ClassProperty" ||
enclosingNode.type === "PropertyDefinition" ||
enclosingNode.type === "TSAbstractClassProperty" ||
enclosingNode.type === "TSAbstractMethodDefinition" ||
enclosingNode.type === "TSDeclareMethod" ||
- enclosingNode.type === "MethodDefinition")
+ enclosingNode.type === "MethodDefinition"
+ )
) {
addTrailingComment(precedingNode, comment);
return true;
@@ -483,11 +497,13 @@ function handleFunctionNameComments({
if (
precedingNode &&
enclosingNode &&
- (enclosingNode.type === "FunctionDeclaration" ||
+ (
+ enclosingNode.type === "FunctionDeclaration" ||
enclosingNode.type === "FunctionExpression" ||
enclosingNode.type === "ClassMethod" ||
enclosingNode.type === "MethodDefinition" ||
- enclosingNode.type === "ObjectMethod")
+ enclosingNode.type === "ObjectMethod"
+ )
) {
addTrailingComment(precedingNode, comment);
return true;
@@ -518,18 +534,26 @@ function handleCommentInEmptyParens({ comment, enclosingNode, text }) {
// i.e. a function without any argument.
if (
enclosingNode &&
- ((isRealFunctionLikeNode(enclosingNode) &&
- getFunctionParameters(enclosingNode).length === 0) ||
- (isCallLikeExpression(enclosingNode) &&
- getCallArguments(enclosingNode).length === 0))
+ (
+ (
+ isRealFunctionLikeNode(enclosingNode) &&
+ getFunctionParameters(enclosingNode).length === 0
+ ) ||
+ (
+ isCallLikeExpression(enclosingNode) &&
+ getCallArguments(enclosingNode).length === 0
+ )
+ )
) {
addDanglingComment(enclosingNode, comment);
return true;
}
if (
enclosingNode &&
- (enclosingNode.type === "MethodDefinition" ||
- enclosingNode.type === "TSAbstractMethodDefinition") &&
+ (
+ enclosingNode.type === "MethodDefinition" ||
+ enclosingNode.type === "TSAbstractMethodDefinition"
+ ) &&
getFunctionParameters(enclosingNode.value).length === 0
) {
addDanglingComment(enclosingNode.value, comment);
@@ -561,8 +585,10 @@ function handleLastFunctionArgComments({
// Real functions and TypeScript function type definitions
if (
precedingNode &&
- (precedingNode.type === "Identifier" ||
- precedingNode.type === "AssignmentPattern") &&
+ (
+ precedingNode.type === "Identifier" ||
+ precedingNode.type === "AssignmentPattern"
+ ) &&
enclosingNode &&
isRealFunctionLikeNode(enclosingNode) &&
getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === ")"
@@ -626,8 +652,10 @@ function handleLabeledStatementComments({ comment, enclosingNode }) {
function handleBreakAndContinueStatementComments({ comment, enclosingNode }) {
if (
enclosingNode &&
- (enclosingNode.type === "ContinueStatement" ||
- enclosingNode.type === "BreakStatement") &&
+ (
+ enclosingNode.type === "ContinueStatement" ||
+ enclosingNode.type === "BreakStatement"
+ ) &&
!enclosingNode.label
) {
addTrailingComment(enclosingNode, comment);
@@ -661,8 +689,10 @@ function handleUnionTypeComments({
}) {
if (
enclosingNode &&
- (enclosingNode.type === "UnionTypeAnnotation" ||
- enclosingNode.type === "TSUnionType")
+ (
+ enclosingNode.type === "UnionTypeAnnotation" ||
+ enclosingNode.type === "TSUnionType"
+ )
) {
if (isPrettierIgnoreComment(comment)) {
followingNode.prettierIgnore = true;
@@ -677,8 +707,10 @@ function handleUnionTypeComments({
if (
followingNode &&
- (followingNode.type === "UnionTypeAnnotation" ||
- followingNode.type === "TSUnionType") &&
+ (
+ followingNode.type === "UnionTypeAnnotation" ||
+ followingNode.type === "TSUnionType"
+ ) &&
isPrettierIgnoreComment(comment)
) {
followingNode.types[0].prettierIgnore = true;
@@ -691,8 +723,10 @@ function handleUnionTypeComments({
function handlePropertyComments({ comment, enclosingNode }) {
if (
enclosingNode &&
- (enclosingNode.type === "Property" ||
- enclosingNode.type === "ObjectProperty")
+ (
+ enclosingNode.type === "Property" ||
+ enclosingNode.type === "ObjectProperty"
+ )
) {
addLeadingComment(enclosingNode, comment);
return true;
@@ -749,8 +783,10 @@ function handleOnlyComments({
function handleForComments({ comment, enclosingNode }) {
if (
enclosingNode &&
- (enclosingNode.type === "ForInStatement" ||
- enclosingNode.type === "ForOfStatement")
+ (
+ enclosingNode.type === "ForInStatement" ||
+ enclosingNode.type === "ForOfStatement"
+ )
) {
addLeadingComment(enclosingNode, comment);
return true;
@@ -800,14 +836,18 @@ function handleVariableDeclaratorComments({
}) {
if (
enclosingNode &&
- (enclosingNode.type === "VariableDeclarator" ||
- enclosingNode.type === "AssignmentExpression") &&
+ (
+ enclosingNode.type === "VariableDeclarator" ||
+ enclosingNode.type === "AssignmentExpression"
+ ) &&
followingNode &&
- (followingNode.type === "ObjectExpression" ||
+ (
+ followingNode.type === "ObjectExpression" ||
followingNode.type === "ArrayExpression" ||
followingNode.type === "TemplateLiteral" ||
followingNode.type === "TaggedTemplateExpression" ||
- isBlockComment(comment))
+ isBlockComment(comment)
+ )
) {
addLeadingComment(followingNode, comment);
return true;
@@ -824,9 +864,11 @@ function handleTSFunctionTrailingComments({
if (
!followingNode &&
enclosingNode &&
- (enclosingNode.type === "TSMethodSignature" ||
+ (
+ enclosingNode.type === "TSMethodSignature" ||
enclosingNode.type === "TSDeclareFunction" ||
- enclosingNode.type === "TSAbstractMethodDefinition") &&
+ enclosingNode.type === "TSAbstractMethodDefinition"
+ ) &&
getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === ";"
) {
addTrailingComment(enclosingNode, comment);
@@ -915,10 +957,12 @@ function getCommentChildNodes(node, options) {
// }
// }
if (
- (options.parser === "typescript" ||
+ (
+ options.parser === "typescript" ||
options.parser === "flow" ||
options.parser === "espree" ||
- options.parser === "meriyah") &&
+ options.parser === "meriyah"
+ ) &&
node.type === "MethodDefinition" &&
node.value &&
node.value.type === "FunctionExpression" &&
@@ -955,23 +999,43 @@ function willPrintOwnComments(path /*, options */) {
const parent = path.getParentNode();
return (
- ((node &&
- (isJsxNode(node) ||
- hasFlowShorthandAnnotationComment(node) ||
- (isCallExpression(parent) &&
- (hasFlowAnnotationComment(node.leadingComments) ||
- hasFlowAnnotationComment(node.trailingComments))))) ||
- (parent &&
- (parent.type === "JSXSpreadAttribute" ||
+ (
+ (
+ node &&
+ (
+ isJsxNode(node) ||
+ hasFlowShorthandAnnotationComment(node) ||
+ (
+ isCallExpression(parent) &&
+ (
+ hasFlowAnnotationComment(node.leadingComments) ||
+ hasFlowAnnotationComment(node.trailingComments)
+ )
+ )
+ )
+ ) ||
+ (
+ parent &&
+ (
+ parent.type === "JSXSpreadAttribute" ||
parent.type === "JSXSpreadChild" ||
parent.type === "UnionTypeAnnotation" ||
parent.type === "TSUnionType" ||
- ((parent.type === "ClassDeclaration" ||
- parent.type === "ClassExpression") &&
- parent.superClass === node)))) &&
- (!hasIgnoreComment(path) ||
+ (
+ (
+ parent.type === "ClassDeclaration" ||
+ parent.type === "ClassExpression"
+ ) &&
+ parent.superClass === node
+ )
+ )
+ )
+ ) &&
+ (
+ !hasIgnoreComment(path) ||
parent.type === "UnionTypeAnnotation" ||
- parent.type === "TSUnionType")
+ parent.type === "TSUnionType"
+ )
);
}
diff --git ORI/prettier/src/language-js/embed.js ALT/prettier/src/language-js/embed.js
index 3058e78..40cedf0 100644
--- ORI/prettier/src/language-js/embed.js
+++ ALT/prettier/src/language-js/embed.js
@@ -95,24 +95,32 @@ function isStyledJsx(path) {
const parent = path.getParentNode();
const parentParent = path.getParentNode(1);
return (
- (parentParent &&
+ (
+ parentParent &&
node.quasis &&
parent.type === "JSXExpressionContainer" &&
parentParent.type === "JSXElement" &&
parentParent.openingElement.name.name === "style" &&
parentParent.openingElement.attributes.some(
(attribute) => attribute.name.name === "jsx"
- )) ||
- (parent &&
+ )
+ ) ||
+ (
+ parent &&
parent.type === "TaggedTemplateExpression" &&
parent.tag.type === "Identifier" &&
- parent.tag.name === "css") ||
- (parent &&
+ parent.tag.name === "css"
+ ) ||
+ (
+ parent &&
parent.type === "TaggedTemplateExpression" &&
parent.tag.type === "MemberExpression" &&
parent.tag.object.name === "css" &&
- (parent.tag.property.name === "global" ||
- parent.tag.property.name === "resolve"))
+ (
+ parent.tag.property.name === "global" ||
+ parent.tag.property.name === "resolve"
+ )
+ )
);
}
@@ -188,15 +196,25 @@ function isStyledComponents(path) {
return (
// styled(Component)``
isStyledIdentifier(tag.callee) ||
- (tag.callee.type === "MemberExpression" &&
- ((tag.callee.object.type === "MemberExpression" &&
- // styled.foo.attrs({})``
- (isStyledIdentifier(tag.callee.object.object) ||
- // Component.extend.attrs({})``
- isStyledExtend(tag.callee.object))) ||
+ (
+ tag.callee.type === "MemberExpression" &&
+ (
+ (
+ tag.callee.object.type === "MemberExpression" &&
+ // styled.foo.attrs({})``
+ (
+ isStyledIdentifier(tag.callee.object.object) ||
+ // Component.extend.attrs({})``
+ isStyledExtend(tag.callee.object)
+ )
+ ) ||
// styled(Component).attrs({})``
- (tag.callee.object.type === "CallExpression" &&
- isStyledIdentifier(tag.callee.object.callee))))
+ (
+ tag.callee.object.type === "CallExpression" &&
+ isStyledIdentifier(tag.callee.object.callee)
+ )
+ )
+ )
);
case "Identifier":
@@ -247,16 +265,30 @@ function isGraphQL(path) {
return (
hasLanguageComment(node, "GraphQL") ||
- (parent &&
- ((parent.type === "TaggedTemplateExpression" &&
- ((parent.tag.type === "MemberExpression" &&
- parent.tag.object.name === "graphql" &&
- parent.tag.property.name === "experimental") ||
- (parent.tag.type === "Identifier" &&
- (parent.tag.name === "gql" || parent.tag.name === "graphql")))) ||
- (parent.type === "CallExpression" &&
+ (
+ parent &&
+ (
+ (
+ parent.type === "TaggedTemplateExpression" &&
+ (
+ (
+ parent.tag.type === "MemberExpression" &&
+ parent.tag.object.name === "graphql" &&
+ parent.tag.property.name === "experimental"
+ ) ||
+ (
+ parent.tag.type === "Identifier" &&
+ (parent.tag.name === "gql" || parent.tag.name === "graphql")
+ )
+ )
+ ) ||
+ (
+ parent.type === "CallExpression" &&
parent.callee.type === "Identifier" &&
- parent.callee.name === "graphql")))
+ parent.callee.name === "graphql"
+ )
+ )
+ )
);
}
diff --git ORI/prettier/src/language-js/needs-parens.js ALT/prettier/src/language-js/needs-parens.js
index 147629d..ed2b8bc 100644
--- ORI/prettier/src/language-js/needs-parens.js
+++ ALT/prettier/src/language-js/needs-parens.js
@@ -75,7 +75,8 @@ function needsParens(path, options) {
// all expressions.
if (
name === "superClass" &&
- (node.type === "ArrowFunctionExpression" ||
+ (
+ node.type === "ArrowFunctionExpression" ||
node.type === "AssignmentExpression" ||
node.type === "AwaitExpression" ||
node.type === "BinaryExpression" ||
@@ -89,7 +90,8 @@ function needsParens(path, options) {
node.type === "UnaryExpression" ||
node.type === "UpdateExpression" ||
node.type === "YieldExpression" ||
- node.type === "TSNonNullExpression")
+ node.type === "TSNonNullExpression"
+ )
) {
return true;
}
@@ -171,8 +173,10 @@ function needsParens(path, options) {
if (parent.type === "UnaryExpression") {
return (
node.prefix &&
- ((node.operator === "++" && parent.operator === "+") ||
- (node.operator === "--" && parent.operator === "-"))
+ (
+ (node.operator === "++" && parent.operator === "+") ||
+ (node.operator === "--" && parent.operator === "-")
+ )
);
}
// else fallthrough
@@ -417,8 +421,10 @@ function needsParens(path, options) {
case "TSUnionType":
case "TSIntersectionType":
if (
- (parent.type === "TSUnionType" ||
- parent.type === "TSIntersectionType") &&
+ (
+ parent.type === "TSUnionType" ||
+ parent.type === "TSIntersectionType"
+ ) &&
parent.types.length > 1 &&
(!node.types || node.types.length > 1)
) {
@@ -437,8 +443,10 @@ function needsParens(path, options) {
parent.type === "TSRestType" ||
(name === "objectType" && parent.type === "TSIndexedAccessType") ||
parent.type === "TSTypeOperator" ||
- (parent.type === "TSTypeAnnotation" &&
- /^TSJSDoc/.test(path.getParentNode(1).type))
+ (
+ parent.type === "TSTypeAnnotation" &&
+ /^TSJSDoc/.test(path.getParentNode(1).type)
+ )
);
case "ArrayTypeAnnotation":
@@ -471,13 +479,15 @@ function needsParens(path, options) {
// will almost never be true.
ancestor.type === "NullableTypeAnnotation" ||
// See #5283
- (parent.type === "FunctionTypeParam" &&
+ (
+ parent.type === "FunctionTypeParam" &&
parent.name === null &&
getFunctionParameters(node).some(
(param) =>
param.typeAnnotation &&
param.typeAnnotation.type === "NullableTypeAnnotation"
- ))
+ )
+ )
);
}
@@ -513,8 +523,10 @@ function needsParens(path, options) {
if (
name === "key" &&
- (parent.type === "ClassProperty" ||
- parent.type === "PropertyDefinition") &&
+ (
+ parent.type === "ClassProperty" ||
+ parent.type === "PropertyDefinition"
+ ) &&
parent.computed
) {
return false;
@@ -660,12 +672,15 @@ function needsParens(path, options) {
const parentParent = path.getParentNode(1);
if (
(name === "object" && parent.type === "MemberExpression") ||
- (name === "callee" &&
- (parent.type === "CallExpression" ||
- parent.type === "NewExpression")) ||
- (parent.type === "TSNonNullExpression" &&
+ (
+ name === "callee" &&
+ (parent.type === "CallExpression" || parent.type === "NewExpression")
+ ) ||
+ (
+ parent.type === "TSNonNullExpression" &&
parentParent.type === "MemberExpression" &&
- parentParent.object === parent)
+ parentParent.object === parent
+ )
) {
return true;
}
@@ -707,18 +722,21 @@ function needsParens(path, options) {
case "BindExpression":
return (
- (name === "callee" &&
- (parent.type === "BindExpression" ||
- parent.type === "NewExpression")) ||
+ (
+ name === "callee" &&
+ (parent.type === "BindExpression" || parent.type === "NewExpression")
+ ) ||
(name === "object" && isMemberExpression(parent))
);
case "NGPipeExpression":
if (
parent.type === "NGRoot" ||
parent.type === "NGMicrosyntaxExpression" ||
- (parent.type === "ObjectProperty" &&
+ (
+ parent.type === "ObjectProperty" &&
// Preserve parens for compatibility with AngularJS expressions
- !(node.extra && node.extra.parenthesized)) ||
+ !(node.extra && node.extra.parenthesized)
+ ) ||
parent.type === "ArrayExpression" ||
(isCallExpression(parent) && parent.arguments[name] === node) ||
(name === "right" && parent.type === "NGPipeExpression") ||
@@ -732,10 +750,13 @@ function needsParens(path, options) {
case "JSXElement":
return (
name === "callee" ||
- (name === "left" &&
+ (
+ name === "left" &&
parent.type === "BinaryExpression" &&
- parent.operator === "<") ||
- (parent.type !== "ArrayExpression" &&
+ parent.operator === "<"
+ ) ||
+ (
+ parent.type !== "ArrayExpression" &&
parent.type !== "ArrowFunctionExpression" &&
parent.type !== "AssignmentExpression" &&
parent.type !== "AssignmentPattern" &&
@@ -756,7 +777,8 @@ function needsParens(path, options) {
parent.type !== "ThrowStatement" &&
parent.type !== "TypeCastExpression" &&
parent.type !== "VariableDeclarator" &&
- parent.type !== "YieldExpression")
+ parent.type !== "YieldExpression"
+ )
);
case "TypeAnnotation":
return (
@@ -839,11 +861,10 @@ function includesFunctionTypeInObjectType(node) {
return hasNode(
node,
(n1) =>
- (n1.type === "ObjectTypeAnnotation" &&
- hasNode(
- n1,
- (n2) => n2.type === "FunctionTypeAnnotation" || undefined
- )) ||
+ (
+ n1.type === "ObjectTypeAnnotation" &&
+ hasNode(n1, (n2) => n2.type === "FunctionTypeAnnotation" || undefined)
+ ) ||
undefined
);
}
diff --git ORI/prettier/src/language-js/parser/json.js ALT/prettier/src/language-js/parser/json.js
index fc115da..350fa52 100644
--- ORI/prettier/src/language-js/parser/json.js
+++ ALT/prettier/src/language-js/parser/json.js
@@ -81,8 +81,10 @@ function assertJsonNode(node) {
if (
argument.type === "NumericLiteral" ||
- (argument.type === "Identifier" &&
- (argument.name === "Infinity" || argument.name === "NaN"))
+ (
+ argument.type === "Identifier" &&
+ (argument.name === "Infinity" || argument.name === "NaN")
+ )
) {
return;
}
diff --git ORI/prettier/src/language-js/print/angular.js ALT/prettier/src/language-js/print/angular.js
index aac03f3..940e2d8 100644
--- ORI/prettier/src/language-js/print/angular.js
+++ ALT/prettier/src/language-js/print/angular.js
@@ -61,14 +61,22 @@ function printAngular(path, options, print) {
const parentNode = path.getParentNode();
const shouldNotPrintColon =
isNgForOf(node, index, parentNode) ||
- (((index === 1 &&
- (node.key.name === "then" || node.key.name === "else")) ||
- (index === 2 &&
- node.key.name === "else" &&
- parentNode.body[index - 1].type ===
- "NGMicrosyntaxKeyedExpression" &&
- parentNode.body[index - 1].key.name === "then")) &&
- parentNode.body[0].type === "NGMicrosyntaxExpression");
+ (
+ (
+ (
+ index === 1 &&
+ (node.key.name === "then" || node.key.name === "else")
+ ) ||
+ (
+ index === 2 &&
+ node.key.name === "else" &&
+ parentNode.body[index - 1].type ===
+ "NGMicrosyntaxKeyedExpression" &&
+ parentNode.body[index - 1].key.name === "then"
+ )
+ ) &&
+ parentNode.body[0].type === "NGMicrosyntaxExpression"
+ );
return [
print("key"),
shouldNotPrintColon ? " " : ": ",
diff --git ORI/prettier/src/language-js/print/array.js ALT/prettier/src/language-js/print/array.js
index 5d07163..9c1446c 100644
--- ORI/prettier/src/language-js/print/array.js
+++ ALT/prettier/src/language-js/print/array.js
@@ -128,8 +128,10 @@ function isConciselyPrintedArray(node, options) {
node.elements.every(
(element) =>
element &&
- (isNumericLiteral(element) ||
- (isSignedNumericLiteral(element) && !hasComment(element.argument))) &&
+ (
+ isNumericLiteral(element) ||
+ (isSignedNumericLiteral(element) && !hasComment(element.argument))
+ ) &&
!hasComment(
element,
CommentCheckFlags.Trailing | CommentCheckFlags.Line,
diff --git ORI/prettier/src/language-js/print/assignment.js ALT/prettier/src/language-js/print/assignment.js
index a72c952..59021aa 100644
--- ORI/prettier/src/language-js/print/assignment.js
+++ ALT/prettier/src/language-js/print/assignment.js
@@ -99,8 +99,10 @@ function chooseLayout(path, options, leftDoc, rightPropertyName) {
(node) => isAssignment(node) || node.type === "VariableDeclarator",
(node) =>
!isTail ||
- (node.type !== "ExpressionStatement" &&
- node.type !== "VariableDeclaration")
+ (
+ node.type !== "ExpressionStatement" &&
+ node.type !== "VariableDeclaration"
+ )
);
if (shouldUseChainFormatting) {
return !isTail
@@ -172,10 +174,14 @@ function shouldBreakAfterOperator(rightNode, hasShortKey) {
if (
isStringLiteral(node) ||
isMemberExpressionChainWithSimpleCalls(node) ||
- (isSimpleCall(node) &&
+ (
+ isSimpleCall(node) &&
isSimpleCall(node.callee) &&
- (isMemberExpressionChainHead(node.callee.callee) ||
- isMemberExpressionChainWithSimpleCalls(node.callee.callee)))
+ (
+ isMemberExpressionChainHead(node.callee.callee) ||
+ isMemberExpressionChainWithSimpleCalls(node.callee.callee)
+ )
+ )
) {
return true;
}
@@ -189,8 +195,10 @@ function shouldNeverBreakAfterOperator(rightNode) {
rightNode.type === "TaggedTemplateExpression" ||
rightNode.type === "BooleanLiteral" ||
isNumericLiteral(rightNode) ||
- (rightNode.type === "CallExpression" &&
- rightNode.callee.name === "require") ||
+ (
+ rightNode.type === "CallExpression" &&
+ rightNode.callee.name === "require"
+ ) ||
rightNode.type === "ClassExpression"
);
}
diff --git ORI/prettier/src/language-js/print/binaryish.js ALT/prettier/src/language-js/print/binaryish.js
index 632b148..4af6563 100644
--- ORI/prettier/src/language-js/print/binaryish.js
+++ ALT/prettier/src/language-js/print/binaryish.js
@@ -35,10 +35,12 @@ function printBinaryishExpression(path, options, print) {
const parentParent = path.getParentNode(1);
const isInsideParenthesis =
node !== parent.body &&
- (parent.type === "IfStatement" ||
+ (
+ parent.type === "IfStatement" ||
parent.type === "WhileStatement" ||
parent.type === "SwitchStatement" ||
- parent.type === "DoWhileStatement");
+ parent.type === "DoWhileStatement"
+ );
const parts = printBinaryishExpressions(
path,
@@ -83,20 +85,30 @@ function printBinaryishExpression(path, options, print) {
const shouldNotIndent =
parent.type === "ReturnStatement" ||
parent.type === "ThrowStatement" ||
- (parent.type === "JSXExpressionContainer" &&
- parentParent.type === "JSXAttribute") ||
+ (
+ parent.type === "JSXExpressionContainer" &&
+ parentParent.type === "JSXAttribute"
+ ) ||
(node.operator !== "|" && parent.type === "JsExpressionRoot") ||
- (node.type !== "NGPipeExpression" &&
- ((parent.type === "NGRoot" && options.parser === "__ng_binding") ||
- (parent.type === "NGMicrosyntaxExpression" &&
+ (
+ node.type !== "NGPipeExpression" &&
+ (
+ (parent.type === "NGRoot" && options.parser === "__ng_binding") ||
+ (
+ parent.type === "NGMicrosyntaxExpression" &&
parentParent.type === "NGMicrosyntax" &&
- parentParent.body.length === 1))) ||
+ parentParent.body.length === 1
+ )
+ )
+ ) ||
(node === parent.body && parent.type === "ArrowFunctionExpression") ||
(node !== parent.body && parent.type === "ForStatement") ||
- (parent.type === "ConditionalExpression" &&
+ (
+ parent.type === "ConditionalExpression" &&
parentParent.type !== "ReturnStatement" &&
parentParent.type !== "ThrowStatement" &&
- !isCallExpression(parentParent)) ||
+ !isCallExpression(parentParent)
+ ) ||
parent.type === "TemplateLiteral";
const shouldIndentIfInlining =
@@ -222,9 +234,11 @@ function printBinaryishExpressions(
const shouldInline = shouldInlineLogicalExpression(node);
const lineBeforeOperator =
- (node.operator === "|>" ||
+ (
+ node.operator === "|>" ||
node.type === "NGPipeExpression" ||
- (node.operator === "|" && options.parser === "__vue_expression")) &&
+ (node.operator === "|" && options.parser === "__vue_expression")
+ ) &&
!hasLeadingOwnLineComment(options.originalText, node.right);
const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
@@ -261,10 +275,12 @@ function printBinaryishExpressions(
);
const shouldGroup =
shouldBreak ||
- (!(isInsideParenthesis && node.type === "LogicalExpression") &&
+ (
+ !(isInsideParenthesis && node.type === "LogicalExpression") &&
parent.type !== node.type &&
node.left.type !== node.type &&
- node.right.type !== node.type);
+ node.right.type !== node.type
+ );
parts.push(
lineBeforeOperator ? "" : " ",
diff --git ORI/prettier/src/language-js/print/call-arguments.js ALT/prettier/src/language-js/print/call-arguments.js
index d87bf8b..7c0f6fe 100644
--- ORI/prettier/src/language-js/print/call-arguments.js
+++ ALT/prettier/src/language-js/print/call-arguments.js
@@ -215,14 +215,19 @@ function printCallArguments(path, options, print) {
function couldGroupArg(arg, arrowChainRecursion = false) {
return (
- (arg.type === "ObjectExpression" &&
- (arg.properties.length > 0 || hasComment(arg))) ||
- (arg.type === "ArrayExpression" &&
- (arg.elements.length > 0 || hasComment(arg))) ||
+ (
+ arg.type === "ObjectExpression" &&
+ (arg.properties.length > 0 || hasComment(arg))
+ ) ||
+ (
+ arg.type === "ArrayExpression" &&
+ (arg.elements.length > 0 || hasComment(arg))
+ ) ||
(arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression)) ||
(arg.type === "TSAsExpression" && couldGroupArg(arg.expression)) ||
arg.type === "FunctionExpression" ||
- (arg.type === "ArrowFunctionExpression" &&
+ (
+ arg.type === "ArrowFunctionExpression" &&
// we want to avoid breaking inside composite return types but not simple keywords
// https://github.com/prettier/prettier/issues/4070
// export class Thing implements OtherThing {
@@ -234,20 +239,31 @@ function couldGroupArg(arg, arrowChainRecursion = false) {
// app.get("/", (req, res): void => {
// res.send("Hello World!");
// });
- (!arg.returnType ||
+ (
+ !arg.returnType ||
!arg.returnType.typeAnnotation ||
arg.returnType.typeAnnotation.type !== "TSTypeReference" ||
// https://github.com/prettier/prettier/issues/7542
- isNonEmptyBlockStatement(arg.body)) &&
- (arg.body.type === "BlockStatement" ||
- (arg.body.type === "ArrowFunctionExpression" &&
- couldGroupArg(arg.body, true)) ||
+ isNonEmptyBlockStatement(arg.body)
+ ) &&
+ (
+ arg.body.type === "BlockStatement" ||
+ (
+ arg.body.type === "ArrowFunctionExpression" &&
+ couldGroupArg(arg.body, true)
+ ) ||
arg.body.type === "ObjectExpression" ||
arg.body.type === "ArrayExpression" ||
- (!arrowChainRecursion &&
- (isCallExpression(arg.body) ||
- arg.body.type === "ConditionalExpression")) ||
- isJsxNode(arg.body)))
+ (
+ !arrowChainRecursion &&
+ (
+ isCallExpression(arg.body) ||
+ arg.body.type === "ConditionalExpression"
+ )
+ ) ||
+ isJsxNode(arg.body)
+ )
+ )
);
}
@@ -262,9 +278,11 @@ function shouldGroupLastArg(args, options) {
// disable last element expansion.
(!penultimateArg || penultimateArg.type !== lastArg.type) &&
// useMemo(() => func(), [foo, bar, baz])
- (args.length !== 2 ||
+ (
+ args.length !== 2 ||
penultimateArg.type !== "ArrowFunctionExpression" ||
- lastArg.type !== "ArrayExpression") &&
+ lastArg.type !== "ArrayExpression"
+ ) &&
!(
args.length > 1 &&
lastArg.type === "ArrayExpression" &&
@@ -281,9 +299,13 @@ function shouldGroupFirstArg(args) {
const [firstArg, secondArg] = args;
return (
!hasComment(firstArg) &&
- (firstArg.type === "FunctionExpression" ||
- (firstArg.type === "ArrowFunctionExpression" &&
- firstArg.body.type === "BlockStatement")) &&
+ (
+ firstArg.type === "FunctionExpression" ||
+ (
+ firstArg.type === "ArrowFunctionExpression" &&
+ firstArg.body.type === "BlockStatement"
+ )
+ ) &&
secondArg.type !== "FunctionExpression" &&
secondArg.type !== "ArrowFunctionExpression" &&
secondArg.type !== "ConditionalExpression" &&
@@ -305,8 +327,10 @@ function isReactHookCallWithDepsArray(args) {
function isNonEmptyBlockStatement(node) {
return (
node.type === "BlockStatement" &&
- (node.body.some((node) => node.type !== "EmptyStatement") ||
- hasComment(node, CommentCheckFlags.Dangling))
+ (
+ node.body.some((node) => node.type !== "EmptyStatement") ||
+ hasComment(node, CommentCheckFlags.Dangling)
+ )
);
}
diff --git ORI/prettier/src/language-js/print/call-expression.js ALT/prettier/src/language-js/print/call-expression.js
index 8196243..fb15bb9 100644
--- ORI/prettier/src/language-js/print/call-expression.js
+++ ALT/prettier/src/language-js/print/call-expression.js
@@ -32,13 +32,17 @@ function printCallExpression(path, options, print) {
// We want to keep CommonJS- and AMD-style require calls, and AMD-style
// define calls, as a unit.
// e.g. `define(["some/lib"], (lib) => {`
- ((!isDynamicImport && !isNew && isCommonsJsOrAmdCall(node, parentNode)) ||
+ (
+ (!isDynamicImport && !isNew && isCommonsJsOrAmdCall(node, parentNode)) ||
// Template literals as single arguments
- (args.length === 1 &&
- isTemplateOnItsOwnLine(args[0], options.originalText)) ||
+ (
+ args.length === 1 &&
+ isTemplateOnItsOwnLine(args[0], options.originalText)
+ ) ||
// Keep test declarations on a single line
// e.g. `it('long name', () => {`
- (!isNew && isTestCall(node, parentNode)))
+ (!isNew && isTestCall(node, parentNode))
+ )
) {
const printed = [];
iterateCallArgumentsPath(path, () => {
@@ -114,11 +118,15 @@ function isCommonsJsOrAmdCall(node, parentNode) {
const args = getCallArguments(node);
return (
parentNode.type === "ExpressionStatement" &&
- (args.length === 1 ||
+ (
+ args.length === 1 ||
(args.length === 2 && args[0].type === "ArrayExpression") ||
- (args.length === 3 &&
+ (
+ args.length === 3 &&
isStringLiteral(args[0]) &&
- args[1].type === "ArrayExpression"))
+ args[1].type === "ArrayExpression"
+ )
+ )
);
}
diff --git ORI/prettier/src/language-js/print/function-parameters.js ALT/prettier/src/language-js/print/function-parameters.js
index e80c7ad..3f316d7 100644
--- ORI/prettier/src/language-js/print/function-parameters.js
+++ ALT/prettier/src/language-js/print/function-parameters.js
@@ -120,14 +120,18 @@ function printFunctionParameters(
}
const isFlowShorthandWithOneArg =
- (isObjectTypePropertyAFunction(parent) ||
+ (
+ isObjectTypePropertyAFunction(parent) ||
isTypeAnnotationAFunction(parent) ||
parent.type === "TypeAlias" ||
parent.type === "UnionTypeAnnotation" ||
parent.type === "TSUnionType" ||
parent.type === "IntersectionTypeAnnotation" ||
- (parent.type === "FunctionTypeAnnotation" &&
- parent.returnType === functionNode)) &&
+ (
+ parent.type === "FunctionTypeAnnotation" &&
+ parent.returnType === functionNode
+ )
+ ) &&
parameters.length === 1 &&
parameters[0].name === null &&
// `type q = (this: string) => void;`
@@ -169,23 +173,41 @@ function shouldHugFunctionParameters(node) {
const [parameter] = parameters;
return (
!hasComment(parameter) &&
- (parameter.type === "ObjectPattern" ||
+ (
+ parameter.type === "ObjectPattern" ||
parameter.type === "ArrayPattern" ||
- (parameter.type === "Identifier" &&
+ (
+ parameter.type === "Identifier" &&
parameter.typeAnnotation &&
- (parameter.typeAnnotation.type === "TypeAnnotation" ||
- parameter.typeAnnotation.type === "TSTypeAnnotation") &&
- isObjectType(parameter.typeAnnotation.typeAnnotation)) ||
- (parameter.type === "FunctionTypeParam" &&
- isObjectType(parameter.typeAnnotation)) ||
- (parameter.type === "AssignmentPattern" &&
- (parameter.left.type === "ObjectPattern" ||
- parameter.left.type === "ArrayPattern") &&
- (parameter.right.type === "Identifier" ||
- (parameter.right.type === "ObjectExpression" &&
- parameter.right.properties.length === 0) ||
- (parameter.right.type === "ArrayExpression" &&
- parameter.right.elements.length === 0))))
+ (
+ parameter.typeAnnotation.type === "TypeAnnotation" ||
+ parameter.typeAnnotation.type === "TSTypeAnnotation"
+ ) &&
+ isObjectType(parameter.typeAnnotation.typeAnnotation)
+ ) ||
+ (
+ parameter.type === "FunctionTypeParam" &&
+ isObjectType(parameter.typeAnnotation)
+ ) ||
+ (
+ parameter.type === "AssignmentPattern" &&
+ (
+ parameter.left.type === "ObjectPattern" ||
+ parameter.left.type === "ArrayPattern"
+ ) &&
+ (
+ parameter.right.type === "Identifier" ||
+ (
+ parameter.right.type === "ObjectExpression" &&
+ parameter.right.properties.length === 0
+ ) ||
+ (
+ parameter.right.type === "ArrayExpression" &&
+ parameter.right.elements.length === 0
+ )
+ )
+ )
+ )
);
}
diff --git ORI/prettier/src/language-js/print/function.js ALT/prettier/src/language-js/print/function.js
index 0331e6b..cbf4bb0 100644
--- ORI/prettier/src/language-js/print/function.js
+++ ALT/prettier/src/language-js/print/function.js
@@ -303,13 +303,15 @@ function printArrowFunctionExpression(path, options, print, args) {
// as the arrow.
if (
!hasLeadingOwnLineComment(options.originalText, node.body) &&
- (node.body.type === "ArrayExpression" ||
+ (
+ node.body.type === "ArrayExpression" ||
node.body.type === "ObjectExpression" ||
node.body.type === "BlockStatement" ||
isJsxNode(node.body) ||
isTemplateOnItsOwnLine(node.body, options.originalText) ||
node.body.type === "ArrowFunctionExpression" ||
- node.body.type === "DoExpression")
+ node.body.type === "DoExpression"
+ )
) {
return group([...parts, " ", body]);
}
@@ -328,8 +330,10 @@ function printArrowFunctionExpression(path, options, print, args) {
// with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
// we should align the expression's closing } with the line with the opening {.
const shouldAddSoftLine =
- ((args && args.expandLastArg) ||
- path.getParentNode().type === "JSXExpressionContainer") &&
+ (
+ (args && args.expandLastArg) ||
+ path.getParentNode().type === "JSXExpressionContainer"
+ ) &&
!hasComment(node);
const printTrailingComma =
diff --git ORI/prettier/src/language-js/print/jsx.js ALT/prettier/src/language-js/print/jsx.js
index 57150c9..b7c97d6 100644
--- ORI/prettier/src/language-js/print/jsx.js
+++ ALT/prettier/src/language-js/print/jsx.js
@@ -75,8 +75,10 @@ function printJsxElementInternal(path, options, print) {
if (
node.children.length === 1 &&
node.children[0].type === "JSXExpressionContainer" &&
- (node.children[0].expression.type === "TemplateLiteral" ||
- node.children[0].expression.type === "TaggedTemplateExpression")
+ (
+ node.children[0].expression.type === "TemplateLiteral" ||
+ node.children[0].expression.type === "TaggedTemplateExpression"
+ )
) {
return [openingLines, ...path.map(print, "children"), closingLines];
}
@@ -156,12 +158,16 @@ function printJsxElementInternal(path, options, print) {
children[i + 1] === "" &&
children[i + 2] === jsxWhitespace;
const isPairOfHardOrSoftLines =
- (children[i] === softline &&
+ (
+ children[i] === softline &&
children[i + 1] === "" &&
- children[i + 2] === hardline) ||
- (children[i] === hardline &&
+ children[i + 2] === hardline
+ ) ||
+ (
+ children[i] === hardline &&
children[i + 1] === "" &&
- children[i + 2] === softline);
+ children[i + 2] === softline
+ );
if (
(isPairOfHardlines && containsText) ||
@@ -500,8 +506,10 @@ function printJsxExpressionContainer(path, options, print) {
const shouldInline =
node.expression.type === "JSXEmptyExpression" ||
- (!hasComment(node.expression) &&
- (node.expression.type === "ArrayExpression" ||
+ (
+ !hasComment(node.expression) &&
+ (
+ node.expression.type === "ArrayExpression" ||
node.expression.type === "ObjectExpression" ||
node.expression.type === "ArrowFunctionExpression" ||
isCallExpression(node.expression) ||
@@ -509,9 +517,15 @@ function printJsxExpressionContainer(path, options, print) {
node.expression.type === "TemplateLiteral" ||
node.expression.type === "TaggedTemplateExpression" ||
node.expression.type === "DoExpression" ||
- (isJsxNode(parent) &&
- (node.expression.type === "ConditionalExpression" ||
- isBinaryish(node.expression)))));
+ (
+ isJsxNode(parent) &&
+ (
+ node.expression.type === "ConditionalExpression" ||
+ isBinaryish(node.expression)
+ )
+ )
+ )
+ );
if (shouldInline) {
return group(["{", print("expression"), lineSuffixBoundary, "}"]);
@@ -575,7 +589,8 @@ function printJsxOpeningElement(path, options, print) {
// Simple tags (no attributes and no comment in tag name) should be
// kept unbroken regardless of `jsxBracketSameLine`
(node.attributes.length === 0 && !nameHasComments) ||
- (options.jsxBracketSameLine &&
+ (
+ options.jsxBracketSameLine &&
// We should print the bracket in a new line for the following cases:
// <div
// // comment
@@ -584,7 +599,8 @@ function printJsxOpeningElement(path, options, print) {
// attr // comment
// >
(!nameHasComments || node.attributes.length > 0) &&
- !lastAttrHasTrailingComments);
+ !lastAttrHasTrailingComments
+ );
// We should print the opening element expanded if any prop value is a
// string literal with newlines
@@ -780,8 +796,10 @@ function isEmptyJsxElement(node) {
function isMeaningfulJsxText(node) {
return (
isLiteral(node) &&
- (containsNonJsxWhitespaceRegex.test(rawText(node)) ||
- !/\n/.test(rawText(node)))
+ (
+ containsNonJsxWhitespaceRegex.test(rawText(node)) ||
+ !/\n/.test(rawText(node))
+ )
);
}
diff --git ORI/prettier/src/language-js/print/member-chain.js ALT/prettier/src/language-js/print/member-chain.js
index 017d17a..67ba26b 100644
--- ORI/prettier/src/language-js/print/member-chain.js
+++ ALT/prettier/src/language-js/print/member-chain.js
@@ -187,9 +187,11 @@ function printMemberChain(path, options, print) {
if (
printedNodes[i].node.type === "TSNonNullExpression" ||
isCallExpression(printedNodes[i].node) ||
- (isMemberExpression(printedNodes[i].node) &&
+ (
+ isMemberExpression(printedNodes[i].node) &&
printedNodes[i].node.computed &&
- isNumericLiteral(printedNodes[i].node.property))
+ isNumericLiteral(printedNodes[i].node.property)
+ )
) {
currentGroup.push(printedNodes[i]);
} else {
@@ -285,10 +287,14 @@ function printMemberChain(path, options, print) {
const firstNode = groups[0][0].node;
return (
firstNode.type === "ThisExpression" ||
- (firstNode.type === "Identifier" &&
- (isFactory(firstNode.name) ||
+ (
+ firstNode.type === "Identifier" &&
+ (
+ isFactory(firstNode.name) ||
(isExpressionStatement && isShort(firstNode.name)) ||
- hasComputed))
+ hasComputed
+ )
+ )
);
}
@@ -336,8 +342,10 @@ function printMemberChain(path, options, print) {
flatGroups
.slice(0, -1)
.some((node) => hasComment(node.node, CommentCheckFlags.Trailing)) ||
- (groups[cutoff] &&
- hasComment(groups[cutoff][0].node, CommentCheckFlags.Leading));
+ (
+ groups[cutoff] &&
+ hasComment(groups[cutoff][0].node, CommentCheckFlags.Leading)
+ );
// If we only have a single `.`, we shouldn't do anything fancy and just
// render everything concatenated together.
@@ -388,10 +396,12 @@ function printMemberChain(path, options, print) {
// * the last call's arguments have a hard line and other calls have non-trivial arguments.
if (
nodeHasComment ||
- (callExpressions.length > 2 &&
+ (
+ callExpressions.length > 2 &&
callExpressions.some(
(expr) => !expr.arguments.every((arg) => isSimpleCallArgument(arg, 0))
- )) ||
+ )
+ ) ||
printedGroups.slice(0, -1).some(willBreak) ||
lastGroupWillBreakAndOtherCallsHaveFunctionArguments()
) {
diff --git ORI/prettier/src/language-js/print/member.js ALT/prettier/src/language-js/print/member.js
index 93bc9a9..9dbb2cd 100644
--- ORI/prettier/src/language-js/print/member.js
+++ ALT/prettier/src/language-js/print/member.js
@@ -17,20 +17,30 @@ function printMemberExpression(path, options, print) {
i++;
} while (
firstNonMemberParent &&
- (isMemberExpression(firstNonMemberParent) ||
- firstNonMemberParent.type === "TSNonNullExpression")
+ (
+ isMemberExpression(firstNonMemberParent) ||
+ firstNonMemberParent.type === "TSNonNullExpression"
+ )
);
const shouldInline =
- (firstNonMemberParent &&
- (firstNonMemberParent.type === "NewExpression" ||
+ (
+ firstNonMemberParent &&
+ (
+ firstNonMemberParent.type === "NewExpression" ||
firstNonMemberParent.type === "BindExpression" ||
- (firstNonMemberParent.type === "AssignmentExpression" &&
- firstNonMemberParent.left.type !== "Identifier"))) ||
+ (
+ firstNonMemberParent.type === "AssignmentExpression" &&
+ firstNonMemberParent.left.type !== "Identifier"
+ )
+ )
+ ) ||
node.computed ||
- (node.object.type === "Identifier" &&
+ (
+ node.object.type === "Identifier" &&
node.property.type === "Identifier" &&
- !isMemberExpression(parent));
+ !isMemberExpression(parent)
+ );
return [
print("object"),
diff --git ORI/prettier/src/language-js/print/misc.js ALT/prettier/src/language-js/print/misc.js
index 417f551..cd3938a 100644
--- ORI/prettier/src/language-js/print/misc.js
+++ ALT/prettier/src/language-js/print/misc.js
@@ -45,9 +45,11 @@ function printTypeAnnotation(path, options, print) {
const parentNode = path.getParentNode();
const isDefinite =
node.definite ||
- (parentNode &&
+ (
+ parentNode &&
parentNode.type === "VariableDeclarator" &&
- parentNode.definite);
+ parentNode.definite
+ );
const isFunctionDeclarationIdentifier =
parentNode.type === "DeclareFunction" && parentNode.id === node;
diff --git ORI/prettier/src/language-js/print/module.js ALT/prettier/src/language-js/print/module.js
index a32b495..4efab83 100644
--- ORI/prettier/src/language-js/print/module.js
+++ ALT/prettier/src/language-js/print/module.js
@@ -302,9 +302,11 @@ function printModuleSpecifier(path, options, print) {
if (
node[rightSideProperty] &&
- (!node[leftSideProperty] ||
+ (
+ !node[leftSideProperty] ||
// import {a as a} from '.'
- !hasSameLoc(node[leftSideProperty], node[rightSideProperty]))
+ !hasSameLoc(node[leftSideProperty], node[rightSideProperty])
+ )
) {
right = print(rightSideProperty);
}
diff --git ORI/prettier/src/language-js/print/object.js ALT/prettier/src/language-js/print/object.js
index ac66f58..c881d0c 100644
--- ORI/prettier/src/language-js/print/object.js
+++ ALT/prettier/src/language-js/print/object.js
@@ -55,14 +55,17 @@ function printObject(path, options, print) {
const isFlowInterfaceLikeBody =
isTypeAnnotation &&
parent &&
- (parent.type === "InterfaceDeclaration" ||
+ (
+ parent.type === "InterfaceDeclaration" ||
parent.type === "DeclareInterface" ||
- parent.type === "DeclareClass") &&
+ parent.type === "DeclareClass"
+ ) &&
path.getName() === "body";
const shouldBreak =
node.type === "TSInterfaceBody" ||
isFlowInterfaceLikeBody ||
- (node.type === "ObjectPattern" &&
+ (
+ node.type === "ObjectPattern" &&
parent.type !== "FunctionDeclaration" &&
parent.type !== "FunctionExpression" &&
parent.type !== "ArrowFunctionExpression" &&
@@ -74,16 +77,21 @@ function printObject(path, options, print) {
node.properties.some(
(property) =>
property.value &&
- (property.value.type === "ObjectPattern" ||
- property.value.type === "ArrayPattern")
- )) ||
- (node.type !== "ObjectPattern" &&
+ (
+ property.value.type === "ObjectPattern" ||
+ property.value.type === "ArrayPattern"
+ )
+ )
+ ) ||
+ (
+ node.type !== "ObjectPattern" &&
firstProperty &&
hasNewlineInRange(
options.originalText,
locStart(node),
locStart(firstProperty)
- ));
+ )
+ );
const separator = isFlowInterfaceLikeBody
? ";"
@@ -117,9 +125,11 @@ function printObject(path, options, print) {
const result = [...separatorParts, group(prop.printed)];
separatorParts = [separator, line];
if (
- (prop.node.type === "TSPropertySignature" ||
+ (
+ prop.node.type === "TSPropertySignature" ||
prop.node.type === "TSMethodSignature" ||
- prop.node.type === "TSConstructSignatureDeclaration") &&
+ prop.node.type === "TSConstructSignatureDeclaration"
+ ) &&
hasComment(prop.node, CommentCheckFlags.PrettierIgnore)
) {
separatorParts.shift();
@@ -158,12 +168,16 @@ function printObject(path, options, print) {
const canHaveTrailingSeparator = !(
node.inexact ||
(lastElem && lastElem.type === "RestElement") ||
- (lastElem &&
- (lastElem.type === "TSPropertySignature" ||
+ (
+ lastElem &&
+ (
+ lastElem.type === "TSPropertySignature" ||
lastElem.type === "TSCallSignatureDeclaration" ||
lastElem.type === "TSMethodSignature" ||
- lastElem.type === "TSConstructSignatureDeclaration") &&
- hasComment(lastElem, CommentCheckFlags.PrettierIgnore))
+ lastElem.type === "TSConstructSignatureDeclaration"
+ ) &&
+ hasComment(lastElem, CommentCheckFlags.PrettierIgnore)
+ )
);
let content;
@@ -208,10 +222,12 @@ function printObject(path, options, print) {
(node) => node.type === "ObjectPattern" && !node.decorators,
(node, name, number) =>
shouldHugFunctionParameters(node) &&
- (name === "params" ||
+ (
+ name === "params" ||
name === "parameters" ||
name === "this" ||
- name === "rest") &&
+ name === "rest"
+ ) &&
number === 0
) ||
path.match(
@@ -220,10 +236,12 @@ function printObject(path, options, print) {
(node, name) => name === "typeAnnotation",
(node, name, number) =>
shouldHugFunctionParameters(node) &&
- (name === "params" ||
+ (
+ name === "params" ||
name === "parameters" ||
name === "this" ||
- name === "rest") &&
+ name === "rest"
+ ) &&
number === 0
)
) {
diff --git ORI/prettier/src/language-js/print/property.js ALT/prettier/src/language-js/print/property.js
index b598c2c..9e181d9 100644
--- ORI/prettier/src/language-js/print/property.js
+++ ALT/prettier/src/language-js/print/property.js
@@ -44,16 +44,22 @@ function printPropertyKey(path, options, print) {
}
if (
- (key.type === "Identifier" ||
- (isNumericLiteral(key) &&
+ (
+ key.type === "Identifier" ||
+ (
+ isNumericLiteral(key) &&
isSimpleNumber(printNumber(rawText(key))) &&
// Avoid converting 999999999999999999999 to 1e+21, 0.99999999999999999 to 1 and 1.0 to 1.
String(key.value) === printNumber(rawText(key)) &&
// Quoting number keys is safe in JS and Flow, but not in TypeScript (as
// mentioned in `isStringPropSafeToUnquote`).
- !(options.parser === "typescript" || options.parser === "babel-ts"))) &&
- (options.parser === "json" ||
- (options.quoteProps === "consistent" && needsQuoteProps.get(parent)))
+ !(options.parser === "typescript" || options.parser === "babel-ts")
+ )
+ ) &&
+ (
+ options.parser === "json" ||
+ (options.quoteProps === "consistent" && needsQuoteProps.get(parent))
+ )
) {
// a -> "a"
// 1 -> "1"
@@ -69,8 +75,10 @@ function printPropertyKey(path, options, print) {
if (
isStringPropSafeToUnquote(node, options) &&
- (options.quoteProps === "as-needed" ||
- (options.quoteProps === "consistent" && !needsQuoteProps.get(parent)))
+ (
+ options.quoteProps === "as-needed" ||
+ (options.quoteProps === "consistent" && !needsQuoteProps.get(parent))
+ )
) {
// 'a' -> a
// '1' -> 1
diff --git ORI/prettier/src/language-js/print/ternary.js ALT/prettier/src/language-js/print/ternary.js
index 4bd00ad..e651f49 100644
--- ORI/prettier/src/language-js/print/ternary.js
+++ ALT/prettier/src/language-js/print/ternary.js
@@ -239,10 +239,12 @@ function printTernary(path, options, print) {
if (
isConditionalExpression &&
- (isJsxNode(node[testNodePropertyNames[0]]) ||
+ (
+ isJsxNode(node[testNodePropertyNames[0]]) ||
isJsxNode(consequentNode) ||
isJsxNode(alternateNode) ||
- conditionalExpressionChainContainsJsx(lastConditionalParent))
+ conditionalExpressionChainContainsJsx(lastConditionalParent)
+ )
) {
jsxMode = true;
forceNoIndent = true;
@@ -334,8 +336,10 @@ function printTernary(path, options, print) {
// ).call()
const breakClosingParen =
!jsxMode &&
- (isMemberExpression(parent) ||
- (parent.type === "NGPipeExpression" && parent.left === node)) &&
+ (
+ isMemberExpression(parent) ||
+ (parent.type === "NGPipeExpression" && parent.left === node)
+ ) &&
!parent.computed;
const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
diff --git ORI/prettier/src/language-js/print/type-annotation.js ALT/prettier/src/language-js/print/type-annotation.js
index ce176da..d856a34 100644
--- ORI/prettier/src/language-js/print/type-annotation.js
+++ ALT/prettier/src/language-js/print/type-annotation.js
@@ -144,9 +144,11 @@ function printUnionType(path, options, print) {
path.getParentNode(1).this !== parent
) &&
!(
- (parent.type === "TypeAlias" ||
+ (
+ parent.type === "TypeAlias" ||
parent.type === "VariableDeclarator" ||
- parent.type === "TSTypeAliasDeclaration") &&
+ parent.type === "TSTypeAliasDeclaration"
+ ) &&
hasLeadingOwnLineComment(options.originalText, node)
);
@@ -211,11 +213,15 @@ function printFunctionType(path, options, print) {
let isArrowFunctionTypeAnnotation =
node.type === "TSFunctionType" ||
!(
- ((parent.type === "ObjectTypeProperty" ||
- parent.type === "ObjectTypeInternalSlot") &&
+ (
+ (
+ parent.type === "ObjectTypeProperty" ||
+ parent.type === "ObjectTypeInternalSlot"
+ ) &&
!parent.variance &&
!parent.optional &&
- locStart(parent) === locStart(node)) ||
+ locStart(parent) === locStart(node)
+ ) ||
parent.type === "ObjectTypeCallProperty" ||
(parentParentParent && parentParentParent.type === "DeclareFunction")
);
diff --git ORI/prettier/src/language-js/print/type-parameters.js ALT/prettier/src/language-js/print/type-parameters.js
index f9aeaa3..d927162 100644
--- ORI/prettier/src/language-js/print/type-parameters.js
+++ ALT/prettier/src/language-js/print/type-parameters.js
@@ -35,9 +35,13 @@ function printTypeParameters(path, options, print, paramsKey) {
const shouldInline =
isParameterInTestCall ||
node[paramsKey].length === 0 ||
- (node[paramsKey].length === 1 &&
- (shouldHugType(node[paramsKey][0]) ||
- node[paramsKey][0].type === "NullableTypeAnnotation"));
+ (
+ node[paramsKey].length === 1 &&
+ (
+ shouldHugType(node[paramsKey][0]) ||
+ node[paramsKey][0].type === "NullableTypeAnnotation"
+ )
+ );
if (shouldInline) {
return [
diff --git ORI/prettier/src/language-js/printer-estree.js ALT/prettier/src/language-js/printer-estree.js
index f30f93e..939c436 100644
--- ORI/prettier/src/language-js/printer-estree.js
+++ ALT/prettier/src/language-js/printer-estree.js
@@ -216,8 +216,10 @@ function printPathNoParens(path, options, print, args) {
case "ParenthesizedExpression": {
const shouldHug =
!hasComment(node.expression) &&
- (node.expression.type === "ObjectExpression" ||
- node.expression.type === "ArrayExpression");
+ (
+ node.expression.type === "ObjectExpression" ||
+ node.expression.type === "ArrayExpression"
+ );
if (shouldHug) {
return ["(", print("expression"), ")"];
}
@@ -660,12 +662,16 @@ function printPathNoParens(path, options, print, args) {
node.param,
(comment) =>
!isBlockComment(comment) ||
- (comment.leading &&
- hasNewline(options.originalText, locEnd(comment))) ||
- (comment.trailing &&
+ (
+ comment.leading &&
+ hasNewline(options.originalText, locEnd(comment))
+ ) ||
+ (
+ comment.trailing &&
hasNewline(options.originalText, locStart(comment), {
backwards: true,
- }))
+ })
+ )
);
const param = print("param");
diff --git ORI/prettier/src/language-js/utils.js ALT/prettier/src/language-js/utils.js
index 7a9e983..32227b9 100644
--- ORI/prettier/src/language-js/utils.js
+++ ALT/prettier/src/language-js/utils.js
@@ -289,8 +289,10 @@ function isFunctionOrArrowExpression(node) {
function isFunctionOrArrowExpressionWithBody(node) {
return (
node.type === "FunctionExpression" ||
- (node.type === "ArrowFunctionExpression" &&
- node.body.type === "BlockStatement")
+ (
+ node.type === "ArrowFunctionExpression" &&
+ node.body.type === "BlockStatement"
+ )
);
}
@@ -313,9 +315,11 @@ function isAngularTestWrapper(node) {
return (
isCallExpression(node) &&
node.callee.type === "Identifier" &&
- (node.callee.name === "async" ||
+ (
+ node.callee.name === "async" ||
node.callee.name === "inject" ||
- node.callee.name === "fakeAsync")
+ node.callee.name === "fakeAsync"
+ )
);
}
@@ -362,8 +366,10 @@ function isFunctionNotation(node) {
*/
function isObjectTypePropertyAFunction(node) {
return (
- (node.type === "ObjectTypeProperty" ||
- node.type === "ObjectTypeInternalSlot") &&
+ (
+ node.type === "ObjectTypeProperty" ||
+ node.type === "ObjectTypeInternalSlot"
+ ) &&
node.value.type === "FunctionTypeAnnotation" &&
!node.static &&
!isFunctionNotation(node)
@@ -461,8 +467,10 @@ function isSimpleType(node) {
}
if (
- (node.type === "GenericTypeAnnotation" ||
- node.type === "TSTypeReference") &&
+ (
+ node.type === "GenericTypeAnnotation" ||
+ node.type === "TSTypeReference"
+ ) &&
!node.typeParameters
) {
return true;
@@ -487,8 +495,10 @@ function isSkipOrOnlyBlock(node) {
node.callee.object.type === "Identifier" &&
node.callee.property.type === "Identifier" &&
unitTestRe.test(node.callee.object.name) &&
- (node.callee.property.name === "only" ||
- node.callee.property.name === "skip")
+ (
+ node.callee.property.name === "only" ||
+ node.callee.property.name === "skip"
+ )
);
}
@@ -520,11 +530,17 @@ function isTestCall(node, parent) {
}
} else if (node.arguments.length === 2 || node.arguments.length === 3) {
if (
- ((node.callee.type === "Identifier" &&
- unitTestRe.test(node.callee.name)) ||
- isSkipOrOnlyBlock(node)) &&
- (isTemplateLiteral(node.arguments[0]) ||
- isStringLiteral(node.arguments[0]))
+ (
+ (
+ node.callee.type === "Identifier" &&
+ unitTestRe.test(node.callee.name)
+ ) ||
+ isSkipOrOnlyBlock(node)
+ ) &&
+ (
+ isTemplateLiteral(node.arguments[0]) ||
+ isStringLiteral(node.arguments[0])
+ )
) {
// it("name", () => { ... }, 2500)
if (node.arguments[2] && !isNumericLiteral(node.arguments[2])) {
@@ -560,8 +576,10 @@ function isCallExpression(node) {
function isMemberExpression(node) {
return (
node &&
- (node.type === "MemberExpression" ||
- node.type === "OptionalMemberExpression")
+ (
+ node.type === "MemberExpression" ||
+ node.type === "OptionalMemberExpression"
+ )
);
}
@@ -722,18 +740,26 @@ function isStringPropSafeToUnquote(node, options) {
options.parser !== "json" &&
isStringLiteral(node.key) &&
rawText(node.key).slice(1, -1) === node.key.value &&
- ((isIdentifierName(node.key.value) &&
- // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
- // See https://github.com/microsoft/TypeScript/pull/20075
- !(
- (options.parser === "typescript" || options.parser === "babel-ts") &&
- node.type === "ClassProperty"
- )) ||
- (isSimpleNumber(node.key.value) &&
+ (
+ (
+ isIdentifierName(node.key.value) &&
+ // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
+ // See https://github.com/microsoft/TypeScript/pull/20075
+ !(
+ (options.parser === "typescript" || options.parser === "babel-ts") &&
+ node.type === "ClassProperty"
+ )
+ ) ||
+ (
+ isSimpleNumber(node.key.value) &&
String(Number(node.key.value)) === node.key.value &&
- (options.parser === "babel" ||
+ (
+ options.parser === "babel" ||
options.parser === "espree" ||
- options.parser === "meriyah")))
+ options.parser === "meriyah"
+ )
+ )
+ )
);
}
@@ -765,14 +791,22 @@ function isJestEachTemplateLiteral(node, parentNode) {
parentNode.tag.type === "MemberExpression" &&
parentNode.tag.property.type === "Identifier" &&
parentNode.tag.property.name === "each" &&
- ((parentNode.tag.object.type === "Identifier" &&
- jestEachTriggerRegex.test(parentNode.tag.object.name)) ||
- (parentNode.tag.object.type === "MemberExpression" &&
+ (
+ (
+ parentNode.tag.object.type === "Identifier" &&
+ jestEachTriggerRegex.test(parentNode.tag.object.name)
+ ) ||
+ (
+ parentNode.tag.object.type === "MemberExpression" &&
parentNode.tag.object.property.type === "Identifier" &&
- (parentNode.tag.object.property.name === "only" ||
- parentNode.tag.object.property.name === "skip") &&
+ (
+ parentNode.tag.object.property.name === "only" ||
+ parentNode.tag.object.property.name === "skip"
+ ) &&
parentNode.tag.object.object.type === "Identifier" &&
- jestEachTriggerRegex.test(parentNode.tag.object.object.name)))
+ jestEachTriggerRegex.test(parentNode.tag.object.object.name)
+ )
+ )
);
}
@@ -791,9 +825,13 @@ function templateLiteralHasNewLines(template) {
*/
function isTemplateOnItsOwnLine(node, text) {
return (
- ((node.type === "TemplateLiteral" && templateLiteralHasNewLines(node)) ||
- (node.type === "TaggedTemplateExpression" &&
- templateLiteralHasNewLines(node.quasi))) &&
+ (
+ (node.type === "TemplateLiteral" && templateLiteralHasNewLines(node)) ||
+ (
+ node.type === "TaggedTemplateExpression" &&
+ templateLiteralHasNewLines(node.quasi)
+ )
+ ) &&
!hasNewline(text, locStart(node), { backwards: true })
);
}
@@ -1262,14 +1300,18 @@ const getCommentTestFunction = (flags, fn) => {
!(
(flags & CommentCheckFlags.Leading && !comment.leading) ||
(flags & CommentCheckFlags.Trailing && !comment.trailing) ||
- (flags & CommentCheckFlags.Dangling &&
- (comment.leading || comment.trailing)) ||
+ (
+ flags & CommentCheckFlags.Dangling &&
+ (comment.leading || comment.trailing)
+ ) ||
(flags & CommentCheckFlags.Block && !isBlockComment(comment)) ||
(flags & CommentCheckFlags.Line && !isLineComment(comment)) ||
(flags & CommentCheckFlags.First && index !== 0) ||
(flags & CommentCheckFlags.Last && index !== comments.length - 1) ||
- (flags & CommentCheckFlags.PrettierIgnore &&
- !isPrettierIgnoreComment(comment)) ||
+ (
+ flags & CommentCheckFlags.PrettierIgnore &&
+ !isPrettierIgnoreComment(comment)
+ ) ||
(fn && !fn(comment))
);
}
diff --git ORI/prettier/src/language-markdown/clean.js ALT/prettier/src/language-markdown/clean.js
index 869eef9..614784a 100644
--- ORI/prettier/src/language-markdown/clean.js
+++ ALT/prettier/src/language-markdown/clean.js
@@ -50,9 +50,11 @@ function clean(ast, newObj, parent) {
}
if (
- (ast.type === "definition" ||
+ (
+ ast.type === "definition" ||
ast.type === "link" ||
- ast.type === "image") &&
+ ast.type === "image"
+ ) &&
ast.title
) {
newObj.title = ast.title.replace(/\\(["')])/g, "$1");
@@ -63,8 +65,10 @@ function clean(ast, newObj, parent) {
parent &&
parent.type === "root" &&
parent.children.length > 0 &&
- (parent.children[0] === ast ||
- (isFrontMatterNode(parent.children[0]) && parent.children[1] === ast)) &&
+ (
+ parent.children[0] === ast ||
+ (isFrontMatterNode(parent.children[0]) && parent.children[1] === ast)
+ ) &&
ast.type === "html" &&
startWithPragma(ast.value)
) {
diff --git ORI/prettier/src/language-markdown/printer-markdown.js ALT/prettier/src/language-markdown/printer-markdown.js
index 6fe7c25..1d9a79c 100644
--- ORI/prettier/src/language-markdown/printer-markdown.js
+++ ALT/prettier/src/language-markdown/printer-markdown.js
@@ -120,13 +120,15 @@ function genericPrint(path, options, print) {
if (
escapedValue !== node.value &&
- (path.match(undefined, isFirstSentence, isLastChildAutolink) ||
+ (
+ path.match(undefined, isFirstSentence, isLastChildAutolink) ||
path.match(
undefined,
isFirstSentence,
(node, name, index) => node.type === "emphasis" && index === 0,
isLastChildAutolink
- ))
+ )
+ )
) {
// backslash is parsed as part of autolinks, so we need to remove it
escapedValue = escapedValue.replace(/^(\\?[*_])+/, (prefix) =>
@@ -159,16 +161,20 @@ function genericPrint(path, options, print) {
const prevNode = parentNode.children[index - 1];
const nextNode = parentNode.children[index + 1];
const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
- (prevNode &&
+ (
+ prevNode &&
prevNode.type === "sentence" &&
prevNode.children.length > 0 &&
getLast(prevNode.children).type === "word" &&
- !getLast(prevNode.children).hasTrailingPunctuation) ||
- (nextNode &&
+ !getLast(prevNode.children).hasTrailingPunctuation
+ ) ||
+ (
+ nextNode &&
nextNode.type === "sentence" &&
nextNode.children.length > 0 &&
nextNode.children[0].type === "word" &&
- !nextNode.children[0].hasLeadingPunctuation);
+ !nextNode.children[0].hasLeadingPunctuation
+ );
style =
hasPrevOrNextWord || getAncestorNode(path, "emphasis") ? "*" : "_";
}
@@ -395,10 +401,14 @@ function genericPrint(path, options, print) {
const shouldInlineFootnote =
node.children.length === 1 &&
node.children[0].type === "paragraph" &&
- (options.proseWrap === "never" ||
- (options.proseWrap === "preserve" &&
+ (
+ options.proseWrap === "never" ||
+ (
+ options.proseWrap === "preserve" &&
node.children[0].position.start.line ===
- node.children[0].position.end.line));
+ node.children[0].position.end.line
+ )
+ );
return [
"[^",
node.identifier,
@@ -829,8 +839,10 @@ function shouldRemainTheSameContent(path) {
return (
ancestorNode &&
- (ancestorNode.type !== "linkReference" ||
- ancestorNode.referenceType !== "full")
+ (
+ ancestorNode.type !== "linkReference" ||
+ ancestorNode.referenceType !== "full"
+ )
);
}
diff --git ORI/prettier/src/language-markdown/utils.js ALT/prettier/src/language-markdown/utils.js
index 4b7d260..8b3fd07 100644
--- ORI/prettier/src/language-markdown/utils.js
+++ ALT/prettier/src/language-markdown/utils.js
@@ -125,12 +125,16 @@ function splitText(text, options) {
const lastNode = getLast(nodes);
if (lastNode && lastNode.type === "word") {
if (
- (lastNode.kind === KIND_NON_CJK &&
+ (
+ lastNode.kind === KIND_NON_CJK &&
node.kind === KIND_CJ_LETTER &&
- !lastNode.hasTrailingPunctuation) ||
- (lastNode.kind === KIND_CJ_LETTER &&
+ !lastNode.hasTrailingPunctuation
+ ) ||
+ (
+ lastNode.kind === KIND_CJ_LETTER &&
node.kind === KIND_NON_CJK &&
- !node.hasLeadingPunctuation)
+ !node.hasLeadingPunctuation
+ )
) {
nodes.push({ type: "whitespace", value: " " });
} else if (
diff --git ORI/prettier/src/language-yaml/print/mapping-item.js ALT/prettier/src/language-yaml/print/mapping-item.js
index 7a23e14..086d691 100644
--- ORI/prettier/src/language-yaml/print/mapping-item.js
+++ ALT/prettier/src/language-yaml/print/mapping-item.js
@@ -93,15 +93,21 @@ function printMappingItem(node, parentNode, path, print, options) {
const flatValueParts = [spaceBeforeColon, ":"];
if (
hasLeadingComments(value.content) ||
- (hasEndComments(value) &&
+ (
+ hasEndComments(value) &&
value.content &&
- !isNode(value.content, ["mapping", "sequence"])) ||
- (parentNode.type === "mapping" &&
+ !isNode(value.content, ["mapping", "sequence"])
+ ) ||
+ (
+ parentNode.type === "mapping" &&
hasTrailingComment(key.content) &&
- isInlineNode(value.content)) ||
- (isNode(value.content, ["mapping", "sequence"]) &&
+ isInlineNode(value.content)
+ ) ||
+ (
+ isNode(value.content, ["mapping", "sequence"]) &&
value.content.tag === null &&
- value.content.anchor === null)
+ value.content.anchor === null
+ )
) {
flatValueParts.push(hardline);
} else if (value.content) {
diff --git ORI/prettier/src/language-yaml/printer-yaml.js ALT/prettier/src/language-yaml/printer-yaml.js
index ed60df1..5b1bd3e 100644
--- ORI/prettier/src/language-yaml/printer-yaml.js
+++ ALT/prettier/src/language-yaml/printer-yaml.js
@@ -359,19 +359,23 @@ function shouldPrintDocumentEndMarker(document, nextDocument) {
*... # trailingComment
*/
hasTrailingComment(document) ||
- (nextDocument &&
+ (
+ nextDocument &&
/**
* ...
* %DIRECTIVE
* ---
*/
- (nextDocument.head.children.length > 0 ||
+ (
+ nextDocument.head.children.length > 0 ||
/**
* ...
* # endComment
* ---
*/
- hasEndComments(nextDocument.head)))
+ hasEndComments(nextDocument.head)
+ )
+ )
);
}
@@ -386,10 +390,12 @@ function shouldPrintDocumentHeadEndMarker(
* ---
* preserve the first document head end marker
*/
- (root.children[0] === document &&
+ (
+ root.children[0] === document &&
/---(\s|$)/.test(
options.originalText.slice(locStart(document), locStart(document) + 4)
- )) ||
+ )
+ ) ||
/**
* %DIRECTIVE
* ---
diff --git ORI/prettier/src/main/comments.js ALT/prettier/src/main/comments.js
index edd8452..96bd963 100644
--- ORI/prettier/src/main/comments.js
+++ ALT/prettier/src/main/comments.js
@@ -47,9 +47,12 @@ function getSortedChildNodes(node, options, resultArray) {
}
const childNodes =
- (printer.getCommentChildNodes &&
- printer.getCommentChildNodes(node, options)) ||
- (typeof node === "object" &&
+ (
+ printer.getCommentChildNodes &&
+ printer.getCommentChildNodes(node, options)
+ ) ||
+ (
+ typeof node === "object" &&
Object.entries(node)
.filter(
([key]) =>
@@ -59,7 +62,8 @@ function getSortedChildNodes(node, options, resultArray) {
key !== "tokens" &&
key !== "comments"
)
- .map(([, value]) => value));
+ .map(([, value]) => value)
+ );
if (!childNodes) {
return;
@@ -363,8 +367,10 @@ function breakTies(tiesToBreak, text, options) {
const { precedingNode, followingNode, enclosingNode } = tiesToBreak[0];
const gapRegExp =
- (options.printer.getGapRegex &&
- options.printer.getGapRegex(enclosingNode)) ||
+ (
+ options.printer.getGapRegex &&
+ options.printer.getGapRegex(enclosingNode)
+ ) ||
/^[\s(]*$/;
let gapEndPos = options.locStart(followingNode);
diff --git ORI/prettier/src/main/options.js ALT/prettier/src/main/options.js
index 43a1d22..03f31cb 100644
--- ORI/prettier/src/main/options.js
+++ ALT/prettier/src/main/options.js
@@ -176,12 +176,14 @@ function inferParser(filepath, plugins) {
// do it last.
let language = languages.find(
(language) =>
- (language.extensions &&
- language.extensions.some((extension) =>
- filename.endsWith(extension)
- )) ||
- (language.filenames &&
- language.filenames.some((name) => name.toLowerCase() === filename))
+ (
+ language.extensions &&
+ language.extensions.some((extension) => filename.endsWith(extension))
+ ) ||
+ (
+ language.filenames &&
+ language.filenames.some((name) => name.toLowerCase() === filename)
+ )
);
if (!language && !filename.includes(".")) {
diff --git ORI/prettier/src/main/range-util.js ALT/prettier/src/main/range-util.js
index 71b5035..3f99241 100644
--- ORI/prettier/src/main/range-util.js
+++ ALT/prettier/src/main/range-util.js
@@ -120,13 +120,15 @@ function isJsSourceElement(type, parentType) {
return (
parentType !== "DeclareExportDeclaration" &&
type !== "TypeParameterDeclaration" &&
- (type === "Directive" ||
+ (
+ type === "Directive" ||
type === "TypeAlias" ||
type === "TSExportAssignment" ||
type.startsWith("Declare") ||
type.startsWith("TSDeclare") ||
type.endsWith("Statement") ||
- type.endsWith("Declaration"))
+ type.endsWith("Declaration")
+ )
);
}
prettier/prettier#11103 VS prettier/prettier@main :: marmelab/react-admin@43c4faf
Diff (171 lines)
diff --git ORI/react-admin/packages/ra-core/src/controller/input/referenceDataStatus.ts ALT/react-admin/packages/ra-core/src/controller/input/referenceDataStatus.ts
index 2677b32..84cdd2d 100644
--- ORI/react-admin/packages/ra-core/src/controller/input/referenceDataStatus.ts
+++ ALT/react-admin/packages/ra-core/src/controller/input/referenceDataStatus.ts
@@ -40,9 +40,11 @@ export const getStatusForInput = ({
(input.value && selectedReferenceError && !matchingReferences) ||
(!input.value && !matchingReferences),
error:
- (input.value &&
+ (
+ input.value &&
selectedReferenceError &&
- matchingReferencesError) ||
+ matchingReferencesError
+ ) ||
(!input.value && matchingReferencesError)
? input.value
? selectedReferenceError
@@ -104,23 +106,31 @@ export const getStatusForArrayInput = ({
return {
waiting:
- (!matchingReferences &&
+ (
+ !matchingReferences &&
input.value &&
- selectedReferencesDataStatus === REFERENCES_STATUS_EMPTY) ||
+ selectedReferencesDataStatus === REFERENCES_STATUS_EMPTY
+ ) ||
(!matchingReferences && !input.value),
error:
matchingReferencesError &&
- (!input.value ||
- (input.value &&
- selectedReferencesDataStatus === REFERENCES_STATUS_EMPTY))
+ (
+ !input.value ||
+ (
+ input.value &&
+ selectedReferencesDataStatus === REFERENCES_STATUS_EMPTY
+ )
+ )
? translate('ra.input.references.all_missing', {
_: 'ra.input.references.all_missing',
})
: null,
warning:
matchingReferencesError ||
- (input.value &&
- selectedReferencesDataStatus !== REFERENCES_STATUS_READY)
+ (
+ input.value &&
+ selectedReferencesDataStatus !== REFERENCES_STATUS_READY
+ )
? matchingReferencesError ||
translate('ra.input.references.many_missing', {
_: 'ra.input.references.many_missing',
diff --git ORI/react-admin/packages/ra-core/src/controller/useListParams.ts ALT/react-admin/packages/ra-core/src/controller/useListParams.ts
index 60bb878..029aa88 100644
--- ORI/react-admin/packages/ra-core/src/controller/useListParams.ts
+++ ALT/react-admin/packages/ra-core/src/controller/useListParams.ts
@@ -330,11 +330,13 @@ export const hasCustomParams = (params: ListParams) => {
return (
params &&
params.filter &&
- (Object.keys(params.filter).length > 0 ||
+ (
+ Object.keys(params.filter).length > 0 ||
params.order != null ||
params.page !== 1 ||
params.perPage != null ||
- params.sort != null)
+ params.sort != null
+ )
);
};
diff --git ORI/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx ALT/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx
index 45578d1..4630d00 100644
--- ORI/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx
+++ ALT/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx
@@ -117,8 +117,10 @@ const CoreAdminRouter: FunctionComponent<AdminRouterProps> = props => {
}
if (
- (typeof children === 'function' &&
- (!computedChildren || computedChildren.length === 0)) ||
+ (
+ typeof children === 'function' &&
+ (!computedChildren || computedChildren.length === 0)
+ ) ||
(Array.isArray(children) && children.length === 0)
) {
return (
diff --git ORI/react-admin/packages/ra-core/src/core/createAdminStore.ts ALT/react-admin/packages/ra-core/src/core/createAdminStore.ts
index 43692d7..590287b 100644
--- ORI/react-admin/packages/ra-core/src/core/createAdminStore.ts
+++ ALT/react-admin/packages/ra-core/src/core/createAdminStore.ts
@@ -66,13 +66,15 @@ export default ({
const typedWindow = typeof window !== 'undefined' && (window as Window);
const composeEnhancers =
- (process.env.NODE_ENV === 'development' &&
+ (
+ process.env.NODE_ENV === 'development' &&
typeof typedWindow !== 'undefined' &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
trace: true,
traceLimit: 25,
- })) ||
+ })
+ ) ||
compose;
const store = createStore(
diff --git ORI/react-admin/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx ALT/react-admin/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx
index 29b41a6..576d39a 100644
--- ORI/react-admin/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx
+++ ALT/react-admin/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx
@@ -53,9 +53,13 @@ const useWarnWhenUnsavedChanges = (enable: boolean) => {
const formState = form.getState();
if (
formState.dirty &&
- (!formState.submitSucceeded ||
- (formState.submitSucceeded &&
- formState.dirtySinceLastSubmit))
+ (
+ !formState.submitSucceeded ||
+ (
+ formState.submitSucceeded &&
+ formState.dirtySinceLastSubmit
+ )
+ )
) {
if (!window.confirm(translate('ra.message.unsaved_changes'))) {
const dirtyFields = formState.submitSucceeded
diff --git ORI/react-admin/packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx ALT/react-admin/packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx
index 9711361..6ca61a7 100644
--- ORI/react-admin/packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx
+++ ALT/react-admin/packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx
@@ -231,8 +231,10 @@ const SimpleFormIterator: FC<SimpleFormIteratorProps> = props => {
...inputProps,
})}
record={
- (records &&
- records[index]) ||
+ (
+ records &&
+ records[index]
+ ) ||
{}
}
resource={resource}
diff --git ORI/react-admin/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx ALT/react-admin/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx
index 80d4f8a..80942c5 100644
--- ORI/react-admin/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx
+++ ALT/react-admin/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx
@@ -63,9 +63,11 @@ const DatagridRow: FC<DatagridRowProps> = React.forwardRef((props, ref) => {
const context = useDatagridContext();
const expandable =
- (!context ||
+ (
+ !context ||
!context.isRowExpandable ||
- context.isRowExpandable(record)) &&
+ context.isRowExpandable(record)
+ ) &&
expand;
const resource = useResourceContext(props);
const [expanded, toggleExpanded] = useExpanded(resource, id);
prettier/prettier#11103 VS prettier/prettier@main :: typescript-eslint/typescript-eslint@d0d7186
Diff (1240 lines)
diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md
index cac4785..45db986 100644
--- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md
+++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md
@@ -405,9 +405,10 @@ type Foo<T, U> =
type Foo<T, U> = { [P in keyof T]?: T[P] } | { [P in keyof U]?: U[P] };
-type Foo<T, U> = { readonly [P in keyof T]: T[P] } & {
- readonly [P in keyof U]: U[P];
-};
+type Foo<T, U> = { readonly [P in keyof T]: T[P] } &
+ {
+ readonly [P in keyof U]: U[P];
+ };
type Foo<T, U> = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] };
```
@@ -419,9 +420,10 @@ type Foo<T> = { readonly [P in keyof T]: T[P] };
type Foo<T> = { [P in keyof T]?: T[P] };
-type Foo<T, U> = { readonly [P in keyof T]: T[P] } & {
- readonly [P in keyof U]: U[P];
-};
+type Foo<T, U> = { readonly [P in keyof T]: T[P] } &
+ {
+ readonly [P in keyof U]: U[P];
+ };
type Foo<T, U> = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] };
```
@@ -453,9 +455,10 @@ type Foo<T, U> = { [P in keyof T]?: T[P] } | { [P in keyof U]?: U[P] };
Examples of **correct** code for the `{ "allowMappedTypes": "in-intersections" }` option:
```ts
-type Foo<T, U> = { readonly [P in keyof T]: T[P] } & {
- readonly [P in keyof U]: U[P];
-};
+type Foo<T, U> = { readonly [P in keyof T]: T[P] } &
+ {
+ readonly [P in keyof U]: U[P];
+ };
type Foo<T, U> = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] };
```
@@ -477,9 +480,10 @@ type Foo<T, U> =
type Foo<T, U> = { [P in keyof T]?: T[P] } | { [P in keyof U]?: U[P] };
-type Foo<T, U> = { readonly [P in keyof T]: T[P] } & {
- readonly [P in keyof U]: U[P];
-};
+type Foo<T, U> = { readonly [P in keyof T]: T[P] } &
+ {
+ readonly [P in keyof U]: U[P];
+ };
type Foo<T, U> = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] };
```
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/consistent-type-assertions.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
index 3b431b8..7c5bca8 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
@@ -137,11 +137,13 @@ export default util.createRule<Options, MessageIds>({
if (
options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
node.parent &&
- (node.parent.type === AST_NODE_TYPES.NewExpression ||
+ (
+ node.parent.type === AST_NODE_TYPES.NewExpression ||
node.parent.type === AST_NODE_TYPES.CallExpression ||
node.parent.type === AST_NODE_TYPES.ThrowStatement ||
node.parent.type === AST_NODE_TYPES.AssignmentPattern ||
- node.parent.type === AST_NODE_TYPES.JSXExpressionContainer)
+ node.parent.type === AST_NODE_TYPES.JSXExpressionContainer
+ )
) {
return;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/default-param-last.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/default-param-last.ts
index dea4111..7457d6d 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/default-param-last.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/default-param-last.ts
@@ -64,8 +64,10 @@ export default createRule({
if (
hasSeenPlainParam &&
- (isOptionalParam(param) ||
- param.type === AST_NODE_TYPES.AssignmentPattern)
+ (
+ isOptionalParam(param) ||
+ param.type === AST_NODE_TYPES.AssignmentPattern
+ )
) {
context.report({ node: current, messageId: 'shouldBeLast' });
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts
index b2b980c..d14b412 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts
@@ -70,8 +70,10 @@ export default createRule<Options, MessageIds>({
return {
MemberExpression(node: TSESTree.MemberExpression): void {
if (
- (allowPrivateClassPropertyAccess ||
- allowProtectedClassPropertyAccess) &&
+ (
+ allowPrivateClassPropertyAccess ||
+ allowProtectedClassPropertyAccess
+ ) &&
node.computed
) {
// for perf reasons - only fetch the symbol if we have to
@@ -81,10 +83,14 @@ export default createRule<Options, MessageIds>({
const modifierKind =
objectSymbol?.getDeclarations()?.[0]?.modifiers?.[0].kind;
if (
- (allowPrivateClassPropertyAccess &&
- modifierKind == ts.SyntaxKind.PrivateKeyword) ||
- (allowProtectedClassPropertyAccess &&
- modifierKind == ts.SyntaxKind.ProtectedKeyword)
+ (
+ allowPrivateClassPropertyAccess &&
+ modifierKind == ts.SyntaxKind.PrivateKeyword
+ ) ||
+ (
+ allowProtectedClassPropertyAccess &&
+ modifierKind == ts.SyntaxKind.ProtectedKeyword
+ )
) {
return;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts
index bdcd975..9e170ca 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts
@@ -441,8 +441,10 @@ export default util.createRule<Options, MessageIds>({
node.parent?.type === AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'constructor';
const isSetAccessor =
- (node.parent?.type === AST_NODE_TYPES.TSAbstractMethodDefinition ||
- node.parent?.type === AST_NODE_TYPES.MethodDefinition) &&
+ (
+ node.parent?.type === AST_NODE_TYPES.TSAbstractMethodDefinition ||
+ node.parent?.type === AST_NODE_TYPES.MethodDefinition
+ ) &&
node.parent.kind === 'set';
if (!isConstructor && !isSetAccessor && !node.returnType) {
context.report({
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts
index deadf6c..e536a45 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts
@@ -541,20 +541,26 @@ export default createRule<Options, MessageIds>({
while (
statement &&
- ((statement.type === AST_NODE_TYPES.UnaryExpression &&
- ['!', '~', '+', '-'].includes(statement.operator)) ||
+ (
+ (
+ statement.type === AST_NODE_TYPES.UnaryExpression &&
+ ['!', '~', '+', '-'].includes(statement.operator)
+ ) ||
statement.type === AST_NODE_TYPES.AssignmentExpression ||
statement.type === AST_NODE_TYPES.LogicalExpression ||
statement.type === AST_NODE_TYPES.SequenceExpression ||
- statement.type === AST_NODE_TYPES.VariableDeclarator)
+ statement.type === AST_NODE_TYPES.VariableDeclarator
+ )
) {
statement = statement.parent;
}
return (
!!statement &&
- (statement.type === AST_NODE_TYPES.ExpressionStatement ||
- statement.type === AST_NODE_TYPES.VariableDeclaration) &&
+ (
+ statement.type === AST_NODE_TYPES.ExpressionStatement ||
+ statement.type === AST_NODE_TYPES.VariableDeclaration
+ ) &&
!!statement.parent &&
statement.parent.type === AST_NODE_TYPES.Program
);
@@ -940,8 +946,10 @@ export default createRule<Options, MessageIds>({
blockIndentLevel = options.outerIIFEBody;
} else if (
node.parent &&
- (node.parent.type === AST_NODE_TYPES.FunctionExpression ||
- node.parent.type === AST_NODE_TYPES.ArrowFunctionExpression)
+ (
+ node.parent.type === AST_NODE_TYPES.FunctionExpression ||
+ node.parent.type === AST_NODE_TYPES.ArrowFunctionExpression
+ )
) {
blockIndentLevel = options.FunctionExpression.body;
} else if (
@@ -1287,8 +1295,10 @@ export default createRule<Options, MessageIds>({
// Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
if (
node.arguments.length > 0 ||
- (isClosingParenToken(sourceCode.getLastToken(node)!) &&
- isOpeningParenToken(sourceCode.getLastToken(node, 1)!))
+ (
+ isClosingParenToken(sourceCode.getLastToken(node)!) &&
+ isOpeningParenToken(sourceCode.getLastToken(node, 1)!)
+ )
) {
addFunctionCallIndent(node);
}
@@ -1710,16 +1720,20 @@ export default createRule<Options, MessageIds>({
// If a comment matches the expected indentation of the token immediately before or after, don't report it.
if (
- (mayAlignWithBefore &&
+ (
+ mayAlignWithBefore &&
validateTokenIndent(
firstTokenOfLine,
offsets.getDesiredIndent(tokenBefore),
- )) ||
- (mayAlignWithAfter &&
+ )
+ ) ||
+ (
+ mayAlignWithAfter &&
validateTokenIndent(
firstTokenOfLine,
offsets.getDesiredIndent(tokenAfter),
- ))
+ )
+ )
) {
return;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts
index 16e31b6..3ef0d0f 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts
@@ -181,9 +181,11 @@ export default util.createRule<Options, MessageIds>({
(id.parent?.type === AST_NODE_TYPES.Property && id.parent.shorthand) ||
// `const { x = 2 }`
// does not match const `{ x: y = 2 }`
- (id.parent?.type === AST_NODE_TYPES.AssignmentPattern &&
+ (
+ id.parent?.type === AST_NODE_TYPES.AssignmentPattern &&
id.parent.parent?.type === AST_NODE_TYPES.Property &&
- id.parent.parent.shorthand)
+ id.parent.parent.shorthand
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-floating-promises.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-floating-promises.ts
index 905dfd0..668766b 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-floating-promises.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-floating-promises.ts
@@ -97,9 +97,11 @@ export default util.createRule<Options, MessageId>({
return (
node.expression.type === AST_NODE_TYPES.CallExpression &&
- (node.expression.callee.type ===
- AST_NODE_TYPES.ArrowFunctionExpression ||
- node.expression.callee.type === AST_NODE_TYPES.FunctionExpression)
+ (
+ node.expression.callee.type ===
+ AST_NODE_TYPES.ArrowFunctionExpression ||
+ node.expression.callee.type === AST_NODE_TYPES.FunctionExpression
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-implied-eval.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-implied-eval.ts
index c7caf2d..c8cf81f 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-implied-eval.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-implied-eval.ts
@@ -113,8 +113,10 @@ export default util.createRule({
case AST_NODE_TYPES.CallExpression:
return (
- (node.callee.type === AST_NODE_TYPES.Identifier &&
- node.callee.name === 'bind') ||
+ (
+ node.callee.type === AST_NODE_TYPES.Identifier &&
+ node.callee.name === 'bind'
+ ) ||
isFunctionType(node)
);
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-inferrable-types.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-inferrable-types.ts
index 110bda4..7f80292 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-inferrable-types.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-inferrable-types.ts
@@ -121,8 +121,10 @@ export default util.createRule<Options, MessageIds>({
return (
isFunctionCall(unwrappedInit, 'BigInt') ||
- (unwrappedInit.type === AST_NODE_TYPES.Literal &&
- 'bigint' in unwrappedInit)
+ (
+ unwrappedInit.type === AST_NODE_TYPES.Literal &&
+ 'bigint' in unwrappedInit
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-invalid-void-type.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-invalid-void-type.ts
index 0dff489..c9d5439 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-invalid-void-type.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-invalid-void-type.ts
@@ -140,12 +140,14 @@ export default util.createRule<[Options], MessageIds>({
member =>
validUnionMembers.includes(member.type) ||
// allows any T<..., void, ...> here, checked by checkGenericTypeArgument
- (member.type === AST_NODE_TYPES.TSTypeReference &&
+ (
+ member.type === AST_NODE_TYPES.TSTypeReference &&
member.typeParameters?.type ===
AST_NODE_TYPES.TSTypeParameterInstantiation &&
member.typeParameters?.params
.map(param => param.type)
- .includes(AST_NODE_TYPES.TSVoidKeyword)),
+ .includes(AST_NODE_TYPES.TSVoidKeyword)
+ ),
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-loop-func.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-loop-func.ts
index 44d0178..e440eba 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-loop-func.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-loop-func.ts
@@ -211,8 +211,10 @@ function isSafe(
return (
!upperRef.isWrite() ||
- (variable?.scope?.variableScope === upperRef.from.variableScope &&
- id.range[0] < border)
+ (
+ variable?.scope?.variableScope === upperRef.from.variableScope &&
+ id.range[0] < border
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts
index f8cc05b..ee1de44 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts
@@ -53,8 +53,10 @@ export default util.createRule<Options, MessageIds>({
function isDeclaration(node: TSESTree.TSModuleDeclaration): boolean {
return (
node.declare === true ||
- (node.parent!.parent?.type === AST_NODE_TYPES.TSModuleDeclaration &&
- isDeclaration(node.parent!.parent))
+ (
+ node.parent!.parent?.type === AST_NODE_TYPES.TSModuleDeclaration &&
+ isDeclaration(node.parent!.parent)
+ )
);
}
@@ -63,8 +65,10 @@ export default util.createRule<Options, MessageIds>({
node: TSESTree.TSModuleDeclaration,
): void {
if (
- (node.parent &&
- node.parent.type === AST_NODE_TYPES.TSModuleDeclaration) ||
+ (
+ node.parent &&
+ node.parent.type === AST_NODE_TYPES.TSModuleDeclaration
+ ) ||
(allowDefinitionFiles && util.isDefinitionFile(filename)) ||
(allowDeclarations && isDeclaration(node))
) {
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts
index 399966b..95fb3cd 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts
@@ -76,8 +76,10 @@ export default util.createRule<Options, MessageIds>({
if (
options?.builtinGlobals &&
'eslintImplicitGlobalSetting' in variable &&
- (variable.eslintImplicitGlobalSetting === 'readonly' ||
- variable.eslintImplicitGlobalSetting === 'writable')
+ (
+ variable.eslintImplicitGlobalSetting === 'readonly' ||
+ variable.eslintImplicitGlobalSetting === 'writable'
+ )
) {
yield { type: 'builtin' };
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts
index 1d1f894..c2b892b 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts
@@ -198,9 +198,13 @@ export default util.createRule<Options, MessageIds>({
inner &&
outer[0] < inner[0] &&
inner[1] < outer[1] &&
- ((innerDef.type === 'FunctionName' &&
- innerDef.node.type === AST_NODE_TYPES.FunctionExpression) ||
- innerDef.node.type === AST_NODE_TYPES.ClassExpression) &&
+ (
+ (
+ innerDef.type === 'FunctionName' &&
+ innerDef.node.type === AST_NODE_TYPES.FunctionExpression
+ ) ||
+ innerDef.node.type === AST_NODE_TYPES.ClassExpression
+ ) &&
outerScope === innerScope.upper
);
}
@@ -236,9 +240,11 @@ export default util.createRule<Options, MessageIds>({
outer &&
inner[1] < outer[0] &&
// Excepts FunctionDeclaration if is {"hoist":"function"}.
- (options.hoist !== 'functions' ||
+ (
+ options.hoist !== 'functions' ||
!outerDef ||
- outerDef.node.type !== AST_NODE_TYPES.FunctionDeclaration)
+ outerDef.node.type !== AST_NODE_TYPES.FunctionDeclaration
+ )
);
}
@@ -323,8 +329,10 @@ export default util.createRule<Options, MessageIds>({
const isESLintGlobal = 'writeable' in shadowed;
if (
- (shadowed.identifiers.length > 0 ||
- (options.builtinGlobals && isESLintGlobal)) &&
+ (
+ shadowed.identifiers.length > 0 ||
+ (options.builtinGlobals && isESLintGlobal)
+ ) &&
!isOnInitializer(variable, shadowed) &&
!(options.hoist !== 'all' && isInTdz(variable, shadowed))
) {
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-type-alias.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-type-alias.ts
index c53b7d1..ec69054 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-type-alias.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-type-alias.ts
@@ -141,11 +141,19 @@ export default util.createRule<Options, MessageIds>({
): boolean {
return (
!compositions.includes(allowed) ||
- (!isTopLevel &&
- ((compositionType === AST_NODE_TYPES.TSUnionType &&
- unions.includes(allowed)) ||
- (compositionType === AST_NODE_TYPES.TSIntersectionType &&
- intersections.includes(allowed))))
+ (
+ !isTopLevel &&
+ (
+ (
+ compositionType === AST_NODE_TYPES.TSUnionType &&
+ unions.includes(allowed)
+ ) ||
+ (
+ compositionType === AST_NODE_TYPES.TSIntersectionType &&
+ intersections.includes(allowed)
+ )
+ )
+ )
);
}
@@ -263,10 +271,12 @@ export default util.createRule<Options, MessageIds>({
// eslint-disable-next-line @typescript-eslint/internal/prefer-ast-types-enum
type.node.type.endsWith('Keyword') ||
aliasTypes.has(type.node.type) ||
- (type.node.type === AST_NODE_TYPES.TSTypeOperator &&
+ (
+ type.node.type === AST_NODE_TYPES.TSTypeOperator &&
type.node.operator === 'readonly' &&
type.node.typeAnnotation &&
- aliasTypes.has(type.node.typeAnnotation.type))
+ aliasTypes.has(type.node.typeAnnotation.type)
+ )
) {
// alias / keyword
checkAndReport(allowAliases!, isTopLevel, type, 'Aliases');
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts
index fcf11f3..4cf2260 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts
@@ -187,11 +187,15 @@ export default createRule<Options, MessageId>({
node.type === AST_NODE_TYPES.MemberExpression &&
node.computed &&
// ...into an array type
- (nodeIsArrayType(node.object) ||
+ (
+ nodeIsArrayType(node.object) ||
// ... or a tuple type
- (nodeIsTupleType(node.object) &&
+ (
+ nodeIsTupleType(node.object) &&
// Exception: literal index into a tuple - will have a sound type
- node.property.type !== AST_NODE_TYPES.Literal))
+ node.property.type !== AST_NODE_TYPES.Literal
+ )
+ )
);
}
@@ -339,10 +343,14 @@ export default createRule<Options, MessageId>({
};
if (
- (leftType.flags === UNDEFINED &&
- !isComparable(rightType, UNDEFINED)) ||
- (rightType.flags === UNDEFINED &&
- !isComparable(leftType, UNDEFINED)) ||
+ (
+ leftType.flags === UNDEFINED &&
+ !isComparable(rightType, UNDEFINED)
+ ) ||
+ (
+ rightType.flags === UNDEFINED &&
+ !isComparable(leftType, UNDEFINED)
+ ) ||
(leftType.flags === NULL && !isComparable(rightType, NULL)) ||
(rightType.flags === NULL && !isComparable(leftType, NULL))
) {
@@ -420,8 +428,10 @@ export default createRule<Options, MessageId>({
const callback = node.arguments[0]!;
// Inline defined functions
if (
- (callback.type === AST_NODE_TYPES.ArrowFunctionExpression ||
- callback.type === AST_NODE_TYPES.FunctionExpression) &&
+ (
+ callback.type === AST_NODE_TYPES.ArrowFunctionExpression ||
+ callback.type === AST_NODE_TYPES.FunctionExpression
+ ) &&
callback.body
) {
// Two special cases, where we can directly check the node that's returned:
@@ -515,10 +525,14 @@ export default createRule<Options, MessageId>({
}
const typeName = getTypeName(checker, propertyType);
return !!(
- (typeName === 'string' &&
- checker.getIndexInfoOfType(objType, ts.IndexKind.String)) ||
- (typeName === 'number' &&
- checker.getIndexInfoOfType(objType, ts.IndexKind.Number))
+ (
+ typeName === 'string' &&
+ checker.getIndexInfoOfType(objType, ts.IndexKind.String)
+ ) ||
+ (
+ typeName === 'number' &&
+ checker.getIndexInfoOfType(objType, ts.IndexKind.Number)
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
index 014b2c2..0bdbd71 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
@@ -162,8 +162,10 @@ export default util.createRule({
): node is TSESTree.Identifier | TSESTree.MemberExpression {
return (
node.type === AST_NODE_TYPES.Identifier ||
- (isPropertyAccessExpression(node) &&
- isEntityNameExpression(node.object))
+ (
+ isPropertyAccessExpression(node) &&
+ isEntityNameExpression(node.object)
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
index 5ae12f5..e316b33 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
@@ -242,9 +242,13 @@ export default util.createRule<Options, MessageIds>({
if (
isTypeFlagSet(castType, ts.TypeFlags.Literal) ||
- (isObjectType(castType) &&
- (isObjectFlagSet(castType, ts.ObjectFlags.Tuple) ||
- couldBeTupleType(castType)))
+ (
+ isObjectType(castType) &&
+ (
+ isObjectFlagSet(castType, ts.ObjectFlags.Tuple) ||
+ couldBeTupleType(castType)
+ )
+ )
) {
// It's not always safe to remove a cast to a literal type or tuple
// type, as those types are sometimes widened without the cast.
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unused-expressions.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unused-expressions.ts
index 8116cbf..49463d8 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unused-expressions.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unused-expressions.ts
@@ -46,8 +46,10 @@ export default util.createRule<Options, MessageIds>({
);
}
return (
- (node.type === AST_NODE_TYPES.ChainExpression &&
- node.expression.type === AST_NODE_TYPES.CallExpression) ||
+ (
+ node.type === AST_NODE_TYPES.ChainExpression &&
+ node.expression.type === AST_NODE_TYPES.CallExpression
+ ) ||
node.type === AST_NODE_TYPES.ImportExpression
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-use-before-define.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-use-before-define.ts
index 5968086..c92259d 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-use-before-define.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-use-before-define.ts
@@ -193,8 +193,10 @@ function isInInitializer(
}
if (
node.parent?.parent &&
- (node.parent.parent.type === AST_NODE_TYPES.ForInStatement ||
- node.parent.parent.type === AST_NODE_TYPES.ForOfStatement) &&
+ (
+ node.parent.parent.type === AST_NODE_TYPES.ForInStatement ||
+ node.parent.parent.type === AST_NODE_TYPES.ForOfStatement
+ ) &&
isInRange(node.parent.parent.right, location)
) {
return true;
@@ -321,8 +323,10 @@ export default util.createRule<Options, MessageIds>({
reference.init ||
!variable ||
variable.identifiers.length === 0 ||
- (variable.identifiers[0].range[1] <= reference.identifier.range[1] &&
- !isInInitializer(variable, reference)) ||
+ (
+ variable.identifiers[0].range[1] <= reference.identifier.range[1] &&
+ !isInInitializer(variable, reference)
+ ) ||
!isForbidden(variable, reference) ||
isClassRefInClassDecorator(variable, reference) ||
reference.from.type === TSESLint.Scope.ScopeType.functionType
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-var-requires.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-var-requires.ts
index 26c49cc..e3343ae 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-var-requires.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-var-requires.ts
@@ -34,11 +34,13 @@ export default util.createRule<Options, MessageIds>({
node.callee.type === AST_NODE_TYPES.Identifier &&
node.callee.name === 'require' &&
parent &&
- (parent.type === AST_NODE_TYPES.VariableDeclarator ||
+ (
+ parent.type === AST_NODE_TYPES.VariableDeclarator ||
parent.type === AST_NODE_TYPES.CallExpression ||
parent.type === AST_NODE_TYPES.TSAsExpression ||
parent.type === AST_NODE_TYPES.TSTypeAssertion ||
- parent.type === AST_NODE_TYPES.MemberExpression)
+ parent.type === AST_NODE_TYPES.MemberExpression
+ )
) {
context.report({
node,
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/object-curly-spacing.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/object-curly-spacing.ts
index 74102af..d231caf 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/object-curly-spacing.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/object-curly-spacing.ts
@@ -197,23 +197,31 @@ export default createRule<Options, MessageIds>({
if (isTokenOnSameLine(penultimate, last)) {
const shouldCheckPenultimate =
- (options.arraysInObjectsException &&
- isClosingBracketToken(penultimate)) ||
- (options.objectsInObjectsException &&
- isClosingBraceToken(penultimate));
+ (
+ options.arraysInObjectsException &&
+ isClosingBracketToken(penultimate)
+ ) ||
+ (
+ options.objectsInObjectsException &&
+ isClosingBraceToken(penultimate)
+ );
const penultimateType = shouldCheckPenultimate
? sourceCode.getNodeByRangeIndex(penultimate.range[0])!.type
: undefined;
const closingCurlyBraceMustBeSpaced =
- (options.arraysInObjectsException &&
- penultimateType === AST_NODE_TYPES.TSTupleType) ||
- (options.objectsInObjectsException &&
+ (
+ options.arraysInObjectsException &&
+ penultimateType === AST_NODE_TYPES.TSTupleType
+ ) ||
+ (
+ options.objectsInObjectsException &&
penultimateType !== undefined &&
[
AST_NODE_TYPES.TSMappedType,
AST_NODE_TYPES.TSTypeLiteral,
- ].includes(penultimateType))
+ ].includes(penultimateType)
+ )
? !options.spaced
: options.spaced;
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-for-of.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-for-of.ts
index 361ad5e..570c8c0 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-for-of.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-for-of.ts
@@ -87,10 +87,16 @@ export default util.createRule({
return (
expr.type === AST_NODE_TYPES.BinaryExpression &&
expr.operator === '+' &&
- ((isMatchingIdentifier(expr.left, name) &&
- isLiteral(expr.right, 1)) ||
- (isLiteral(expr.left, 1) &&
- isMatchingIdentifier(expr.right, name)))
+ (
+ (
+ isMatchingIdentifier(expr.left, name) &&
+ isLiteral(expr.right, 1)
+ ) ||
+ (
+ isLiteral(expr.left, 1) &&
+ isMatchingIdentifier(expr.right, name)
+ )
+ )
);
}
}
@@ -170,11 +176,13 @@ export default util.createRule({
const node = id.parent;
return (
!contains(body, id) ||
- (node !== undefined &&
+ (
+ node !== undefined &&
node.type === AST_NODE_TYPES.MemberExpression &&
node.property === id &&
sourceCode.getText(node.object) === arrayText &&
- !isAssignee(node))
+ !isAssignee(node)
+ )
);
});
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-function-type.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-function-type.ts
index 761e8bc..4253182 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-function-type.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-function-type.ts
@@ -81,8 +81,10 @@ export default util.createRule({
tsThisTypes: TSESTree.TSThisType[] | null = null,
): void {
if (
- (member.type === AST_NODE_TYPES.TSCallSignatureDeclaration ||
- member.type === AST_NODE_TYPES.TSConstructSignatureDeclaration) &&
+ (
+ member.type === AST_NODE_TYPES.TSCallSignatureDeclaration ||
+ member.type === AST_NODE_TYPES.TSConstructSignatureDeclaration
+ ) &&
typeof member.returnType !== 'undefined'
) {
if (
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts
index fa6c1bb..65d6651 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts
@@ -130,11 +130,13 @@ function isConditionalTest(node: TSESTree.Node): boolean {
parents.add(current);
if (
- (current.type === AST_NODE_TYPES.ConditionalExpression ||
+ (
+ current.type === AST_NODE_TYPES.ConditionalExpression ||
current.type === AST_NODE_TYPES.DoWhileStatement ||
current.type === AST_NODE_TYPES.IfStatement ||
current.type === AST_NODE_TYPES.ForStatement ||
- current.type === AST_NODE_TYPES.WhileStatement) &&
+ current.type === AST_NODE_TYPES.WhileStatement
+ ) &&
parents.has(current.test)
) {
return true;
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-optional-chain.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-optional-chain.ts
index 0e15bf8..a5d8d2d 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-optional-chain.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-optional-chain.ts
@@ -365,8 +365,10 @@ function isValidChainTarget(
if (
allowIdentifier &&
- (node.type === AST_NODE_TYPES.Identifier ||
- node.type === AST_NODE_TYPES.ThisExpression)
+ (
+ node.type === AST_NODE_TYPES.Identifier ||
+ node.type === AST_NODE_TYPES.ThisExpression
+ )
) {
return true;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts
index 56ab826..d6e9b48 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts
@@ -118,8 +118,10 @@ export default util.createRule<Options, MessageIds>({
ts.isObjectLiteralExpression(parent) ||
ts.isArrayLiteralExpression(parent) ||
ts.isSpreadAssignment(parent) ||
- (ts.isSpreadElement(parent) &&
- ts.isArrayLiteralExpression(parent.parent))
+ (
+ ts.isSpreadElement(parent) &&
+ ts.isArrayLiteralExpression(parent.parent)
+ )
) {
current = parent;
} else if (ts.isBinaryExpression(parent)) {
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
index f4697b7..9323044 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
@@ -177,11 +177,15 @@ export default createRule({
expectedIndexedNode: TSESTree.Node,
): boolean {
return (
- (node.type === AST_NODE_TYPES.UnaryExpression &&
- node.operator === '-') ||
- (node.type === AST_NODE_TYPES.BinaryExpression &&
+ (
+ node.type === AST_NODE_TYPES.UnaryExpression &&
+ node.operator === '-'
+ ) ||
+ (
+ node.type === AST_NODE_TYPES.BinaryExpression &&
node.operator === '-' &&
- isLengthExpression(node.left, expectedIndexedNode))
+ isLengthExpression(node.left, expectedIndexedNode)
+ )
);
}
@@ -568,9 +572,13 @@ export default createRule({
}
const isEndsWith =
- (callNode.arguments.length === 1 ||
- (callNode.arguments.length === 2 &&
- isLengthExpression(callNode.arguments[1], node.object))) &&
+ (
+ callNode.arguments.length === 1 ||
+ (
+ callNode.arguments.length === 2 &&
+ isLengthExpression(callNode.arguments[1], node.object)
+ )
+ ) &&
isNegativeIndexExpression(callNode.arguments[0], node.object);
const isStartsWith =
!isEndsWith &&
@@ -591,8 +599,10 @@ export default createRule({
// Don't fix if it can change the behavior.
if (
eqNode.operator.length === 2 &&
- (eqNode.right.type !== AST_NODE_TYPES.Literal ||
- typeof eqNode.right.value !== 'string')
+ (
+ eqNode.right.type !== AST_NODE_TYPES.Literal ||
+ typeof eqNode.right.value !== 'string'
+ )
) {
return null;
}
@@ -606,14 +616,18 @@ export default createRule({
} else {
const posNode = callNode.arguments[0];
const posNodeIsAbsolutelyValid =
- (posNode.type === AST_NODE_TYPES.BinaryExpression &&
+ (
+ posNode.type === AST_NODE_TYPES.BinaryExpression &&
posNode.operator === '-' &&
isLengthExpression(posNode.left, node.object) &&
- isLengthExpression(posNode.right, eqNode.right)) ||
- (negativeIndexSupported &&
+ isLengthExpression(posNode.right, eqNode.right)
+ ) ||
+ (
+ negativeIndexSupported &&
posNode.type === AST_NODE_TYPES.UnaryExpression &&
posNode.operator === '-' &&
- isLengthExpression(posNode.argument, eqNode.right));
+ isLengthExpression(posNode.argument, eqNode.right)
+ );
if (!posNodeIsAbsolutelyValid) {
return null;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/promise-function-async.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/promise-function-async.ts
index 68b1d42..0697afc 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/promise-function-async.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/promise-function-async.ts
@@ -127,8 +127,10 @@ export default util.createRule<Options, MessageIds>({
if (
node.parent &&
- (node.parent.type === AST_NODE_TYPES.Property ||
- node.parent.type === AST_NODE_TYPES.MethodDefinition) &&
+ (
+ node.parent.type === AST_NODE_TYPES.Property ||
+ node.parent.type === AST_NODE_TYPES.MethodDefinition
+ ) &&
(node.parent.kind === 'get' || node.parent.kind === 'set')
) {
// Getters and setters can't be async
@@ -153,9 +155,13 @@ export default util.createRule<Options, MessageIds>({
fix: fixer => {
if (
node.parent &&
- (node.parent.type === AST_NODE_TYPES.MethodDefinition ||
- (node.parent.type === AST_NODE_TYPES.Property &&
- node.parent.method))
+ (
+ node.parent.type === AST_NODE_TYPES.MethodDefinition ||
+ (
+ node.parent.type === AST_NODE_TYPES.Property &&
+ node.parent.method
+ )
+ )
) {
// this function is a class method or object function property shorthand
const method = node.parent;
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/space-before-function-paren.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/space-before-function-paren.ts
index e2ccfa5..da29586 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/space-before-function-paren.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/space-before-function-paren.ts
@@ -88,8 +88,10 @@ export default util.createRule<Options, MessageIds>({
return (
parent.type === AST_NODE_TYPES.MethodDefinition ||
parent.type === AST_NODE_TYPES.TSAbstractMethodDefinition ||
- (parent.type === AST_NODE_TYPES.Property &&
- (parent.kind === 'get' || parent.kind === 'set' || parent.method))
+ (
+ parent.type === AST_NODE_TYPES.Property &&
+ (parent.kind === 'get' || parent.kind === 'set' || parent.method)
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/space-infix-ops.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/space-infix-ops.ts
index 57c56ad..f80f46c 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/space-infix-ops.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/space-infix-ops.ts
@@ -63,8 +63,10 @@ export default util.createRule<Options, MessageIds>({
if (
operator &&
- (!sourceCode.isSpaceBetweenTokens(prev!, operator) ||
- !sourceCode.isSpaceBetweenTokens(operator, next!))
+ (
+ !sourceCode.isSpaceBetweenTokens(prev!, operator) ||
+ !sourceCode.isSpaceBetweenTokens(operator, next!)
+ )
) {
context.report({
node: node,
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts
index 7664010..46d4b7a 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts
@@ -134,8 +134,10 @@ export default util.createRule<[Options], MessageIds>({
function isVariableDeclarationIgnoreFunction(node: TSESTree.Node): boolean {
return (
!!options[OptionKeys.VariableDeclarationIgnoreFunction] &&
- (node.type === AST_NODE_TYPES.FunctionExpression ||
- node.type === AST_NODE_TYPES.ArrowFunctionExpression)
+ (
+ node.type === AST_NODE_TYPES.FunctionExpression ||
+ node.type === AST_NODE_TYPES.ArrowFunctionExpression
+ )
);
}
@@ -209,10 +211,14 @@ export default util.createRule<[Options], MessageIds>({
if (
!options[OptionKeys.VariableDeclaration] ||
node.id.typeAnnotation ||
- (node.id.type === AST_NODE_TYPES.ArrayPattern &&
- !options[OptionKeys.ArrayDestructuring]) ||
- (node.id.type === AST_NODE_TYPES.ObjectPattern &&
- !options[OptionKeys.ObjectDestructuring]) ||
+ (
+ node.id.type === AST_NODE_TYPES.ArrayPattern &&
+ !options[OptionKeys.ArrayDestructuring]
+ ) ||
+ (
+ node.id.type === AST_NODE_TYPES.ObjectPattern &&
+ !options[OptionKeys.ObjectDestructuring]
+ ) ||
(node.init && isVariableDeclarationIgnoreFunction(node.init))
) {
return;
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts
index ecf9e65..777cb66 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts
@@ -332,11 +332,15 @@ function isSafeUse(node: TSESTree.Node): boolean {
case AST_NODE_TYPES.AssignmentExpression:
return (
parent.operator === '=' &&
- (node === parent.left ||
- (node.type === AST_NODE_TYPES.MemberExpression &&
+ (
+ node === parent.left ||
+ (
+ node.type === AST_NODE_TYPES.MemberExpression &&
node.object.type === AST_NODE_TYPES.Super &&
parent.left.type === AST_NODE_TYPES.MemberExpression &&
- parent.left.object.type === AST_NODE_TYPES.ThisExpression))
+ parent.left.object.type === AST_NODE_TYPES.ThisExpression
+ )
+ )
);
case AST_NODE_TYPES.ChainExpression:
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts
index e904904..1903391 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts
@@ -421,10 +421,12 @@ export default util.createRule({
): boolean {
return (
a === b ||
- (a !== undefined &&
+ (
+ a !== undefined &&
b !== undefined &&
sourceCode.getText(a.typeAnnotation) ===
- sourceCode.getText(b.typeAnnotation))
+ sourceCode.getText(b.typeAnnotation)
+ )
);
}
@@ -565,8 +567,10 @@ function getExportingNode(
| TSESTree.ExportDefaultDeclaration
| undefined {
return node.parent &&
- (node.parent.type === AST_NODE_TYPES.ExportNamedDeclaration ||
- node.parent.type === AST_NODE_TYPES.ExportDefaultDeclaration)
+ (
+ node.parent.type === AST_NODE_TYPES.ExportNamedDeclaration ||
+ node.parent.type === AST_NODE_TYPES.ExportDefaultDeclaration
+ )
? node.parent
: undefined;
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts ALT/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts
index b36d07e..5981276 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts
@@ -405,8 +405,10 @@ function isMergableExported(variable: TSESLint.Scope.Variable): boolean {
}
if (
- (MERGABLE_TYPES.has(def.node.type) &&
- def.node.parent?.type === AST_NODE_TYPES.ExportNamedDeclaration) ||
+ (
+ MERGABLE_TYPES.has(def.node.type) &&
+ def.node.parent?.type === AST_NODE_TYPES.ExportNamedDeclaration
+ ) ||
def.node.parent?.type === AST_NODE_TYPES.ExportDefaultDeclaration
) {
return true;
@@ -463,8 +465,10 @@ function isUsedVariable(variable: TSESLint.Scope.Variable): boolean {
// FunctionExpressions
if (
def.type === TSESLint.Scope.DefinitionType.Variable &&
- (def.node.init?.type === AST_NODE_TYPES.FunctionExpression ||
- def.node.init?.type === AST_NODE_TYPES.ArrowFunctionExpression)
+ (
+ def.node.init?.type === AST_NODE_TYPES.FunctionExpression ||
+ def.node.init?.type === AST_NODE_TYPES.ArrowFunctionExpression
+ )
) {
functionDefinitions.add(def.node.init);
}
@@ -699,14 +703,22 @@ function isUsedVariable(variable: TSESLint.Scope.Variable): boolean {
return (
ref.isRead() && // in RHS of an assignment for itself. e.g. `a = a + 1`
// self update. e.g. `a += 1`, `a++`
- ((parent.type === AST_NODE_TYPES.AssignmentExpression &&
- grandparent.type === AST_NODE_TYPES.ExpressionStatement &&
- parent.left === id) ||
- (parent.type === AST_NODE_TYPES.UpdateExpression &&
- grandparent.type === AST_NODE_TYPES.ExpressionStatement) ||
- (!!rhsNode &&
+ (
+ (
+ parent.type === AST_NODE_TYPES.AssignmentExpression &&
+ grandparent.type === AST_NODE_TYPES.ExpressionStatement &&
+ parent.left === id
+ ) ||
+ (
+ parent.type === AST_NODE_TYPES.UpdateExpression &&
+ grandparent.type === AST_NODE_TYPES.ExpressionStatement
+ ) ||
+ (
+ !!rhsNode &&
isInside(id, rhsNode) &&
- !isInsideOfStorableFunction(id, rhsNode)))
+ !isInsideOfStorableFunction(id, rhsNode)
+ )
+ )
);
}
diff --git ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts
index e7e0991..34561e2 100644
--- ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts
+++ ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts
@@ -32,10 +32,12 @@ function arraysAreEqual<T>(
): boolean {
return (
a === b ||
- (a !== undefined &&
+ (
+ a !== undefined &&
b !== undefined &&
a.length === b.length &&
- a.every((x, idx) => eq(x, b[idx])))
+ a.every((x, idx) => eq(x, b[idx]))
+ )
);
}
diff --git ORI/typescript-eslint/packages/experimental-utils/src/ast-utils/predicates.ts ALT/typescript-eslint/packages/experimental-utils/src/ast-utils/predicates.ts
index bf62a6f..60324bd 100644
--- ORI/typescript-eslint/packages/experimental-utils/src/ast-utils/predicates.ts
+++ ALT/typescript-eslint/packages/experimental-utils/src/ast-utils/predicates.ts
@@ -184,8 +184,10 @@ function isSetter(
): node is TSESTree.MethodDefinition | TSESTree.Property {
return (
!!node &&
- (node.type === AST_NODE_TYPES.MethodDefinition ||
- node.type === AST_NODE_TYPES.Property) &&
+ (
+ node.type === AST_NODE_TYPES.MethodDefinition ||
+ node.type === AST_NODE_TYPES.Property
+ ) &&
node.kind === 'set'
);
}
diff --git ORI/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts ALT/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts
index fff5758..2602dab 100644
--- ORI/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts
+++ ALT/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts
@@ -144,8 +144,10 @@ class ClassVisitor extends Visitor {
*/
withMethodDecorators =
withMethodDecorators ||
- (methodNode.kind !== 'set' &&
- node.params.some(param => param.decorators));
+ (
+ methodNode.kind !== 'set' &&
+ node.params.some(param => param.decorators)
+ );
if (!withMethodDecorators && methodNode.kind === 'set') {
const keyName = getLiteralMethodKeyName(methodNode);
diff --git ORI/typescript-eslint/packages/typescript-estree/src/convert.ts ALT/typescript-eslint/packages/typescript-estree/src/convert.ts
index 456564d..844a8cb 100644
--- ORI/typescript-eslint/packages/typescript-estree/src/convert.ts
+++ ALT/typescript-eslint/packages/typescript-estree/src/convert.ts
@@ -1052,8 +1052,10 @@ export class Converter {
}
if (
- (node.name.kind === SyntaxKind.Identifier ||
- node.name.kind === SyntaxKind.ComputedPropertyName) &&
+ (
+ node.name.kind === SyntaxKind.Identifier ||
+ node.name.kind === SyntaxKind.ComputedPropertyName
+ ) &&
node.questionToken
) {
result.optional = true;
diff --git ORI/typescript-eslint/packages/typescript-estree/src/node-utils.ts ALT/typescript-eslint/packages/typescript-estree/src/node-utils.ts
index eb88660..92bd0bc 100644
--- ORI/typescript-eslint/packages/typescript-estree/src/node-utils.ts
+++ ALT/typescript-eslint/packages/typescript-estree/src/node-utils.ts
@@ -153,9 +153,11 @@ export function hasModifier(
*/
export function getLastModifier(node: ts.Node): ts.Modifier | null {
return (
- (!!node.modifiers &&
+ (
+ !!node.modifiers &&
!!node.modifiers.length &&
- node.modifiers[node.modifiers.length - 1]) ||
+ node.modifiers[node.modifiers.length - 1]
+ ) ||
null
);
}
@@ -542,8 +544,10 @@ export function getTokenType(
// must actually be an ESTree-JSXText token
if (
token.parent &&
- (token.parent.kind === SyntaxKind.JsxAttribute ||
- token.parent.kind === SyntaxKind.JsxElement)
+ (
+ token.parent.kind === SyntaxKind.JsxAttribute ||
+ token.parent.kind === SyntaxKind.JsxElement
+ )
) {
return AST_TOKEN_TYPES.JSXText;
}
diff --git ORI/typescript-eslint/packages/typescript-estree/src/parser.ts ALT/typescript-eslint/packages/typescript-estree/src/parser.ts
index 300a73c..de85162 100644
--- ORI/typescript-eslint/packages/typescript-estree/src/parser.ts
+++ ALT/typescript-eslint/packages/typescript-estree/src/parser.ts
@@ -65,11 +65,15 @@ function getProgramAndAST(
shouldCreateDefaultProgram: boolean,
): ASTAndProgram {
return (
- (shouldProvideParserServices &&
- createProjectProgram(code, shouldCreateDefaultProgram, extra)) ||
- (shouldProvideParserServices &&
+ (
+ shouldProvideParserServices &&
+ createProjectProgram(code, shouldCreateDefaultProgram, extra)
+ ) ||
+ (
+ shouldProvideParserServices &&
shouldCreateDefaultProgram &&
- createDefaultProgram(code, extra)) ||
+ createDefaultProgram(code, extra)
+ ) ||
createIsolatedProgram(code, extra)
);
}
prettier/prettier#11103 VS prettier/prettier@main :: vega/vega-lite@2dff36f
diff --git ORI/vega-lite/src/normalize/toplevelselection.ts ALT/vega-lite/src/normalize/toplevelselection.ts
index 599e301..28a6de9 100644
--- ORI/vega-lite/src/normalize/toplevelselection.ts
+++ ALT/vega-lite/src/normalize/toplevelselection.ts
@@ -50,8 +50,10 @@ export class TopLevelSelectionsNormalizer extends SpecMapper<NormalizerParams, N
// view is either a specific unit name, or a partial path through the spec tree.
if (
(isString(view) && (view === spec.name || path.indexOf(view) >= 0)) ||
- (isArray(view) &&
- view.map(v => path.indexOf(v)).every((v, i, arr) => v !== -1 && (i === 0 || v > arr[i - 1])))
+ (
+ isArray(view) &&
+ view.map(v => path.indexOf(v)).every((v, i, arr) => v !== -1 && (i === 0 || v > arr[i - 1]))
+ )
) {
params.push(selection);
}
I was going to run a test on this PR, you already did.
I think the new format is good, WDYT?
It looks good to me. But it'll be big change for users. I want to listen to the opinions of other maintainers and decide carefully.