Skip to content

Commit

Permalink
Use prettier 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 13, 2023
1 parent 210616f commit f3e64c4
Show file tree
Hide file tree
Showing 42 changed files with 260 additions and 308 deletions.
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ function pluginToggleBooleanFlag({ types: t }, { name, value }) {
return arg.unrelated
? res.unrelated()
: arg.replacement
? res.replacement(t.unaryExpression("!", arg.replacement))
: res.value(!arg.value);
? res.replacement(t.unaryExpression("!", arg.replacement))
: res.value(!arg.value);
}

if (test.isLogicalExpression({ operator: "||" })) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"jest-worker": "^30.0.0-alpha.1",
"lint-staged": "^14.0.1",
"mergeiterator": "^1.4.4",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"rollup": "^3.28.1",
"rollup-plugin-dts": "^6.0.0",
"rollup-plugin-dts-5": "npm:rollup-plugin-dts@^5.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-cli/src/babel/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ function requireChokidar(): any {
return process.env.BABEL_8_BREAKING
? require("chokidar")
: parseInt(process.versions.node) >= 8
? require("chokidar")
: require("@nicolo-ribaudo/chokidar-2");
? require("chokidar")
: require("@nicolo-ribaudo/chokidar-2");
} catch (err) {
console.error(
"The optional dependency chokidar failed to install and is required for " +
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-generator/src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,8 +1186,8 @@ class Printer {
i === 0
? COMMENT_SKIP_NEWLINE.LEADING
: i === len - 1
? COMMENT_SKIP_NEWLINE.TRAILING
: COMMENT_SKIP_NEWLINE.DEFAULT,
? COMMENT_SKIP_NEWLINE.TRAILING
: COMMENT_SKIP_NEWLINE.DEFAULT,
);
} else {
this._printComment(comment, COMMENT_SKIP_NEWLINE.DEFAULT);
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-helper-fixtures/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ function pushTask(
filename: !loc
? undefined
: fileName === true
? suiteName + "/" + taskName + "/" + path.basename(loc)
: fileName || undefined,
? suiteName + "/" + taskName + "/" + path.basename(loc)
: fileName || undefined,
};
}

Expand Down
8 changes: 4 additions & 4 deletions packages/babel-helper-string-parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ export function readInt(
radix === 16
? isAllowedNumericSeparatorSibling.hex
: radix === 10
? isAllowedNumericSeparatorSibling.dec
: radix === 8
? isAllowedNumericSeparatorSibling.oct
: isAllowedNumericSeparatorSibling.bin;
? isAllowedNumericSeparatorSibling.dec
: radix === 8
? isAllowedNumericSeparatorSibling.oct
: isAllowedNumericSeparatorSibling.bin;

let invalid = false;
let total = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-helpers/src/helpers/applyDecs2301.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ function applyDecs2301Factory() {
get && set
? { get: get, set: set, has: has }
: get
? { get: get, has: has }
: { set: set, has: has };
? { get: get, has: has }
: { set: set, has: has };

try {
return dec(value, ctx);
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-helpers/src/helpers/applyDecs2305.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ function memberDec(
get && set
? { get: get, set: set, has: has }
: get
? { get: get, has: has }
: { set: set, has: has };
? { get: get, has: has }
: { set: set, has: has };

try {
return dec.call(thisArg, value, ctx);
Expand Down
12 changes: 6 additions & 6 deletions packages/babel-parser/src/parse-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export function ParseErrorEnum(a: TemplateStringsArray): <
? Parameters<T[K]["message"]>[0]
: {}
: T[K] extends ToMessage<any>
? Parameters<T[K]>[0]
: {}
? Parameters<T[K]>[0]
: {}
>;
};

Expand All @@ -154,8 +154,8 @@ export function ParseErrorEnum<T extends ParseErrorTemplates>(
? Parameters<T[K]["message"]>[0]
: {}
: T[K] extends ToMessage<any>
? Parameters<T[K]>[0]
: {}
? Parameters<T[K]>[0]
: {}
>;
};

Expand Down Expand Up @@ -200,8 +200,8 @@ export function ParseErrorEnum(
typeof template === "string"
? { message: () => template }
: typeof template === "function"
? { message: template }
: template;
? { message: template }
: template;
const toMessage = typeof message === "string" ? () => message : message;

ParseErrorConstructors[reasonCode] = toParseErrorConstructor({
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/src/parser/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2835,8 +2835,8 @@ export default abstract class ExpressionParser extends LValParser {
const reservedTest = !this.state.strict
? isReservedWord
: isBinding
? isStrictBindReservedWord
: isStrictReservedWord;
? isStrictBindReservedWord
: isStrictReservedWord;

if (reservedTest(word, this.inModule)) {
this.raise(Errors.UnexpectedReservedWord, {
Expand Down
20 changes: 10 additions & 10 deletions packages/babel-parser/src/parser/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ export default abstract class StatementParser extends ExpressionParser {
this.state.strict
? Errors.StrictFunction
: this.options.annexB
? Errors.SloppyFunctionAnnexB
: Errors.SloppyFunction,
? Errors.SloppyFunctionAnnexB
: Errors.SloppyFunction,
{ at: this.state.startLoc },
);
}
Expand Down Expand Up @@ -1276,8 +1276,8 @@ export default abstract class StatementParser extends ExpressionParser {
const kind = tokenIsLoop(this.state.type)
? "loop"
: this.match(tt._switch)
? "switch"
: null;
? "switch"
: null;
for (let i = this.state.labels.length - 1; i >= 0; i--) {
const label = this.state.labels[i];
if (label.statementStart === node.start) {
Expand Down Expand Up @@ -1536,8 +1536,8 @@ export default abstract class StatementParser extends ExpressionParser {
decl.init = !this.eat(tt.eq)
? null
: isFor
? this.parseMaybeAssignDisallowIn()
: this.parseMaybeAssignAllowIn();
? this.parseMaybeAssignDisallowIn()
: this.parseMaybeAssignAllowIn();

if (decl.init === null && !allowMissingInitializer) {
if (
Expand Down Expand Up @@ -2228,10 +2228,10 @@ export default abstract class StatementParser extends ExpressionParser {
? ClassElementType.STATIC_GETTER
: ClassElementType.INSTANCE_GETTER
: node.kind === "set"
? node.static
? ClassElementType.STATIC_SETTER
: ClassElementType.INSTANCE_SETTER
: ClassElementType.OTHER;
? node.static
? ClassElementType.STATIC_SETTER
: ClassElementType.INSTANCE_SETTER
: ClassElementType.OTHER;
this.declareClassPrivateMethodInScope(node, kind);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/src/plugins/flow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3407,8 +3407,8 @@ export default (superClass: typeof Parser) =>
!enumContext.explicitType
? FlowErrors.EnumInvalidMemberInitializerUnknownType
: enumContext.explicitType === "symbol"
? FlowErrors.EnumInvalidMemberInitializerSymbolType
: FlowErrors.EnumInvalidMemberInitializerPrimaryType,
? FlowErrors.EnumInvalidMemberInitializerSymbolType
: FlowErrors.EnumInvalidMemberInitializerPrimaryType,
{
at: loc,
...enumContext,
Expand Down
16 changes: 8 additions & 8 deletions packages/babel-parser/src/plugins/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,8 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
type === tt._void
? "TSVoidKeyword"
: type === tt._null
? "TSNullKeyword"
: keywordTypeFromName(this.state.value);
? "TSNullKeyword"
: keywordTypeFromName(this.state.value);
if (
nodeType !== undefined &&
this.lookaheadCharCode() !== charCodes.dot
Expand Down Expand Up @@ -1378,10 +1378,10 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
return isTypeOperator
? this.tsParseTypeOperator()
: this.isContextual(tt._infer)
? this.tsParseInferType()
: this.tsInAllowConditionalTypesContext(() =>
this.tsParseArrayTypeOrHigher(),
);
? this.tsParseInferType()
: this.tsInAllowConditionalTypesContext(() =>
this.tsParseArrayTypeOrHigher(),
);
}

tsParseUnionOrIntersectionType(
Expand Down Expand Up @@ -2377,8 +2377,8 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
type === "FunctionDeclaration"
? "TSDeclareFunction"
: type === "ClassMethod" || type === "ClassPrivateMethod"
? "TSDeclareMethod"
: undefined;
? "TSDeclareMethod"
: undefined;
if (bodilessType && !this.match(tt.braceL) && this.isLineTerminator()) {
return this.finishNode(node, bodilessType);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/src/tokenizer/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default class State {
strictMode === false
? false
: strictMode === true
? true
: sourceType === "module";
? true
: sourceType === "module";

this.curLine = startLine;
this.lineStart = -startColumn;
Expand Down
36 changes: 18 additions & 18 deletions packages/babel-parser/test/helpers/difference.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const toType = value =>
value === null
? "null"
: typeof value !== "object"
? typeof value
: isArray(value)
? "Array"
: value instanceof RegExp
? "RegExp"
: value instanceof Error
? "Error"
: "Object";
? typeof value
: isArray(value)
? "Array"
: value instanceof RegExp
? "RegExp"
: value instanceof Error
? "Error"
: "Object";

function compare(adjust, expected, actual) {
// easy.
Expand Down Expand Up @@ -126,21 +126,21 @@ const toValueString = (value, type = toType(value)) =>
type === "string"
? JSON.stringify(value)
: type === "symbol"
? value.toString()
: type === "bigint"
? `${value}n`
: Object.is(value, -0)
? "-0"
: value + "";
? value.toString()
: type === "bigint"
? `${value}n`
: Object.is(value, -0)
? "-0"
: value + "";

const toExplanationString = ({ discrepancy, expected, actual, key }) =>
discrepancy === "length"
? `Array of wrong size, expected length of ${expected}, but got ${actual}`
: discrepancy === "unexpected-key"
? `Did not expect a property ${toValueString(key)}`
: discrepancy === "missing-key"
? `${toType(actual)} is missing property ${toValueString(key)}`
: `${toValueString(expected)} != ${toValueString(actual)}`;
? `Did not expect a property ${toValueString(key)}`
: discrepancy === "missing-key"
? `${toType(actual)} is missing property ${toValueString(key)}`
: `${toValueString(expected)} != ${toValueString(actual)}`;

const isInt = key => isInteger(+key);
const toAccess = key =>
Expand Down
24 changes: 14 additions & 10 deletions packages/babel-parser/test/helpers/fixture-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,20 @@ export default class FixtureError extends Error {
return difference === Difference.None
? false
: difference.path[0] !== "threw"
? new FixtureError.DifferentAST(difference)
: !difference.expected
? new FixtureError.UnexpectedError(difference, { cause: actual.threw })
: difference.actual
? new FixtureError.DifferentError(difference, { cause: actual.threw })
: actual.ast && actual.ast.errors
? new FixtureError.UnexpectedRecovery(difference, {
cause: actual.ast.errors,
})
: new FixtureError.UnexpectedSuccess(difference);
? new FixtureError.DifferentAST(difference)
: !difference.expected
? new FixtureError.UnexpectedError(difference, {
cause: actual.threw,
})
: difference.actual
? new FixtureError.DifferentError(difference, {
cause: actual.threw,
})
: actual.ast && actual.ast.errors
? new FixtureError.UnexpectedRecovery(difference, {
cause: actual.ast.errors,
})
: new FixtureError.UnexpectedSuccess(difference);
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/babel-parser/test/helpers/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const deserialize = (filename, options, string) =>
!value[SerializationKey]
? value
: value[SerializationKey] === "RegExp"
? new RegExp(value.source, value.flags)
: toBigInt(value.value)),
? new RegExp(value.source, value.flags)
: toBigInt(value.value)),
),
);

Expand Down Expand Up @@ -88,10 +88,10 @@ export function serialize(value) {
typeof value === "bigint"
? toExtended("bigint", { value: value + "" })
: value instanceof RegExp
? toExtended("RegExp", { source: value.source, flags: value.flags })
: value instanceof Error
? value + ""
: value;
? toExtended("RegExp", { source: value.source, flags: value.flags })
: value instanceof Error
? value + ""
: value;
const serialized = stringify(value, encode, 2).replace(
CompactRegExp,
// This is safe since none of the values can have spaces in them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-async-generators").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-async-generators").default,

visitor: {
Program(path, state) {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-transform-block-scoping/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default declare((api, opts: Options) => {
const headPath = isForStatement
? path.get("init")
: path.isForXStatement()
? path.get("left")
: null;
? path.get("left")
: null;

let needsBodyWrap = false;
const markNeedsBodyWrap = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-transform-block-scoping/src/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function getUsageInBody(binding: Binding, loopPath: NodePath<t.Loop>) {
const id = path.isUpdateExpression()
? path.get("argument")
: path.isAssignmentExpression()
? path.get("left")
: null;
? path.get("left")
: null;
if (id) seen.add(id.node);
return id as NodePath<t.Identifier> | null;
});
Expand Down
Loading

0 comments on commit f3e64c4

Please sign in to comment.