prettier / prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
11 stars 9 forks source link

for 11103 (Break multiline parenthesized logical expression) #282

Open fisker opened 2 years ago

fisker commented 2 years ago

run #11103 vs prettier/prettier#main

github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: babel/babel@4e0e5f9ad6ca1c8b305dd2bc3aba9a28f1239837

Diff (216 lines) ```diff diff --git ORI/babel/packages/babel-helpers/src/helpers/jsx.js ALT/babel/packages/babel-helpers/src/helpers/jsx.js index e6f7de73..57c90453 100644 --- ORI/babel/packages/babel-helpers/src/helpers/jsx.js +++ ALT/babel/packages/babel-helpers/src/helpers/jsx.js @@ -5,10 +5,12 @@ var REACT_ELEMENT_TYPE; export default function _createRawReactElement(type, props, key, children) { if (!REACT_ELEMENT_TYPE) { REACT_ELEMENT_TYPE = - (typeof Symbol === "function" && + ( + typeof Symbol === "function" && // "for" is a reserved keyword in ES3 so escaping it here for backward compatibility Symbol["for"] && - Symbol["for"]("react.element")) || + Symbol["for"]("react.element") + ) || 0xeac7; } diff --git ORI/babel/packages/babel-parser/src/parser/expression.js ALT/babel/packages/babel-parser/src/parser/expression.js index bb37f6a8..650037e3 100644 --- ORI/babel/packages/babel-parser/src/parser/expression.js +++ ALT/babel/packages/babel-parser/src/parser/expression.js @@ -1999,9 +1999,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) + ) ); } diff --git ORI/babel/packages/babel-parser/src/parser/statement.js ALT/babel/packages/babel-parser/src/parser/statement.js index 0f7cbec4..a4419925 100644 --- ORI/babel/packages/babel-parser/src/parser/statement.js +++ ALT/babel/packages/babel-parser/src/parser/statement.js @@ -431,10 +431,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; @@ -1156,10 +1160,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( Errors.ForInOfLoopInitializer, @@ -1390,8 +1396,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 ); } diff --git ORI/babel/packages/babel-parser/src/parser/util.js ALT/babel/packages/babel-parser/src/parser/util.js index f9bad51b..396fbb1a 100644 --- ORI/babel/packages/babel-parser/src/parser/util.js +++ ALT/babel/packages/babel-parser/src/parser/util.js @@ -357,8 +357,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 da51b813..ee4a4d77 100644 --- ORI/babel/packages/babel-parser/src/plugins/flow/index.js +++ ALT/babel/packages/babel-parser/src/plugins/flow/index.js @@ -153,10 +153,16 @@ const FlowErrors = makeErrorTemplates( 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" + ) + ) + ) ); } @@ -497,8 +503,10 @@ export default (superClass: Class): Class => if ( this.match(tt._const) || this.isLet() || - ((this.isContextual(tt._type) || this.isContextual(tt._interface)) && - !insideModule) + ( + (this.isContextual(tt._type) || this.isContextual(tt._interface)) && + !insideModule + ) ) { const label = this.state.value; const suggestion = exportSuggestions[label]; @@ -2094,10 +2102,14 @@ export default (superClass: Class): Class => 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 fae6d2fb..a72dd5c3 100644 --- ORI/babel/packages/babel-parser/src/plugins/typescript/index.js +++ ALT/babel/packages/babel-parser/src/plugins/typescript/index.js @@ -230,12 +230,14 @@ export default (superClass: Class): Class => tsTokenCanFollowModifier() { return ( - (this.match(tt.bracketL) || + ( + this.match(tt.bracketL) || this.match(tt.braceL) || this.match(tt.star) || this.match(tt.ellipsis) || this.match(tt.privateName) || - this.isLiteralPropertyName()) && + this.isLiteralPropertyName() + ) && !this.hasPrecedingLineBreak() ); } @@ -2700,9 +2702,11 @@ export default (superClass: Class): Class => } if ( declaration && - (declaration.type === "TSInterfaceDeclaration" || + ( + declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || - isDeclare) + isDeclare + ) ) { node.exportKind = "type"; } diff --git ORI/babel/packages/babel-parser/src/util/scope.js ALT/babel/packages/babel-parser/src/util/scope.js index 573fb502..afeb3bce 100644 --- ORI/babel/packages/babel-parser/src/util/scope.js +++ ALT/babel/packages/babel-parser/src/util/scope.js @@ -176,11 +176,13 @@ export default class ScopeHandler { } return ( - (scope.lexical.has(name) && + ( + scope.lexical.has(name) && !( scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical.values().next().value === name - )) || + ) + ) || (!this.treatFunctionsAsVarInScope(scope) && scope.functions.has(name)) ); } ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: vuejs/eslint-plugin-vue@508ea0e14ef2c882623f812b7a0237369b532a66

Diff (898 lines) ```diff diff --git ORI/eslint-plugin-vue/lib/rules/attributes-order.js ALT/eslint-plugin-vue/lib/rules/attributes-order.js index 0d9ea9c..f02cef9 100644 --- ORI/eslint-plugin-vue/lib/rules/attributes-order.js +++ ALT/eslint-plugin-vue/lib/rules/attributes-order.js @@ -306,8 +306,10 @@ function create(context) { const attributes = node.attributes.filter((node, index, attributes) => { if ( isVBindObject(node) && - (isVAttributeOrVBindOrVModel(attributes[index - 1]) || - isVAttributeOrVBindOrVModel(attributes[index + 1])) + ( + isVAttributeOrVBindOrVModel(attributes[index - 1]) || + isVAttributeOrVBindOrVModel(attributes[index + 1]) + ) ) { // In Vue 3, ignore `v-bind="object"`, which is // a pair of `v-bind:foo="..."` and `v-bind="object"` and 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 a5cf396..8f4655b 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 a762d3f..540be1e 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 @@ -29,11 +29,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 ) } @@ -48,11 +52,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 @@ -68,9 +76,11 @@ function isNextTick(node, context) { const name = utils.getStaticPropertyName(callee) return ( (utils.isThis(callee.object, context) && name === '$nextTick') || - (callee.object.type === 'Identifier' && + ( + callee.object.type === 'Identifier' && callee.object.name === 'Vue' && - name === 'nextTick') + name === 'nextTick' + ) ) } return false diff --git ORI/eslint-plugin-vue/lib/rules/no-computed-properties-in-data.js ALT/eslint-plugin-vue/lib/rules/no-computed-properties-in-data.js index 3e1490d..c23153a 100644 --- ORI/eslint-plugin-vue/lib/rules/no-computed-properties-in-data.js +++ ALT/eslint-plugin-vue/lib/rules/no-computed-properties-in-data.js @@ -66,8 +66,10 @@ module.exports = { const dataProperty = utils.findProperty(node, 'data') if ( !dataProperty || - (dataProperty.value.type !== 'FunctionExpression' && - dataProperty.value.type !== 'ArrowFunctionExpression') + ( + dataProperty.value.type !== 'FunctionExpression' && + dataProperty.value.type !== 'ArrowFunctionExpression' + ) ) { return } 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-mutating-props.js ALT/eslint-plugin-vue/lib/rules/no-mutating-props.js index b7ffcd6..3da4065 100644 --- ORI/eslint-plugin-vue/lib/rules/no-mutating-props.js +++ ALT/eslint-plugin-vue/lib/rules/no-mutating-props.js @@ -305,9 +305,13 @@ module.exports = { }, onVueObjectExit(node, { type }) { if ( - (!vueObjectData || - (vueObjectData.type !== 'export' && - vueObjectData.type !== 'setup')) && + ( + !vueObjectData || + ( + vueObjectData.type !== 'export' && + vueObjectData.type !== 'setup' + ) + ) && type !== 'instance' ) { vueObjectData = { 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 e32e182..d5a86cc 100644 --- ORI/eslint-plugin-vue/lib/rules/no-reserved-component-names.js +++ ALT/eslint-plugin-vue/lib/rules/no-reserved-component-names.js @@ -104,9 +104,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-side-effects-in-computed-properties.js ALT/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js index 6e43266..4e55d36 100644 --- ORI/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js @@ -94,8 +94,10 @@ module.exports = { const isVueSet = mem.parent.type === 'CallExpression' && mem.property.type === 'Identifier' && - ((isThis && mem.property.name === '$set') || - (isVue && mem.property.name === 'set')) + ( + (isThis && mem.property.name === '$set') || + (isVue && mem.property.name === 'set') + ) const invalid = isVueSet ? { node: mem.property } diff --git ORI/eslint-plugin-vue/lib/rules/no-undef-properties.js ALT/eslint-plugin-vue/lib/rules/no-undef-properties.js index 4246f77..ad37922 100644 --- ORI/eslint-plugin-vue/lib/rules/no-undef-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-undef-properties.js @@ -344,8 +344,10 @@ module.exports = { ]) )) { const propertyMap = - (prop.groupName === GROUP_DATA || - prop.groupName === GROUP_ASYNC_DATA) && + ( + prop.groupName === GROUP_DATA || + prop.groupName === GROUP_ASYNC_DATA + ) && prop.type === 'object' && prop.property.value.type === 'ObjectExpression' ? getObjectPropertyMap(prop.property.value) diff --git ORI/eslint-plugin-vue/lib/rules/no-unused-components.js ALT/eslint-plugin-vue/lib/rules/no-unused-components.js index 8497dd9..5ff18cd 100644 --- ORI/eslint-plugin-vue/lib/rules/no-unused-components.js +++ ALT/eslint-plugin-vue/lib/rules/no-unused-components.js @@ -116,8 +116,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/no-unused-properties.js ALT/eslint-plugin-vue/lib/rules/no-unused-properties.js index 1414df3..82395a5 100644 --- ORI/eslint-plugin-vue/lib/rules/no-unused-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-unused-properties.js @@ -353,8 +353,10 @@ module.exports = { // used if ( deepData && - (property.groupName === 'data' || - property.groupName === 'asyncData') && + ( + property.groupName === 'data' || + property.groupName === 'asyncData' + ) && property.type === 'object' ) { // Check the deep properties of the data option. diff --git ORI/eslint-plugin-vue/lib/rules/order-in-components.js ALT/eslint-plugin-vue/lib/rules/order-in-components.js index 83558aa..06e1527 100644 --- ORI/eslint-plugin-vue/lib/rules/order-in-components.js +++ ALT/eslint-plugin-vue/lib/rules/order-in-components.js @@ -176,12 +176,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/prefer-separate-static-class.js ALT/eslint-plugin-vue/lib/rules/prefer-separate-static-class.js index 0ebeb24..b356695 100644 --- ORI/eslint-plugin-vue/lib/rules/prefer-separate-static-class.js +++ ALT/eslint-plugin-vue/lib/rules/prefer-separate-static-class.js @@ -38,8 +38,10 @@ function findStaticClasses(expressionNode) { property.type === 'Property' && property.value.type === 'Literal' && property.value.value === true && - (isStringLiteral(property.key) || - (property.key.type === 'Identifier' && !property.computed)) + ( + isStringLiteral(property.key) || + (property.key.type === 'Identifier' && !property.computed) + ) ) { return [property.key] } @@ -81,8 +83,10 @@ function* removeNodeWithComma(fixer, tokenStore, node) { if ( nextToken.type === 'Punctuator' && nextToken.value === ',' && - (nextNextToken.type !== 'Punctuator' || - (nextNextToken.value !== ']' && nextNextToken.value !== '}')) + ( + nextNextToken.type !== 'Punctuator' || + (nextNextToken.value !== ']' && nextNextToken.value !== '}') + ) ) { yield fixer.removeRange([node.range[0], nextNextToken.range[0]]) return diff --git ORI/eslint-plugin-vue/lib/rules/require-default-prop.js ALT/eslint-plugin-vue/lib/rules/require-default-prop.js index 7cfdc7e..7e046e5 100644 --- ORI/eslint-plugin-vue/lib/rules/require-default-prop.js +++ ALT/eslint-plugin-vue/lib/rules/require-default-prop.js @@ -132,14 +132,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/require-emit-validator.js ALT/eslint-plugin-vue/lib/rules/require-emit-validator.js index 24c6a9c..5b18d0d 100644 --- ORI/eslint-plugin-vue/lib/rules/require-emit-validator.js +++ ALT/eslint-plugin-vue/lib/rules/require-emit-validator.js @@ -48,10 +48,12 @@ module.exports = { const { value, node, emitName } = emit const hasType = !!value && - (value.type === 'ArrowFunctionExpression' || + ( + value.type === 'ArrowFunctionExpression' || value.type === 'FunctionExpression' || // validator may from outer scope - value.type === 'Identifier') + value.type === 'Identifier' + ) if (!hasType) { const name = diff --git ORI/eslint-plugin-vue/lib/rules/require-explicit-emits.js ALT/eslint-plugin-vue/lib/rules/require-explicit-emits.js index aa83b88..67adc0f 100644 --- ORI/eslint-plugin-vue/lib/rules/require-explicit-emits.js +++ ALT/eslint-plugin-vue/lib/rules/require-explicit-emits.js @@ -384,8 +384,10 @@ module.exports = { const emits = vueEmitsDeclarations.get(node) if ( !vueTemplateDefineData || - (vueTemplateDefineData.type !== 'export' && - vueTemplateDefineData.type !== 'setup') + ( + vueTemplateDefineData.type !== 'export' && + vueTemplateDefineData.type !== 'setup' + ) ) { if ( emits && diff --git ORI/eslint-plugin-vue/lib/rules/require-valid-default-prop.js ALT/eslint-plugin-vue/lib/rules/require-valid-default-prop.js index 21191e8..3471643 100644 --- ORI/eslint-plugin-vue/lib/rules/require-valid-default-prop.js +++ ALT/eslint-plugin-vue/lib/rules/require-valid-default-prop.js @@ -404,8 +404,10 @@ module.exports = { (prop) => Boolean( prop.type === 'type' || - (prop.type === 'object' && - prop.value.type === 'ObjectExpression') + ( + prop.type === 'object' && + prop.value.type === 'ObjectExpression' + ) ) ) const defaults = utils.getWithDefaultsPropExpressions(node) diff --git ORI/eslint-plugin-vue/lib/rules/script-setup-uses-vars.js ALT/eslint-plugin-vue/lib/rules/script-setup-uses-vars.js index 0e0f958..03e8879 100644 --- ORI/eslint-plugin-vue/lib/rules/script-setup-uses-vars.js +++ ALT/eslint-plugin-vue/lib/rules/script-setup-uses-vars.js @@ -94,9 +94,13 @@ module.exports = { VElement(node) { if ( (!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) || - (node.rawName === node.name && - (utils.isHtmlWellKnownElementName(node.rawName) || - utils.isSvgWellKnownElementName(node.rawName))) || + ( + node.rawName === node.name && + ( + utils.isHtmlWellKnownElementName(node.rawName) || + utils.isSvgWellKnownElementName(node.rawName) + ) + ) || utils.isBuiltInComponentName(node.rawName) ) { return diff --git ORI/eslint-plugin-vue/lib/rules/sort-keys.js ALT/eslint-plugin-vue/lib/rules/sort-keys.js index e84774d..7c970dd 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 4cfe209..f730810 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js @@ -71,8 +71,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 eb8b63b..b872810 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 df0fa7c..6dbc5cf 100644 --- ORI/eslint-plugin-vue/lib/rules/valid-v-slot.js +++ ALT/eslint-plugin-vue/lib/rules/valid-v-slot.js @@ -291,8 +291,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 = @@ -390,9 +392,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 020b637..612263b 100644 --- ORI/eslint-plugin-vue/lib/utils/indent-common.js +++ ALT/eslint-plugin-vue/lib/utils/indent-common.js @@ -176,10 +176,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 === ']') + ) + ) ) } @@ -305,11 +309,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' + ) } const contentTokens = endToken ? tokenStore.getTokensBetween(node.startTag, endToken, cursorOptions) @@ -772,8 +778,10 @@ module.exports.defineVisitor = function create( if ( actualIndent !== expectedIndent && - (optionalExpectedIndents == null || - !optionalExpectedIndents.includes(actualIndent)) + ( + optionalExpectedIndents == null || + !optionalExpectedIndents.includes(actualIndent) + ) ) { context.report({ loc: { @@ -1165,11 +1173,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) @@ -1413,9 +1427,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/indent-ts.js ALT/eslint-plugin-vue/lib/utils/indent-ts.js index 496e892..c4135b3 100644 --- ORI/eslint-plugin-vue/lib/utils/indent-ts.js +++ ALT/eslint-plugin-vue/lib/utils/indent-ts.js @@ -1290,8 +1290,10 @@ function defineVisitor({ } else { const startParentToken = tokenStore.getFirstToken( parent.parent && - (parent.parent.type === 'ExportDefaultDeclaration' || - parent.parent.type === 'ExportNamedDeclaration') && + ( + parent.parent.type === 'ExportDefaultDeclaration' || + parent.parent.type === 'ExportNamedDeclaration' + ) && node.range[0] < parent.parent.range[0] ? parent.parent : parent diff --git ORI/eslint-plugin-vue/lib/utils/indent-utils.js ALT/eslint-plugin-vue/lib/utils/indent-utils.js index 5e40ba9..c3b62b8 100644 --- ORI/eslint-plugin-vue/lib/utils/indent-utils.js +++ ALT/eslint-plugin-vue/lib/utils/indent-utils.js @@ -48,12 +48,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') + ) + ) ) } diff --git ORI/eslint-plugin-vue/lib/utils/index.js ALT/eslint-plugin-vue/lib/utils/index.js index 69cd84a..ca50681 100644 --- ORI/eslint-plugin-vue/lib/utils/index.js +++ ALT/eslint-plugin-vue/lib/utils/index.js @@ -776,10 +776,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) + ) || hasAttribute(node, 'is') || hasDirective(node, 'bind', 'is') || hasDirective(node, 'is') @@ -1234,8 +1238,10 @@ module.exports = { ) { if ( hasPropsEvent && - (candidateMacro === node || - candidateMacro === getWithDefaults(node)) && + ( + candidateMacro === node || + candidateMacro === getWithDefaults(node) + ) && node.callee.name === 'defineProps' ) { /** @type {ComponentProp[]} */ @@ -2448,9 +2454,11 @@ function getVueComponentDefinitionType(node) { propName && isObjectArgument(parent) return maybeFullVueComponentForVue2 && - (propName === 'component' || + ( + propName === 'component' || propName === 'mixin' || - propName === 'extend') + propName === 'extend' + ) ? propName : null } @@ -2618,11 +2626,13 @@ function isSFCObject(context, node) { const { callee } = parent if ( (callee.type === 'Identifier' && callee.name === 'defineComponent') || - (callee.type === 'MemberExpression' && + ( + callee.type === 'MemberExpression' && callee.object.type === 'Identifier' && callee.object.name === 'Vue' && callee.property.type === 'Identifier' && - callee.property.name === 'extend') + callee.property.name === 'extend' + ) ) { return isSFC(parent) } @@ -2703,8 +2713,10 @@ function getAttribute(node, name, value) { 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 @@ -2748,10 +2760,12 @@ function getDirective(node, name, argument) { 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 diff --git ORI/eslint-plugin-vue/tools/update-vue3-export-names.js ALT/eslint-plugin-vue/tools/update-vue3-export-names.js index fcd31b3..99d9278 100644 --- ORI/eslint-plugin-vue/tools/update-vue3-export-names.js +++ ALT/eslint-plugin-vue/tools/update-vue3-export-names.js @@ -110,9 +110,11 @@ async function resolveTypeContents(m) { const packageJson = JSON.parse(packageJsonText) let typesPath = - (packageJson.exports && + ( + packageJson.exports && packageJson.exports['.'] && - packageJson.exports['.'].types) || + packageJson.exports['.'].types + ) || packageJson.types if (typesPath.startsWith('./')) { typesPath = typesPath.slice(2) ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: excalidraw/excalidraw@49172ac2d309790d5ab5d55bdbd9ebf549ee5b01

Diff (743 lines) ```diff diff --git ORI/excalidraw/src/actions/actionFinalize.tsx ALT/excalidraw/src/actions/actionFinalize.tsx index e89112a..820b7c8 100644 --- ORI/excalidraw/src/actions/actionFinalize.tsx +++ ALT/excalidraw/src/actions/actionFinalize.tsx @@ -160,11 +160,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 }) => ( ({ 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, data }) => ( 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/components/Actions.tsx ALT/excalidraw/src/components/Actions.tsx index d1f9a78..3682806 100644 --- ORI/excalidraw/src/components/Actions.tsx +++ ALT/excalidraw/src/components/Actions.tsx @@ -40,8 +40,10 @@ export const SelectedShapeActions = ({ let isSingleElementBoundContainer = false; if ( targetElements.length === 2 && - (hasBoundTextElement(targetElements[0]) || - hasBoundTextElement(targetElements[1])) + ( + hasBoundTextElement(targetElements[0]) || + hasBoundTextElement(targetElements[1]) + ) ) { isSingleElementBoundContainer = true; } @@ -70,37 +72,49 @@ export const SelectedShapeActions = ({ return (
- {((hasStrokeColor(elementType) && - elementType !== "image" && - commonSelectedType !== "image") || - targetElements.some((element) => hasStrokeColor(element.type))) && + {( + ( + hasStrokeColor(elementType) && + elementType !== "image" && + commonSelectedType !== "image" + ) || + targetElements.some((element) => hasStrokeColor(element.type)) + ) && renderAction("changeStrokeColor")} {showChangeBackgroundIcons && renderAction("changeBackgroundColor")} {showFillIcons && renderAction("changeFillStyle")} - {(hasStrokeWidth(elementType) || - targetElements.some((element) => hasStrokeWidth(element.type))) && + {( + hasStrokeWidth(elementType) || + targetElements.some((element) => hasStrokeWidth(element.type)) + ) && renderAction("changeStrokeWidth")} - {(elementType === "freedraw" || - targetElements.some((element) => element.type === "freedraw")) && + {( + elementType === "freedraw" || + targetElements.some((element) => element.type === "freedraw") + ) && renderAction("changeStrokeShape")} - {(hasStrokeStyle(elementType) || - targetElements.some((element) => hasStrokeStyle(element.type))) && ( + {( + hasStrokeStyle(elementType) || + targetElements.some((element) => hasStrokeStyle(element.type)) + ) && ( <> {renderAction("changeStrokeStyle")} {renderAction("changeSloppiness")} )} - {(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")} @@ -110,10 +124,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 ae5376f..53ee10d 100644 --- ORI/excalidraw/src/components/App.tsx +++ ALT/excalidraw/src/components/App.tsx @@ -1337,8 +1337,10 @@ class App extends React.Component { // 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; } @@ -1681,8 +1683,10 @@ class App extends React.Component { // 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) { @@ -1734,10 +1738,10 @@ class App extends React.Component { 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); @@ -1844,8 +1848,10 @@ class App extends React.Component { if ( event.key === KEYS.G && - (hasBackground(this.state.elementType) || - selectedElements.some((element) => hasBackground(element.type))) + ( + hasBackground(this.state.elementType) || + selectedElements.some((element) => hasBackground(element.type)) + ) ) { this.setState({ openPopup: "backgroundColorPicker" }); } @@ -2614,8 +2620,10 @@ class App extends React.Component { const hasDeselectedButton = Boolean(event.buttons); if ( hasDeselectedButton || - (this.state.elementType !== "selection" && - this.state.elementType !== "text") + ( + this.state.elementType !== "selection" && + this.state.elementType !== "text" + ) ) { return; } @@ -2719,11 +2727,13 @@ class App extends React.Component { } else if ( // if using cmd/ctrl, we're not dragging !event[KEYS.CTRL_OR_CMD] && - (hitElement || + ( + hitElement || this.isHittingCommonBoundingBoxOfSelectedElements( scenePointer, selectedElements, - )) + ) + ) ) { setCursor(this.canvas, CURSOR_TYPE.MOVE); } else { @@ -2964,9 +2974,11 @@ class App extends React.Component { 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 + ) ) || isTextElement(this.state.editingElement) ) { @@ -3741,8 +3753,10 @@ class App extends React.Component { // triggering pointermove) if ( !pointerDownState.drag.hasOccurred && - (this.state.elementType === "arrow" || - this.state.elementType === "line") + ( + this.state.elementType === "arrow" || + this.state.elementType === "line" + ) ) { if ( distance2d( @@ -3790,16 +3804,20 @@ class App extends React.Component { ); if ( - (hasHitASelectedElement || - pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && + ( + hasHitASelectedElement || + pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements + ) && // this allows for box-selecting points when clicking inside the // line's bounding box (!this.state.editingLinearElement || !event.shiftKey) && // box-selecting without shift when editing line, not clicking on a line - (!this.state.editingLinearElement || + ( + !this.state.editingLinearElement || this.state.editingLinearElement?.elementId !== pointerDownState.hit.element?.id || - pointerDownState.hit.hasHitElementInside) + pointerDownState.hit.hasHitElementInside + ) ) { // Marking that click was used for dragging to check // if elements should be deselected on pointerup @@ -3861,8 +3879,10 @@ class App extends React.Component { selectedElementIds.includes(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, @@ -4103,9 +4123,11 @@ class App extends React.Component { if (this.state.editingLinearElement) { if ( !pointerDownState.boxSelection.hasOccurred && - (pointerDownState.hit?.element?.id !== - this.state.editingLinearElement.elementId || - !pointerDownState.hit.hasHitElementInside) + ( + pointerDownState.hit?.element?.id !== + this.state.editingLinearElement.elementId || + !pointerDownState.hit.hasHitElementInside + ) ) { this.actionManager.executeAction(actionFinalize); } else { @@ -4308,8 +4330,10 @@ class App extends React.Component { !pointerDownState.hit.wasAddedToSelection && // if we're editing a line, pointerup shouldn't switch selection if // box selected - (!this.state.editingLinearElement || - !pointerDownState.boxSelection.hasOccurred) + ( + !this.state.editingLinearElement || + !pointerDownState.boxSelection.hasOccurred + ) ) { // when inside line editor, shift selects points instead if (childEvent.shiftKey && !this.state.editingLinearElement) { @@ -4381,15 +4405,21 @@ class App extends React.Component { !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({ @@ -4728,8 +4758,10 @@ class App extends React.Component { // if user-created bounding box is below threshold, assume the // intention was to click instead of drag, and use the image's // intrinsic size - (imageElement.width < DRAGGING_THRESHOLD / this.state.zoom.value && - imageElement.height < DRAGGING_THRESHOLD / this.state.zoom.value) + ( + imageElement.width < DRAGGING_THRESHOLD / this.state.zoom.value && + imageElement.height < DRAGGING_THRESHOLD / this.state.zoom.value + ) ) { const minHeight = Math.max(this.state.height - 120, 160); // max 65% of canvas height, clamped to <300px, vh - 120px> @@ -5055,10 +5087,14 @@ class App extends React.Component { event.preventDefault(); if ( - (event.nativeEvent.pointerType === "touch" || - (event.nativeEvent.pointerType === "pen" && + ( + event.nativeEvent.pointerType === "touch" || + ( + event.nativeEvent.pointerType === "pen" && // always allow if user uses a pen secondary button - event.button !== POINTER_BUTTON.SECONDARY)) && + event.button !== POINTER_BUTTON.SECONDARY + ) + ) && this.state.elementType !== "selection" ) { return; @@ -5275,8 +5311,10 @@ class App extends React.Component { 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/LibraryMenu.tsx ALT/excalidraw/src/components/LibraryMenu.tsx index 763dfb8..18179bb 100644 --- ORI/excalidraw/src/components/LibraryMenu.tsx +++ ALT/excalidraw/src/components/LibraryMenu.tsx @@ -32,8 +32,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 e7ce527..5308512 100644 --- ORI/excalidraw/src/data/json.ts +++ ALT/excalidraw/src/data/json.ts @@ -108,9 +108,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/linearElementEditor.ts ALT/excalidraw/src/element/linearElementEditor.ts index ee4da2d..d88f86d 100644 --- ORI/excalidraw/src/element/linearElementEditor.ts +++ ALT/excalidraw/src/element/linearElementEditor.ts @@ -106,10 +106,12 @@ export class LinearElementEditor { const nextSelectedPoints = pointsSceneCoords.reduce( (acc: number[], point, index) => { if ( - (point[0] >= selectionX1 && + ( + point[0] >= selectionX1 && point[0] <= selectionX2 && point[1] >= selectionY1 && - point[1] <= selectionY2) || + point[1] <= selectionY2 + ) || (event.shiftKey && selectedPointsIndices?.includes(index)) ) { acc.push(index); diff --git ORI/excalidraw/src/element/mutateElement.ts ALT/excalidraw/src/element/mutateElement.ts index 52038c1..5a8b94a 100644 --- ORI/excalidraw/src/element/mutateElement.ts +++ ALT/excalidraw/src/element/mutateElement.ts @@ -37,10 +37,12 @@ export const mutateElement = >( (element as any)[key] === value && // if object, always update because its attrs could have changed // (except for specific keys we handle below) - (typeof value !== "object" || + ( + typeof value !== "object" || value === null || key === "groupIds" || - key === "scale") + key === "scale" + ) ) { continue; } diff --git ORI/excalidraw/src/element/resizeElements.ts ALT/excalidraw/src/element/resizeElements.ts index 634e9dd..72698a4 100644 --- ORI/excalidraw/src/element/resizeElements.ts +++ ALT/excalidraw/src/element/resizeElements.ts @@ -77,10 +77,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, @@ -91,10 +93,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 a62efb4..a083478 100644 --- ORI/excalidraw/src/element/textWysiwyg.tsx +++ ALT/excalidraw/src/element/textWysiwyg.tsx @@ -333,9 +333,13 @@ export const textWysiwyg = ({ handleSubmit(); } else if ( event.key === KEYS.TAB || - (event[KEYS.CTRL_OR_CMD] && - (event.code === CODES.BRACKET_LEFT || - event.code === CODES.BRACKET_RIGHT)) + ( + event[KEYS.CTRL_OR_CMD] && + ( + event.code === CODES.BRACKET_LEFT || + event.code === CODES.BRACKET_RIGHT + ) + ) ) { event.preventDefault(); if (event.shiftKey || event.code === CODES.BRACKET_LEFT) { @@ -555,10 +559,14 @@ export const textWysiwyg = ({ event.target.closest(".color-picker-input") && isWritableElement(event.target); 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)) || + !isWritableElement(event.target) + ) || isTargetColorPicker ) { editable.onblur = null; diff --git ORI/excalidraw/src/element/typeChecks.ts ALT/excalidraw/src/element/typeChecks.ts index ea5b11a..bf28c61 100644 --- ORI/excalidraw/src/element/typeChecks.ts +++ ALT/excalidraw/src/element/typeChecks.ts @@ -15,10 +15,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" + ) ); }; @@ -83,21 +85,25 @@ export const isBindableElement = ( ): element is ExcalidrawBindableElement => { return ( element != null && - (element.type === "rectangle" || + ( + element.type === "rectangle" || element.type === "diamond" || element.type === "ellipse" || element.type === "image" || - (element.type === "text" && !element.containerId)) + (element.type === "text" && !element.containerId) + ) ); }; export const isTextBindableContainer = (element: ExcalidrawElement | null) => { return ( element != null && - (element.type === "rectangle" || + ( + element.type === "rectangle" || element.type === "diamond" || element.type === "ellipse" || - element.type === "image") + element.type === "image" + ) ); }; diff --git ORI/excalidraw/src/excalidraw-app/collab/CollabWrapper.tsx ALT/excalidraw/src/excalidraw-app/collab/CollabWrapper.tsx index 23454bc..3f9c93d 100644 --- ORI/excalidraw/src/excalidraw-app/collab/CollabWrapper.tsx +++ ALT/excalidraw/src/excalidraw-app/collab/CollabWrapper.tsx @@ -202,8 +202,10 @@ class CollabWrapper extends PureComponent { if ( this.isCollaborating && - (this.fileManager.shouldPreventUnload(syncableElements) || - !isSavedToFirebase(this.portal, syncableElements)) + ( + this.fileManager.shouldPreventUnload(syncableElements) || + !isSavedToFirebase(this.portal, syncableElements) + ) ) { // this won't run in time if user decides to leave the site, but // the purpose is to run in immediately after user decides to stay diff --git ORI/excalidraw/src/excalidraw-app/collab/Portal.tsx ALT/excalidraw/src/excalidraw-app/collab/Portal.tsx index 4922ac0..240f117 100644 --- ORI/excalidraw/src/excalidraw-app/collab/Portal.tsx +++ ALT/excalidraw/src/excalidraw-app/collab/Portal.tsx @@ -133,10 +133,11 @@ class Portal { const syncableElements = allElements.reduce( (acc, element: BroadcastedExcalidrawElement, idx, elements) => { if ( - (syncAll || + ( + syncAll || !this.broadcastedElementVersions.has(element.id) || - element.version > - this.broadcastedElementVersions.get(element.id)!) && + element.version > this.broadcastedElementVersions.get(element.id)! + ) && this.collab.isSyncableElement(element) ) { acc.push({ diff --git ORI/excalidraw/src/excalidraw-app/collab/reconciliation.ts ALT/excalidraw/src/excalidraw-app/collab/reconciliation.ts index 4c9019f..e89b768 100644 --- ORI/excalidraw/src/excalidraw-app/collab/reconciliation.ts +++ ALT/excalidraw/src/excalidraw-app/collab/reconciliation.ts @@ -17,15 +17,19 @@ const shouldDiscardRemoteElement = ( if ( local && // local element is being edited - (local.id === localAppState.editingElement?.id || + ( + local.id === localAppState.editingElement?.id || local.id === localAppState.resizingElement?.id || local.id === localAppState.draggingElement?.id || // local element is newer local.version > remote.version || // resolve conflicting edits deterministically by taking the one with // the lowest versionNonce - (local.version === remote.version && - local.versionNonce < remote.versionNonce)) + ( + local.version === remote.version && + local.versionNonce < remote.versionNonce + ) + ) ) { return true; } diff --git ORI/excalidraw/src/shapes.tsx ALT/excalidraw/src/shapes.tsx index c54ef20..799ea0d 100644 --- ORI/excalidraw/src/shapes.tsx +++ ALT/excalidraw/src/shapes.tsx @@ -111,10 +111,12 @@ export const findShapeByKey = (key: string) => { const shape = SHAPES.find((shape, index) => { return ( key === (index + 1).toString() || - (shape.key && + ( + shape.key && (typeof shape.key === "string" ? shape.key === key - : (shape.key as readonly string[]).includes(key))) + : (shape.key as readonly string[]).includes(key)) + ) ); }); return shape?.value || null; diff --git ORI/excalidraw/src/utils.ts ALT/excalidraw/src/utils.ts index 3d3cecd..54de2d1 100644 --- ORI/excalidraw/src/utils.ts +++ ALT/excalidraw/src/utils.ts @@ -64,8 +64,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, @@ -475,9 +477,11 @@ export const getNearestScrollableContainer = ( const hasScrollableContent = parent.scrollHeight > parent.clientHeight; if ( hasScrollableContent && - (overflowY === "auto" || + ( + overflowY === "auto" || overflowY === "scroll" || - overflowY === "overlay") + overflowY === "overlay" + ) ) { return parent; } ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: prettier/prettier@e949a54e595e7bb20b2ea8e85736fbf030701404

Diff (3149 lines) ```diff diff --git ORI/prettier/src/cli/format.js ALT/prettier/src/cli/format.js index 0180652..a257309 100644 --- ORI/prettier/src/cli/format.js +++ ALT/prettier/src/cli/format.js @@ -310,10 +310,12 @@ async function formatFiles(context) { const fileIgnored = ignorer.ignores(fixWindowsSlashes(ignoreFilename)); if ( fileIgnored && - (context.argv.debugCheck || + ( + context.argv.debugCheck || context.argv.write || context.argv.check || - context.argv.listDifferent) + context.argv.listDifferent + ) ) { continue; } diff --git ORI/prettier/src/cli/options/create-minimist-options.js ALT/prettier/src/cli/options/create-minimist-options.js index baaa4cf..3a45d50 100644 --- ORI/prettier/src/cli/options/create-minimist-options.js +++ ALT/prettier/src/cli/options/create-minimist-options.js @@ -17,9 +17,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/common/util.js ALT/prettier/src/common/util.js index 4acfb14..e8940bd 100644 --- ORI/prettier/src/common/util.js +++ ALT/prettier/src/common/util.js @@ -268,9 +268,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 ? "'" @@ -468,8 +470,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 8dc5925..1f8d7b7 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 1ede6c6..3c2a9d1 100644 --- ORI/prettier/src/language-css/printer-postcss.js +++ ALT/prettier/src/language-css/printer-postcss.js @@ -284,13 +284,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 : " ", "{", @@ -519,8 +523,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); @@ -671,8 +677,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; @@ -690,10 +698,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; @@ -725,15 +735,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; } @@ -751,11 +767,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(" "); @@ -856,12 +874,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") : "", @@ -988,9 +1010,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") ? "" @@ -1042,14 +1066,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/index.js ALT/prettier/src/language-css/utils/index.js index efcf7f6..bd91418 100644 --- ORI/prettier/src/language-css/utils/index.js +++ ALT/prettier/src/language-css/utils/index.js @@ -102,8 +102,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 abcf1a9..1a7b5a5 100644 --- ORI/prettier/src/language-handlebars/utils.js +++ ALT/prettier/src/language-handlebars/utils.js @@ -40,8 +40,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/embed.js ALT/prettier/src/language-html/embed.js index ef83e63..188387d 100644 --- ORI/prettier/src/language-html/embed.js +++ ALT/prettier/src/language-html/embed.js @@ -51,11 +51,17 @@ function printEmbeddedAttributeValue(node, htmlTextToDoc, 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; } @@ -292,9 +298,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"; } diff --git ORI/prettier/src/language-html/parser-html.js ALT/prettier/src/language-html/parser-html.js index b438eaa..f529ede 100644 --- ORI/prettier/src/language-html/parser-html.js +++ ALT/prettier/src/language-html/parser-html.js @@ -220,9 +220,11 @@ function ngHtmlParser( if (node.type === "element") { if ( normalizeTagName && - (!node.namespace || + ( + !node.namespace || node.namespace === node.tagDefinition.implicitNamespacePrefix || - isUnknownNamespace(node)) + isUnknownNamespace(node) + ) ) { node.name = lowerCaseIfFn( node.name, @@ -239,8 +241,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 + ) ); } } @@ -419,10 +423,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 0add77b..133bd73 100644 --- ORI/prettier/src/language-html/print-preprocess.js +++ ALT/prettier/src/language-html/print-preprocess.js @@ -268,9 +268,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 + ) ) { node.hasDanglingSpaces = node.children.length > 0; node.children = []; @@ -337,10 +339,14 @@ function addIsSelfClosing(ast /*, options */) { ast.walk((node) => { 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/print/children.js ALT/prettier/src/language-html/print/children.js index ee8d36e..60b7f6e 100644 --- ORI/prettier/src/language-html/print/children.js +++ ALT/prettier/src/language-html/print/children.js @@ -58,8 +58,10 @@ function printBetweenLine(prevNode, nextNode) { : preferHardlineAsLeadingSpaces(nextNode) ? hardline : softline - : (needsToBorrowNextOpeningTagStartMarker(prevNode) && - (hasPrettierIgnore(nextNode) || + : ( + needsToBorrowNextOpeningTagStartMarker(prevNode) && + ( + hasPrettierIgnore(nextNode) || /** * 123 0))) || + (nextNode.type === "element" && nextNode.attrs.length > 0) + ) + ) || /** * 123 */ - (prevNode.type === "element" && + ( + prevNode.type === "element" && prevNode.isSelfClosing && - needsToBorrowPrevClosingTagEndMarker(nextNode)) + needsToBorrowPrevClosingTagEndMarker(nextNode) + ) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) || @@ -96,11 +102,13 @@ function printBetweenLine(prevNode, nextNode) { * ~ * >. */ - (needsToBorrowPrevClosingTagEndMarker(nextNode) && + ( + needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && - needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild)) + needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) + ) ? hardline : nextNode.hasLeadingSpaces ? line diff --git ORI/prettier/src/language-html/print/element.js ALT/prettier/src/language-html/print/element.js index a00d4e3..8562dbf 100644 --- ORI/prettier/src/language-html/print/element.js +++ ALT/prettier/src/language-html/print/element.js @@ -138,10 +138,14 @@ function printElement(path, options, print) { return line; } if ( - (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 * diff --git ORI/prettier/src/language-html/print/tag.js ALT/prettier/src/language-html/print/tag.js index 7d97ec0..96ab07d 100644 --- ORI/prettier/src/language-html/print/tag.js +++ ALT/prettier/src/language-html/print/tag.js @@ -269,16 +269,20 @@ function printAttributes(path, options, print) { * ~ * >456 */ - (node.firstChild && - needsToBorrowParentOpeningTagEndMarker(node.firstChild)) || + ( + node.firstChild && + needsToBorrowParentOpeningTagEndMarker(node.firstChild) + ) || /** * 123 */ - (node.isSelfClosing && - needsToBorrowLastChildClosingTagEndMarker(node.parent)) || + ( + node.isSelfClosing && + needsToBorrowLastChildClosingTagEndMarker(node.parent) + ) || forceNotToBreakAttrContent ) { parts.push(node.isSelfClosing ? " " : ""); diff --git ORI/prettier/src/language-html/utils/index.js ALT/prettier/src/language-html/utils/index.js index 18b46ce..8d719aa 100644 --- ORI/prettier/src/language-html/utils/index.js +++ ALT/prettier/src/language-html/utils/index.js @@ -112,11 +112,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") + ) + ) ); } @@ -174,11 +178,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; } @@ -217,11 +223,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; } @@ -246,9 +254,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 + ) ); } @@ -256,16 +266,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) + ) + ) ); } @@ -274,8 +292,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") + ) ); } @@ -315,8 +335,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 + )) ); } @@ -403,8 +425,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) + ) ); } } @@ -508,11 +532,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 ); } @@ -521,9 +549,11 @@ function getNodeCssStyleDisplay(node, options) { 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 ); } @@ -596,8 +626,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 fa706ef..6a30232 100644 --- ORI/prettier/src/language-js/clean.js +++ ALT/prettier/src/language-js/clean.js @@ -61,8 +61,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; @@ -72,7 +74,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" || @@ -80,13 +83,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; } @@ -159,15 +165,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 4a23aba..9985169 100644 --- ORI/prettier/src/language-js/comments.js +++ ALT/prettier/src/language-js/comments.js @@ -307,8 +307,10 @@ function handleTryStatementComments({ }) { if ( !enclosingNode || - (enclosingNode.type !== "TryStatement" && - enclosingNode.type !== "CatchClause") || + ( + enclosingNode.type !== "TryStatement" && + enclosingNode.type !== "CatchClause" + ) || !followingNode ) { return false; @@ -368,8 +370,10 @@ function handleConditionalExpressionComments({ if ( (!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && - (enclosingNode.type === "ConditionalExpression" || - enclosingNode.type === "TSConditionalType") && + ( + enclosingNode.type === "ConditionalExpression" || + enclosingNode.type === "TSConditionalType" + ) && followingNode ) { addLeadingComment(followingNode, comment); @@ -403,12 +407,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) && @@ -430,8 +436,10 @@ function handleClassComments({ enclosingNode.superClass && followingNode === enclosingNode.superClass && precedingNode && - (precedingNode === enclosingNode.id || - precedingNode === enclosingNode.typeParameters) + ( + precedingNode === enclosingNode.id || + precedingNode === enclosingNode.typeParameters + ) ) { addTrailingComment(precedingNode, comment); return true; @@ -441,9 +449,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 { @@ -471,9 +481,11 @@ function handleMethodNameComments({ precedingNode && getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(" && // "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) }; @@ -490,13 +502,15 @@ function handleMethodNameComments({ precedingNode && enclosingNode && precedingNode.type === "Decorator" && - (enclosingNode.type === "ClassMethod" || + ( + enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "PropertyDefinition" || enclosingNode.type === "TSAbstractPropertyDefinition" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || - enclosingNode.type === "MethodDefinition") + enclosingNode.type === "MethodDefinition" + ) ) { addTrailingComment(precedingNode, comment); return true; @@ -517,11 +531,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; @@ -552,18 +568,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); @@ -595,8 +619,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) === ")" @@ -660,8 +686,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); @@ -695,8 +723,10 @@ function handleUnionTypeComments({ }) { if ( enclosingNode && - (enclosingNode.type === "UnionTypeAnnotation" || - enclosingNode.type === "TSUnionType") + ( + enclosingNode.type === "UnionTypeAnnotation" || + enclosingNode.type === "TSUnionType" + ) ) { if (isPrettierIgnoreComment(comment)) { followingNode.prettierIgnore = true; @@ -711,8 +741,10 @@ function handleUnionTypeComments({ if ( followingNode && - (followingNode.type === "UnionTypeAnnotation" || - followingNode.type === "TSUnionType") && + ( + followingNode.type === "UnionTypeAnnotation" || + followingNode.type === "TSUnionType" + ) && isPrettierIgnoreComment(comment) ) { followingNode.types[0].prettierIgnore = true; @@ -778,8 +810,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; @@ -821,18 +855,22 @@ function handleVariableDeclaratorComments({ }) { if ( enclosingNode && - (enclosingNode.type === "VariableDeclarator" || + ( + enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression" || enclosingNode.type === "TypeAlias" || - enclosingNode.type === "TSTypeAliasDeclaration") && + enclosingNode.type === "TSTypeAliasDeclaration" + ) && followingNode && - (followingNode.type === "ObjectExpression" || + ( + followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression" || followingNode.type === "ObjectTypeAnnotation" || followingNode.type === "TSTypeLiteral" || - isBlockComment(comment)) + isBlockComment(comment) + ) ) { addLeadingComment(followingNode, comment); return true; @@ -849,9 +887,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); @@ -962,12 +1002,14 @@ function getCommentChildNodes(node, options) { // } // } if ( - (options.parser === "typescript" || + ( + options.parser === "typescript" || options.parser === "flow" || options.parser === "acorn" || options.parser === "espree" || options.parser === "meriyah" || - options.parser === "__babel_estree") && + options.parser === "__babel_estree" + ) && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && @@ -1008,21 +1050,37 @@ function willPrintOwnComments(path /*, options */) { hasFlowAnnotationComment(getComments(node, CommentCheckFlags.Trailing)); return ( - ((node && - (isJsxNode(node) || - hasFlowShorthandAnnotationComment(node) || - (isCallExpression(parent) && hasFlowAnnotations(node)))) || - (parent && - (parent.type === "JSXSpreadAttribute" || + ( + ( + node && + ( + isJsxNode(node) || + hasFlowShorthandAnnotationComment(node) || + (isCallExpression(parent) && hasFlowAnnotations(node)) + ) + ) || + ( + 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 8703ad9..6ce9c74 100644 --- ORI/prettier/src/language-js/embed.js +++ ALT/prettier/src/language-js/embed.js @@ -99,24 +99,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" + ) + ) ); } @@ -195,15 +203,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": @@ -254,16 +272,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 0695e97..1aa27bd 100644 --- ORI/prettier/src/language-js/needs-parens.js +++ ALT/prettier/src/language-js/needs-parens.js @@ -88,7 +88,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" || @@ -101,7 +102,8 @@ function needsParens(path, options) { node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression" || - node.type === "TSNonNullExpression") + node.type === "TSNonNullExpression" + ) ) { return true; } @@ -183,8 +185,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 @@ -419,8 +423,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) ) { @@ -439,8 +445,10 @@ function needsParens(path, options) { parent.type === "TSRestType" || (name === "objectType" && parent.type === "TSIndexedAccessType") || parent.type === "TSTypeOperator" || - (parent.type === "TSTypeAnnotation" && - path.getParentNode(1).type.startsWith("TSJSDoc")) + ( + parent.type === "TSTypeAnnotation" && + path.getParentNode(1).type.startsWith("TSJSDoc") + ) ); case "ArrayTypeAnnotation": @@ -453,17 +461,25 @@ function needsParens(path, options) { parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || - (name === "objectType" && - (parent.type === "IndexedAccessType" || - parent.type === "OptionalIndexedAccessType")) + ( + name === "objectType" && + ( + parent.type === "IndexedAccessType" || + parent.type === "OptionalIndexedAccessType" + ) + ) ); case "NullableTypeAnnotation": return ( parent.type === "ArrayTypeAnnotation" || - (name === "objectType" && - (parent.type === "IndexedAccessType" || - parent.type === "OptionalIndexedAccessType")) + ( + name === "objectType" && + ( + parent.type === "IndexedAccessType" || + parent.type === "OptionalIndexedAccessType" + ) + ) ); case "FunctionTypeAnnotation": { @@ -476,21 +492,27 @@ function needsParens(path, options) { ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || - (name === "objectType" && - (ancestor.type === "IndexedAccessType" || - ancestor.type === "OptionalIndexedAccessType")) || + ( + name === "objectType" && + ( + ancestor.type === "IndexedAccessType" || + ancestor.type === "OptionalIndexedAccessType" + ) + ) || // We should check ancestor's parent to know whether the parentheses // are really needed, but since ??T doesn't make sense this check // 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" - )) + ) + ) ); } @@ -500,8 +522,10 @@ function needsParens(path, options) { case "TypeofTypeAnnotation": return ( name === "objectType" && - (parent.type === "IndexedAccessType" || - parent.type === "OptionalIndexedAccessType") + ( + parent.type === "IndexedAccessType" || + parent.type === "OptionalIndexedAccessType" + ) ); case "StringLiteral": @@ -536,8 +560,10 @@ function needsParens(path, options) { if ( name === "key" && - (parent.type === "ClassProperty" || - parent.type === "PropertyDefinition") && + ( + parent.type === "ClassProperty" || + parent.type === "PropertyDefinition" + ) && parent.computed ) { return false; @@ -684,12 +710,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; } @@ -731,18 +760,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") || @@ -756,10 +788,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" && @@ -779,7 +814,8 @@ function needsParens(path, options) { parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && - parent.type !== "YieldExpression") + parent.type !== "YieldExpression" + ) ); case "TypeAnnotation": return ( @@ -862,11 +898,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/parse/json.js ALT/prettier/src/language-js/parse/json.js index e69e379..deb63e9 100644 --- ORI/prettier/src/language-js/parse/json.js +++ ALT/prettier/src/language-js/parse/json.js @@ -82,8 +82,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/parse/postprocess/typescript.js ALT/prettier/src/language-js/parse/postprocess/typescript.js index 39a7170..a96eb84 100644 --- ORI/prettier/src/language-js/parse/postprocess/typescript.js +++ ALT/prettier/src/language-js/parse/postprocess/typescript.js @@ -45,10 +45,12 @@ function throwErrorForInvalidAbstractProperty(tsNode, esTreeNode) { const SYNTAX_KIND_ABSTRACT_KEYWORD = 126; if ( tsNode.kind !== SYNTAX_KIND_PROPERTY_DEFINITION || - (tsNode.modifiers && + ( + tsNode.modifiers && !tsNode.modifiers.some( (modifier) => modifier.kind === SYNTAX_KIND_ABSTRACT_KEYWORD - )) + ) + ) ) { return; } diff --git ORI/prettier/src/language-js/print/angular.js ALT/prettier/src/language-js/print/angular.js index 005692b..eee31f1 100644 --- ORI/prettier/src/language-js/print/angular.js +++ ALT/prettier/src/language-js/print/angular.js @@ -67,14 +67,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 551f675..04116b2 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 1cb8bc8..5c0fccc 100644 --- ORI/prettier/src/language-js/print/assignment.js +++ ALT/prettier/src/language-js/print/assignment.js @@ -107,8 +107,10 @@ function chooseLayout(path, options, print, leftDoc, rightPropertyName) { isAssignmentOrVariableDeclarator, (node) => !isTail || - (node.type !== "ExpressionStatement" && - node.type !== "VariableDeclaration") + ( + node.type !== "ExpressionStatement" && + node.type !== "VariableDeclaration" + ) ); if (shouldUseChainFormatting) { return !isTail @@ -128,8 +130,10 @@ function chooseLayout(path, options, print, leftDoc, rightPropertyName) { } if ( - (rightNode.type === "CallExpression" && - rightNode.callee.name === "require") || + ( + rightNode.type === "CallExpression" && + rightNode.callee.name === "require" + ) || // do not put values on a separate line from the key in json options.parser === "json5" || options.parser === "json" @@ -232,8 +236,10 @@ function isComplexDestructuring(node) { leftNode.properties.some( (property) => isObjectProperty(property) && - (!property.shorthand || - (property.value && property.value.type === "AssignmentPattern")) + ( + !property.shorthand || + (property.value && property.value.type === "AssignmentPattern") + ) ) ); } diff --git ORI/prettier/src/language-js/print/binaryish.js ALT/prettier/src/language-js/print/binaryish.js index 813a769..0b36fdd 100644 --- ORI/prettier/src/language-js/print/binaryish.js +++ ALT/prettier/src/language-js/print/binaryish.js @@ -37,10 +37,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 isHackPipeline = isEnabledHackPipeline(options) && node.operator === "|>"; @@ -91,20 +93,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 = @@ -231,9 +243,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; @@ -288,10 +302,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 187521a..537d01a 100644 --- ORI/prettier/src/language-js/print/call-arguments.js +++ ALT/prettier/src/language-js/print/call-arguments.js @@ -93,8 +93,10 @@ function printCallArguments(path, options, print) { if ( anyArgEmptyLine || - (path.getParentNode().type !== "Decorator" && - isFunctionCompositionArgs(args)) + ( + path.getParentNode().type !== "Decorator" && + isFunctionCompositionArgs(args) + ) ) { return allArgsBrokenOut(); } @@ -185,14 +187,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 { @@ -204,20 +211,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) + ) + ) || arg.type === "DoExpression" || arg.type === "ModuleExpression" ); @@ -234,9 +252,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" && @@ -261,9 +281,13 @@ function shouldGroupFirstArg(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" && @@ -285,8 +309,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 bbc5864..1467e76 100644 --- ORI/prettier/src/language-js/print/call-expression.js +++ ALT/prettier/src/language-js/print/call-expression.js @@ -35,13 +35,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, () => { @@ -117,11 +121,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/class.js ALT/prettier/src/language-js/print/class.js index 8864459..8cdd964 100644 --- ORI/prettier/src/language-js/print/class.js +++ ALT/prettier/src/language-js/print/class.js @@ -37,8 +37,10 @@ function printClass(path, options, print) { // If there is only on extends and there are not comments const groupMode = (node.id && hasComment(node.id, CommentCheckFlags.Trailing)) || - (node.typeParameters && - hasComment(node.typeParameters, CommentCheckFlags.Trailing)) || + ( + node.typeParameters && + hasComment(node.typeParameters, CommentCheckFlags.Trailing) + ) || (node.superClass && hasComment(node.superClass)) || isNonEmptyArray(node.extends) || // DeclareClass isNonEmptyArray(node.mixins) || diff --git ORI/prettier/src/language-js/print/function-parameters.js ALT/prettier/src/language-js/print/function-parameters.js index 12f0af2..73a6790 100644 --- ORI/prettier/src/language-js/print/function-parameters.js +++ ALT/prettier/src/language-js/print/function-parameters.js @@ -114,14 +114,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;` @@ -163,23 +167,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 8263a11..427b495 100644 --- ORI/prettier/src/language-js/print/function.js +++ ALT/prettier/src/language-js/print/function.js @@ -57,8 +57,10 @@ function printFunction(path, print, options, args) { let expandArg = false; if ( - (node.type === "FunctionDeclaration" || - node.type === "FunctionExpression") && + ( + node.type === "FunctionDeclaration" || + node.type === "FunctionExpression" + ) && args && args.expandLastArg ) { @@ -336,13 +338,15 @@ function printArrowFunction(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]); } @@ -361,8 +365,10 @@ function printArrowFunction(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 cb307e4..8863e19 100644 --- ORI/prettier/src/language-js/print/jsx.js +++ ALT/prettier/src/language-js/print/jsx.js @@ -78,8 +78,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]; } @@ -159,12 +161,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) || @@ -505,20 +511,30 @@ function printJsxExpressionContainer(path, options, print) { const shouldInline = (node, parent) => node.type === "JSXEmptyExpression" || - (!hasComment(node) && - (node.type === "ArrayExpression" || + ( + !hasComment(node) && + ( + node.type === "ArrayExpression" || node.type === "ObjectExpression" || node.type === "ArrowFunctionExpression" || - (node.type === "AwaitExpression" && - (shouldInline(node.argument, node) || - node.argument.type === "JSXElement")) || + ( + node.type === "AwaitExpression" && + ( + shouldInline(node.argument, node) || + node.argument.type === "JSXElement" + ) + ) || isCallExpression(node) || node.type === "FunctionExpression" || node.type === "TemplateLiteral" || node.type === "TaggedTemplateExpression" || node.type === "DoExpression" || - (isJsxNode(parent) && - (node.type === "ConditionalExpression" || isBinaryish(node))))); + ( + isJsxNode(parent) && + (node.type === "ConditionalExpression" || isBinaryish(node)) + ) + ) + ); if (shouldInline(node.expression, path.getParentNode(0))) { return group(["{", print("expression"), lineSuffixBoundary, "}"]); @@ -584,7 +600,8 @@ function printJsxOpeningElement(path, options, print) { // jsxBracketSameLine is deprecated in favour of bracketSameLine, // but is still needed for backwards compatibility. (node.attributes.length === 0 && !nameHasComments) || - ((options.bracketSameLine || options.jsxBracketSameLine) && + ( + (options.bracketSameLine || options.jsxBracketSameLine) && // We should print the bracket in a new line for the following cases: //
(!nameHasComments || node.attributes.length > 0) && - !lastAttrHasTrailingComments); + !lastAttrHasTrailingComments + ); // We should print the opening element expanded if any prop value is a // string literal with newlines @@ -803,8 +821,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 984b31c..4319e47 100644 --- ORI/prettier/src/language-js/print/member-chain.js +++ ALT/prettier/src/language-js/print/member-chain.js @@ -185,9 +185,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 { @@ -283,10 +285,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 + ) + ) ); } @@ -334,8 +340,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. @@ -386,10 +394,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 ddbdd86..14eef0c 100644 --- ORI/prettier/src/language-js/print/member.js +++ ALT/prettier/src/language-js/print/member.js @@ -21,30 +21,48 @@ function printMemberExpression(path, options, print) { i++; } while ( firstNonMemberParent && - (isMemberExpression(firstNonMemberParent) || - firstNonMemberParent.type === "TSNonNullExpression") + ( + isMemberExpression(firstNonMemberParent) || + firstNonMemberParent.type === "TSNonNullExpression" + ) ); const objectDoc = print("object"); const lookupDoc = printMemberLookup(path, options, print); 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)) || - ((parent.type === "AssignmentExpression" || - parent.type === "VariableDeclarator") && - ((isCallExpression(node.object) && node.object.arguments.length > 0) || - (node.object.type === "TSNonNullExpression" && + !isMemberExpression(parent) + ) || + ( + ( + parent.type === "AssignmentExpression" || + parent.type === "VariableDeclarator" + ) && + ( + (isCallExpression(node.object) && node.object.arguments.length > 0) || + ( + node.object.type === "TSNonNullExpression" && isCallExpression(node.object.expression) && - node.object.expression.arguments.length > 0) || - objectDoc.label === "member-chain")); + node.object.expression.arguments.length > 0 + ) || + objectDoc.label === "member-chain" + ) + ); return label(objectDoc.label === "member-chain" ? "member-chain" : "member", [ objectDoc, diff --git ORI/prettier/src/language-js/print/misc.js ALT/prettier/src/language-js/print/misc.js index 66616e8..56fdc5d 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/object.js ALT/prettier/src/language-js/print/object.js index f1c789a..3989e00 100644 --- ORI/prettier/src/language-js/print/object.js +++ ALT/prettier/src/language-js/print/object.js @@ -54,14 +54,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" && @@ -73,16 +76,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 ? ";" @@ -118,9 +126,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(); @@ -159,12 +169,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; @@ -209,10 +223,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( @@ -221,21 +237,25 @@ 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 ) || // Assignment printing logic (printAssignment) is responsible // for adding a group if needed - (!shouldBreak && + ( + !shouldBreak && path.match( (node) => node.type === "ObjectPattern", (node) => node.type === "AssignmentExpression" || node.type === "VariableDeclarator" - )) + ) + ) ) { return content; } diff --git ORI/prettier/src/language-js/print/property.js ALT/prettier/src/language-js/print/property.js index 2a6b05c..f06e949 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 18c9c8d..bec96fa 100644 --- ORI/prettier/src/language-js/print/ternary.js +++ ALT/prettier/src/language-js/print/ternary.js @@ -238,10 +238,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; @@ -333,8 +335,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 88f4c78..12ac408 100644 --- ORI/prettier/src/language-js/print/type-annotation.js +++ ALT/prettier/src/language-js/print/type-annotation.js @@ -147,9 +147,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) ); @@ -214,11 +216,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 ba4c3c2..75e3669 100644 --- ORI/prettier/src/language-js/print/type-parameters.js +++ ALT/prettier/src/language-js/print/type-parameters.js @@ -45,11 +45,17 @@ function printTypeParameters(path, options, print, paramsKey) { const shouldInline = !isArrowFunctionVariable && - (isParameterInTestCall || + ( + isParameterInTestCall || node[paramsKey].length === 0 || - (node[paramsKey].length === 1 && - (node[paramsKey][0].type === "NullableTypeAnnotation" || - shouldHugType(node[paramsKey][0])))); + ( + node[paramsKey].length === 1 && + ( + node[paramsKey][0].type === "NullableTypeAnnotation" || + shouldHugType(node[paramsKey][0]) + ) + ) + ); if (shouldInline) { return [ diff --git ORI/prettier/src/language-js/printer-estree.js ALT/prettier/src/language-js/printer-estree.js index 4321e96..f4d17ce 100644 --- ORI/prettier/src/language-js/printer-estree.js +++ ALT/prettier/src/language-js/printer-estree.js @@ -248,8 +248,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"), ")"]; } @@ -668,12 +670,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/index.js ALT/prettier/src/language-js/utils/index.js index b005897..aa27f65 100644 --- ORI/prettier/src/language-js/utils/index.js +++ ALT/prettier/src/language-js/utils/index.js @@ -282,8 +282,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" + ) ); } @@ -356,8 +358,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) @@ -455,8 +459,10 @@ function isSimpleType(node) { } if ( - (node.type === "GenericTypeAnnotation" || - node.type === "TSTypeReference") && + ( + node.type === "GenericTypeAnnotation" || + node.type === "TSTypeReference" + ) && !node.typeParameters ) { return true; @@ -481,8 +487,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" + ) ); } @@ -514,11 +522,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])) { @@ -554,8 +568,10 @@ function isCallExpression(node) { function isMemberExpression(node) { return ( node && - (node.type === "MemberExpression" || - node.type === "OptionalMemberExpression") + ( + node.type === "MemberExpression" || + node.type === "OptionalMemberExpression" + ) ); } @@ -693,20 +709,31 @@ 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 === "babel-ts" && node.type === "ClassProperty") || - (options.parser === "typescript" && node.type === "PropertyDefinition") - )) || - (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 === "babel-ts" && node.type === "ClassProperty") || + ( + options.parser === "typescript" && + node.type === "PropertyDefinition" + ) + ) + ) || + ( + isSimpleNumber(node.key.value) && String(Number(node.key.value)) === node.key.value && - (options.parser === "babel" || + ( + options.parser === "babel" || options.parser === "acorn" || options.parser === "espree" || options.parser === "meriyah" || - options.parser === "__babel_estree"))) + options.parser === "__babel_estree" + ) + ) + ) ); } @@ -738,14 +765,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) + ) + ) ); } @@ -764,9 +799,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 }) ); } @@ -891,8 +930,10 @@ function isSimpleCallArgument(node, depth) { if (isCallLikeExpression(node)) { return ( - (node.type === "ImportExpression" || - isSimpleCallArgument(node.callee, depth)) && + ( + node.type === "ImportExpression" || + isSimpleCallArgument(node.callee, depth) + ) && getCallArguments(node).every(isChildSimple) ); } @@ -1237,14 +1278,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)) ); } @@ -1295,8 +1340,10 @@ function isCallLikeExpression(node) { function isObjectProperty(node) { return ( node && - (node.type === "ObjectProperty" || - (node.type === "Property" && !node.method && node.kind === "init")) + ( + node.type === "ObjectProperty" || + (node.type === "Property" && !node.method && node.kind === "init") + ) ); } diff --git ORI/prettier/src/language-markdown/clean.js ALT/prettier/src/language-markdown/clean.js index 60c3c7c..eabdcbd 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 1cd5f82..d5361ad 100644 --- ORI/prettier/src/language-markdown/printer-markdown.js +++ ALT/prettier/src/language-markdown/printer-markdown.js @@ -119,13 +119,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) => @@ -158,16 +160,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") ? "*" : "_"; } @@ -396,10 +402,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, @@ -848,8 +858,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 1cc85e2..68b5a1f 100644 --- ORI/prettier/src/language-markdown/utils.js +++ ALT/prettier/src/language-markdown/utils.js @@ -126,12 +126,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 98c7dcb..c83f9dc 100644 --- ORI/prettier/src/language-yaml/print/mapping-item.js +++ ALT/prettier/src/language-yaml/print/mapping-item.js @@ -101,15 +101,21 @@ function printMappingItem(node, parentNode, path, print, options) { const implicitMappingValueParts = [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 + ) ) { implicitMappingValueParts.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 272eb97..de91787 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 77d9615..e83985e 100644 --- ORI/prettier/src/main/comments.js +++ ALT/prettier/src/main/comments.js @@ -45,9 +45,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]) => @@ -58,7 +61,8 @@ function getSortedChildNodes(node, options, resultArray) { key !== "comments" && key !== "parent" ) - .map(([, value]) => value)); + .map(([, value]) => value) + ); if (!childNodes) { return; @@ -362,8 +366,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 27f21f7..0bbd2de 100644 --- ORI/prettier/src/main/options.js +++ ALT/prettier/src/main/options.js @@ -127,12 +127,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 ( diff --git ORI/prettier/src/main/range-util.js ALT/prettier/src/main/range-util.js index ecb396e..5864b08 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") + ) ); } ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: marmelab/react-admin@5ae855aa958ba54438b144bf0907b1437c5a5d77

Diff (133 lines) ```diff 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 7faf4a7..419dc53 100644 --- ORI/react-admin/packages/ra-core/src/controller/useListParams.ts +++ ALT/react-admin/packages/ra-core/src/controller/useListParams.ts @@ -321,11 +321,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 36f2961..538f423 100644 --- ORI/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx +++ ALT/react-admin/packages/ra-core/src/core/CoreAdminRouter.tsx @@ -116,8 +116,10 @@ const CoreAdminRouter = (props: AdminRouterProps) => { } 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-ui-materialui/src/list/datagrid/DatagridRow.tsx ALT/react-admin/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx index b91e267..fb4cfd6 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 @@ -70,9 +70,11 @@ const DatagridRow: FC = React.forwardRef((props, ref) => { const context = useDatagridContext(); const translate = useTranslate(); const expandable = - (!context || + ( + !context || !context.isRowExpandable || - context.isRowExpandable(record)) && + context.isRowExpandable(record) + ) && expand; const resource = useResourceContext(props); const [expanded, toggleExpanded] = useExpanded(resource, id); ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: typescript-eslint/typescript-eslint@9d47a8b94577540ae445e5ec17373da25423eeb8

Diff (1354 lines) ```diff 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 4a75edd..84084cc 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 @@ -133,11 +133,13 @@ export default util.createRule({ 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 a701e37..8c8e191 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 @@ -60,8 +60,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 29db2f3..9615c4e 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/dot-notation.ts @@ -86,9 +86,11 @@ export default createRule({ return { MemberExpression(node: TSESTree.MemberExpression): void { if ( - (allowPrivateClassPropertyAccess || + ( + allowPrivateClassPropertyAccess || allowProtectedClassPropertyAccess || - allowIndexSignaturePropertyAccess) && + allowIndexSignaturePropertyAccess + ) && node.computed ) { // for perf reasons - only fetch symbols if we have to @@ -98,10 +100,14 @@ export default createRule({ const modifierKind = propertySymbol?.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-function-return-type.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index 1f69834..5e33745 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -145,8 +145,10 @@ export default util.createRule({ if ( options.allowTypedFunctionExpressions && - (isValidFunctionExpressionReturnType(node, options) || - ancestorHasReturnType(node)) + ( + isValidFunctionExpressionReturnType(node, options) || + ancestorHasReturnType(node) + ) ) { 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 3f9f500..33179f5 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 @@ -396,8 +396,10 @@ export default util.createRule({ 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 fa7013b..638d7ff 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 @@ -538,20 +538,26 @@ export default createRule({ 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 ); @@ -937,8 +943,10 @@ export default createRule({ 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 ( @@ -1284,8 +1292,10 @@ export default createRule({ // 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); } @@ -1705,16 +1715,20 @@ export default createRule({ // 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/lines-between-class-members.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/lines-between-class-members.ts index 4446568..edce00d 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/lines-between-class-members.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/lines-between-class-members.ts @@ -47,8 +47,10 @@ export default util.createRule({ function isOverload(node: TSESTree.Node): boolean { return ( - (node.type === AST_NODE_TYPES.TSAbstractMethodDefinition || - node.type === AST_NODE_TYPES.MethodDefinition) && + ( + node.type === AST_NODE_TYPES.TSAbstractMethodDefinition || + node.type === AST_NODE_TYPES.MethodDefinition + ) && node.value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression ); } diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/member-ordering.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/member-ordering.ts index 92c794c..8c0d44b 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/member-ordering.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/member-ordering.ts @@ -410,10 +410,12 @@ function getRank( const decorated = 'decorators' in node && node.decorators!.length > 0; if ( decorated && - (type === 'field' || + ( + type === 'field' || type === 'method' || type === 'get' || - type === 'set') + type === 'set' + ) ) { memberGroups.push(`${accessibility}-decorated-${type}`); memberGroups.push(`decorated-${type}`); 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 cc2fa80..4721a17 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -176,9 +176,11 @@ export default util.createRule({ (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 cdea517..1111e36 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 @@ -100,9 +100,11 @@ export default util.createRule({ 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-inferrable-types.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-inferrable-types.ts index dc3216f..ec6ed48 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 @@ -118,8 +118,10 @@ export default util.createRule({ 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 cd28cfa..8c55dfc 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 @@ -136,12 +136,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 7d4a238..8de94a7 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 @@ -206,8 +206,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 c8c3ff2..1d2328f 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-namespace.ts @@ -49,8 +49,10 @@ export default util.createRule({ 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) + ) ); } @@ -59,8 +61,10 @@ export default util.createRule({ 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 d81c522..12a494b 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-redeclare.ts @@ -75,8 +75,10 @@ export default util.createRule({ 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-redundant-type-constituents.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts index 1ee8c3c..c9870d9 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts @@ -155,8 +155,10 @@ function isNodeInsideReturnType(node: TSESTree.TSUnionType): boolean { return !!( node.parent?.type === AST_NODE_TYPES.TSTypeAnnotation && node.parent.parent && - (util.isFunctionType(node.parent.parent) || - util.isFunction(node.parent.parent)) + ( + util.isFunctionType(node.parent.parent) || + util.isFunction(node.parent.parent) + ) ); } 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 3f13f58..d332d0f 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-shadow.ts @@ -98,9 +98,13 @@ export default util.createRule({ ): definition is ImportBindingDefinition { return ( definition?.type === DefinitionType.ImportBinding && - (definition.parent.importKind === 'type' || - (definition.node.type === AST_NODE_TYPES.ImportSpecifier && - definition.node.importKind === 'type')) + ( + definition.parent.importKind === 'type' || + ( + definition.node.type === AST_NODE_TYPES.ImportSpecifier && + definition.node.importKind === 'type' + ) + ) ); } @@ -177,8 +181,10 @@ export default util.createRule({ const functionExpr = typeParameterDecl.parent; if ( !functionExpr || - (functionExpr.type !== AST_NODE_TYPES.FunctionExpression && - functionExpr.type !== AST_NODE_TYPES.TSEmptyBodyFunctionExpression) + ( + functionExpr.type !== AST_NODE_TYPES.FunctionExpression && + functionExpr.type !== AST_NODE_TYPES.TSEmptyBodyFunctionExpression + ) ) { return false; } @@ -339,9 +345,13 @@ export default util.createRule({ inner && outer[0] < inner[0] && inner[1] < outer[1] && - ((innerDef.type === DefinitionType.FunctionName && - innerDef.node.type === AST_NODE_TYPES.FunctionExpression) || - innerDef.node.type === AST_NODE_TYPES.ClassExpression) && + ( + ( + innerDef.type === DefinitionType.FunctionName && + innerDef.node.type === AST_NODE_TYPES.FunctionExpression + ) || + innerDef.node.type === AST_NODE_TYPES.ClassExpression + ) && outerScope === innerScope.upper ); } @@ -377,9 +387,11 @@ export default util.createRule({ 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 + ) ); } @@ -452,8 +464,10 @@ export default util.createRule({ 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 2d9847e..4f83f90 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 @@ -148,11 +148,19 @@ export default util.createRule({ ): 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) + ) + ) + ) ); } @@ -280,11 +288,17 @@ export default util.createRule({ } else if ( type.node.type.endsWith(AST_TOKEN_TYPES.Keyword) || aliasTypes.has(type.node.type) || - (type.node.type === AST_NODE_TYPES.TSTypeOperator && - (type.node.operator === 'keyof' || - (type.node.operator === 'readonly' && + ( + type.node.type === AST_NODE_TYPES.TSTypeOperator && + ( + type.node.operator === 'keyof' || + ( + 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 4e18a9f..b99891a 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 @@ -186,11 +186,15 @@ export default createRule({ 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 + ) + ) ); } @@ -344,10 +348,14 @@ export default createRule({ }; 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)) ) { @@ -425,8 +433,10 @@ export default createRule({ 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: @@ -520,10 +530,14 @@ export default createRule({ } 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 dae2174..7494d14 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 @@ -158,8 +158,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 38c9b26..bb9c2ee 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 @@ -243,9 +243,13 @@ export default util.createRule({ 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 56eb152..8d08312 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 @@ -45,8 +45,10 @@ export default util.createRule({ ); } 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 3a5b519..34c4cdf 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 @@ -190,8 +190,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; @@ -317,8 +319,10 @@ export default util.createRule({ 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/object-curly-spacing.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/object-curly-spacing.ts index c64ca54..5368051 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({ 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/padding-line-between-statements.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/padding-line-between-statements.ts index bc5f30a..ac7aabd 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/padding-line-between-statements.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/padding-line-between-statements.ts @@ -207,8 +207,10 @@ function isBlockLikeStatement( return ( !!belongingNode && - (belongingNode.type === AST_NODE_TYPES.BlockStatement || - belongingNode.type === AST_NODE_TYPES.SwitchStatement) + ( + belongingNode.type === AST_NODE_TYPES.BlockStatement || + belongingNode.type === AST_NODE_TYPES.SwitchStatement + ) ); } @@ -224,9 +226,13 @@ function isDirective( ): boolean { return ( node.type === AST_NODE_TYPES.ExpressionStatement && - (node.parent?.type === AST_NODE_TYPES.Program || - (node.parent?.type === AST_NODE_TYPES.BlockStatement && - util.isFunction(node.parent.parent))) && + ( + node.parent?.type === AST_NODE_TYPES.Program || + ( + node.parent?.type === AST_NODE_TYPES.BlockStatement && + util.isFunction(node.parent.parent) + ) + ) && node.expression.type === AST_NODE_TYPES.Literal && typeof node.expression.value === 'string' && !util.isParenthesized(node.expression, sourceCode) @@ -279,10 +285,14 @@ function isCJSExport(node: TSESTree.Node): boolean { } return ( left.object.type === AST_NODE_TYPES.Identifier && - (left.object.name === 'exports' || - (left.object.name === 'module' && + ( + left.object.name === 'exports' || + ( + left.object.name === 'module' && left.property.type === AST_NODE_TYPES.Identifier && - left.property.name === 'exports')) + left.property.name === 'exports' + ) + ) ); } } 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 3355fda..37dc659 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 @@ -85,10 +85,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) + ) + ) ); } } @@ -168,12 +174,14 @@ export default util.createRule({ const node = id.parent; return ( !contains(body, id) || - (node !== undefined && + ( + node !== undefined && node.type === AST_NODE_TYPES.MemberExpression && node.object.type !== AST_NODE_TYPES.ThisExpression && 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 d13d187..44b26ca 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 @@ -80,8 +80,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-literal-enum-member.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts index f64482a..4d4f8bb 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts @@ -53,8 +53,10 @@ export default createRule({ if ( node.initializer.type === AST_NODE_TYPES.UnaryExpression && node.initializer.argument.type === AST_NODE_TYPES.Literal && - (['+', '-'].includes(node.initializer.operator) || - (allowBitwiseExpressions && node.initializer.operator === '~')) + ( + ['+', '-'].includes(node.initializer.operator) || + (allowBitwiseExpressions && node.initializer.operator === '~') + ) ) { return; } 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 b492287..08703a4 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 109deaa..e318d4c 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 @@ -361,8 +361,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 1959726..d2efb5c 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-readonly.ts @@ -113,8 +113,10 @@ export default util.createRule({ 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-regexp-exec.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts index 07c98a6..1fc74e7 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts @@ -112,9 +112,11 @@ export default createRule({ // Don't report regular expressions with global flag. if ( (!argumentValue && isLikelyToContainGlobalFlag(argumentNode)) || - (argumentValue && + ( + argumentValue && argumentValue.value instanceof RegExp && - argumentValue.value.flags.includes('g')) + argumentValue.value.flags.includes('g') + ) ) { return; } 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 501693e..6ba5aa2 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 @@ -172,11 +172,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) + ) ); } @@ -565,9 +569,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 && @@ -588,8 +596,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; } @@ -603,14 +613,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 bf49764..f8c0d21 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 @@ -126,8 +126,10 @@ export default util.createRule({ 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 @@ -152,9 +154,13 @@ export default util.createRule({ 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 6c6995d..bfb4d28 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 @@ -82,8 +82,10 @@ export default util.createRule({ 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/typedef.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts index 89ef30f..4464d16 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts @@ -144,8 +144,10 @@ export default util.createRule<[Options], MessageIds>({ function isVariableDeclarationIgnoreFunction(node: TSESTree.Node): boolean { return ( variableDeclarationIgnoreFunction === true && - (node.type === AST_NODE_TYPES.ArrowFunctionExpression || - node.type === AST_NODE_TYPES.FunctionExpression) + ( + node.type === AST_NODE_TYPES.ArrowFunctionExpression || + node.type === AST_NODE_TYPES.FunctionExpression + ) ); } @@ -239,10 +241,14 @@ export default util.createRule<[Options], MessageIds>({ if ( !variableDeclaration || node.id.typeAnnotation || - (node.id.type === AST_NODE_TYPES.ArrayPattern && - !arrayDestructuring) || - (node.id.type === AST_NODE_TYPES.ObjectPattern && - !objectDestructuring) || + ( + node.id.type === AST_NODE_TYPES.ArrayPattern && + !arrayDestructuring + ) || + ( + node.id.type === AST_NODE_TYPES.ObjectPattern && + !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 2dd6aaf..085478f 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/unbound-method.ts @@ -328,11 +328,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 b5a1d8a..1519679 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/unified-signatures.ts @@ -417,10 +417,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) + ) ); } @@ -561,8 +563,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 6fe14b0..08bd995 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/util/collectUnusedVariables.ts @@ -406,8 +406,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; @@ -464,8 +466,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); } @@ -700,14 +704,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/getWrappingFixer.ts ALT/typescript-eslint/packages/eslint-plugin/src/util/getWrappingFixer.ts index af7885e..375e373 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/util/getWrappingFixer.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/util/getWrappingFixer.ts @@ -111,8 +111,10 @@ function isWeakPrecedenceParent(node: TSESTree.Node): boolean { } if ( - (parent.type === AST_NODE_TYPES.CallExpression || - parent.type === AST_NODE_TYPES.NewExpression) && + ( + parent.type === AST_NODE_TYPES.CallExpression || + parent.type === AST_NODE_TYPES.NewExpression + ) && parent.callee === node ) { return true; @@ -178,9 +180,11 @@ function isLeftHandSide(node: TSESTree.Node): boolean { // a + b if ( - (parent.type === AST_NODE_TYPES.BinaryExpression || + ( + parent.type === AST_NODE_TYPES.BinaryExpression || parent.type === AST_NODE_TYPES.LogicalExpression || - parent.type === AST_NODE_TYPES.AssignmentExpression) && + parent.type === AST_NODE_TYPES.AssignmentExpression + ) && node === parent.left ) { return true; diff --git ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts index 8479feb..c281f65 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts @@ -49,10 +49,12 @@ function arraysAreEqual( ): 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/scope-manager/src/referencer/ClassVisitor.ts ALT/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts index 6f50504..0945be6 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 f0fb7d3..702383f 100644 --- ORI/typescript-eslint/packages/typescript-estree/src/convert.ts +++ ALT/typescript-eslint/packages/typescript-estree/src/convert.ts @@ -1157,9 +1157,11 @@ export class Converter { } if ( - (node.name.kind === SyntaxKind.Identifier || + ( + node.name.kind === SyntaxKind.Identifier || node.name.kind === SyntaxKind.ComputedPropertyName || - node.name.kind === SyntaxKind.PrivateIdentifier) && + node.name.kind === SyntaxKind.PrivateIdentifier + ) && 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 d8182aa..d4ff5ad 100644 --- ORI/typescript-eslint/packages/typescript-estree/src/node-utils.ts +++ ALT/typescript-eslint/packages/typescript-estree/src/node-utils.ts @@ -94,9 +94,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 ); } @@ -487,8 +489,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 8867e8a..104e87f 100644 --- ORI/typescript-eslint/packages/typescript-estree/src/parser.ts +++ ALT/typescript-eslint/packages/typescript-estree/src/parser.ts @@ -83,11 +83,15 @@ function getProgramAndAST( ): ASTAndProgram { return ( (programInstances && useProvidedPrograms(programInstances, extra)) || - (shouldProvideParserServices && - createProjectProgram(code, shouldCreateDefaultProgram, extra)) || - (shouldProvideParserServices && + ( + shouldProvideParserServices && + createProjectProgram(code, shouldCreateDefaultProgram, extra) + ) || + ( + shouldProvideParserServices && shouldCreateDefaultProgram && - createDefaultProgram(code, extra)) || + createDefaultProgram(code, extra) + ) || createIsolatedProgram(code, extra) ); } diff --git ORI/typescript-eslint/packages/utils/src/ast-utils/predicates.ts ALT/typescript-eslint/packages/utils/src/ast-utils/predicates.ts index 10e5052..b2e5612 100644 --- ORI/typescript-eslint/packages/utils/src/ast-utils/predicates.ts +++ ALT/typescript-eslint/packages/utils/src/ast-utils/predicates.ts @@ -119,8 +119,10 @@ function isSetter( ): node is (TSESTree.MethodDefinition | TSESTree.Property) & { kind: 'set' } { 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' ); } ```
github-actions[bot] commented 2 years ago

prettier/prettier#11103 VS prettier/prettier@main :: vega/vega-lite@16bc9138a2470274f2a2e6c964b9a03822c7dd5c

diff --git ORI/vega-lite/src/mark.ts ALT/vega-lite/src/mark.ts
index 5a27f5d..1270686 100644
--- ORI/vega-lite/src/mark.ts
+++ ALT/vega-lite/src/mark.ts
@@ -599,8 +599,10 @@ export interface RelativeBandSize {
 }

 // Point/Line OverlayMixins are only for area, line, and trail but we don't want to declare multiple types of MarkDef
-export interface MarkDef<M extends string | Mark = Mark, ES extends ExprRef | SignalRef = ExprRef | SignalRef>
-  extends GenericMarkDef<M>,
+export interface MarkDef<
+  M extends string | Mark = Mark,
+  ES extends ExprRef | SignalRef = ExprRef | SignalRef
+> extends GenericMarkDef<M>,
     Omit<
       MarkConfig<ES> &
         AreaConfig<ES> &
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);
           }