diff --git a/package.json b/package.json index 4d6312270618..9e457285e980 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "lint-staged": "^9.2.0", "lodash": "^4.17.20", "mergeiterator": "^1.2.5", - "prettier": "^2.0.5", + "prettier": "^2.2.1", "rollup": "^2.26.5", "rollup-plugin-dts": "^2.0.0", "rollup-plugin-node-polyfills": "^0.2.1", diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index 9e04d85a623a..d715b63862a6 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -167,16 +167,17 @@ describe("api", function () { babelrc: false, }; Object.freeze(options); - transformFile(__dirname + "/fixtures/api/file.js", options, function ( - err, - res, - ) { - if (err) return done(err); - expect(res.code).toBe("foo();"); - // keep user options untouched - expect(options).toEqual({ babelrc: false }); - done(); - }); + transformFile( + __dirname + "/fixtures/api/file.js", + options, + function (err, res) { + if (err) return done(err); + expect(res.code).toBe("foo();"); + // keep user options untouched + expect(options).toEqual({ babelrc: false }); + done(); + }, + ); }); it("transformFileSync", function () { diff --git a/packages/babel-traverse/src/path/ancestry.js b/packages/babel-traverse/src/path/ancestry.js index 758def8e5509..73ab074b9f3f 100644 --- a/packages/babel-traverse/src/path/ancestry.js +++ b/packages/babel-traverse/src/path/ancestry.js @@ -78,43 +78,42 @@ export function getStatementParent(): NodePath { export function getEarliestCommonAncestorFrom( paths: Array, ): NodePath { - return this.getDeepestCommonAncestorFrom(paths, function ( - deepest, - i, - ancestries, - ) { - let earliest; - const keys = t.VISITOR_KEYS[deepest.type]; + return this.getDeepestCommonAncestorFrom( + paths, + function (deepest, i, ancestries) { + let earliest; + const keys = t.VISITOR_KEYS[deepest.type]; - for (const ancestry of (ancestries: Array)) { - const path = ancestry[i + 1]; - - // first path - if (!earliest) { - earliest = path; - continue; - } + for (const ancestry of (ancestries: Array)) { + const path = ancestry[i + 1]; - // handle containers - if (path.listKey && earliest.listKey === path.listKey) { - // we're in the same container so check if we're earlier - if (path.key < earliest.key) { + // first path + if (!earliest) { earliest = path; continue; } - } - // handle keys - const earliestKeyIndex = keys.indexOf(earliest.parentKey); - const currentKeyIndex = keys.indexOf(path.parentKey); - if (earliestKeyIndex > currentKeyIndex) { - // key appears before so it's earlier - earliest = path; + // handle containers + if (path.listKey && earliest.listKey === path.listKey) { + // we're in the same container so check if we're earlier + if (path.key < earliest.key) { + earliest = path; + continue; + } + } + + // handle keys + const earliestKeyIndex = keys.indexOf(earliest.parentKey); + const currentKeyIndex = keys.indexOf(path.parentKey); + if (earliestKeyIndex > currentKeyIndex) { + // key appears before so it's earlier + earliest = path; + } } - } - return earliest; - }); + return earliest; + }, + ); } /** diff --git a/yarn.lock b/yarn.lock index 5a1cb88ca4df..9c3d776a61b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4857,7 +4857,7 @@ __metadata: lint-staged: ^9.2.0 lodash: ^4.17.20 mergeiterator: ^1.2.5 - prettier: ^2.0.5 + prettier: ^2.2.1 rollup: ^2.26.5 rollup-plugin-dts: ^2.0.0 rollup-plugin-node-polyfills: ^0.2.1 @@ -10860,12 +10860,12 @@ fsevents@^1.2.7: languageName: node linkType: hard -"prettier@npm:^2.0.5": - version: 2.0.5 - resolution: "prettier@npm:2.0.5" +"prettier@npm:^2.2.1": + version: 2.2.1 + resolution: "prettier@npm:2.2.1" bin: prettier: bin-prettier.js - checksum: d249d89361870a29b20e8b268cb09e908490b8c9e21f70393d12a213701f29ba7e95b7f9ce0ad63929c16ce475176742481911737ae3da4a498873e4a3b90990 + checksum: 92c6c9f4b87eba1f28466edee57dd18c80d00b858edda77d46d1950d20e6e302b68ee255fc91133ba931e63c4577b5ae30da194d9626a8f3c0177778b91bf056 languageName: node linkType: hard