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 e368442 commit 6bef2e9
Show file tree
Hide file tree
Showing 40 changed files with 228 additions and 280 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default declare(({ types: t, template, assertVersion }) => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-class-static-block").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-class-static-block").default,

pre() {
// Enable this in @babel/helper-create-class-features-plugin, so that it
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-dynamic-import/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-dynamic-import").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-dynamic-import").default,

pre() {
// We keep using the old name, for compatibility with older
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-export-namespace-from").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-export-namespace-from").default,

visitor: {
ExportNamedDeclaration(path) {
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-json-strings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-json-strings").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-json-strings").default,

visitor: {
"DirectiveLiteral|StringLiteral"({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-logical-assignment-operators").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-logical-assignment-operators").default,

visitor: {
AssignmentExpression(path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default declare((api, { loose = false }: Options) => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-nullish-coalescing-operator").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-nullish-coalescing-operator").default,

visitor: {
LogicalExpression(path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-numeric-separator").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-numeric-separator").default,

visitor: {
NumericLiteral: remover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ export default declare((api, opts: Options) => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-object-rest-spread").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-object-rest-spread").default,

visitor: {
// function a({ b, ...c }) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default declare(api => {
inherits: USE_ESM
? undefined
: IS_STANDALONE
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-optional-catch-binding").default,
? undefined
: // eslint-disable-next-line no-restricted-globals
require("@babel/plugin-syntax-optional-catch-binding").default,

visitor: {
CatchClause(path) {
Expand Down

0 comments on commit 6bef2e9

Please sign in to comment.