Skip to content

Commit b2d9156

Browse files
authored
Update to Prettier 2.3 (#13288)
1 parent 5ae3a6c commit b2d9156

45 files changed

Lines changed: 262 additions & 364 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint/babel-eslint-parser/src/convert/convertTokens.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { tokTypes } from "@babel/core";
22

3-
const tl = (process.env.BABEL_8_BREAKING
4-
? Object.fromEntries
5-
: p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {}))(
6-
Object.keys(tokTypes).map(key => [key, tokTypes[key].label]),
7-
);
3+
const tl = (
4+
process.env.BABEL_8_BREAKING
5+
? Object.fromEntries
6+
: p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {})
7+
)(Object.keys(tokTypes).map(key => [key, tokTypes[key].label]));
88

99
function convertTemplateType(tokens) {
1010
let curlyBrace = null;

eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js

Lines changed: 66 additions & 132 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"lint-staged": "^9.2.0",
6464
"lodash": "^4.17.21",
6565
"mergeiterator": "^1.2.5",
66-
"prettier": "^2.2.1",
66+
"prettier": "2.3.0",
6767
"rollup": "^2.47.0",
6868
"rollup-plugin-dts": "^2.0.0",
6969
"rollup-plugin-node-polyfills": "^0.2.1",

packages/babel-core/src/config/caching.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function updateFunctionCache<
208208
ArgT,
209209
ResultT,
210210
SideChannel,
211-
Cache extends CacheMap<ArgT, ResultT, SideChannel>
211+
Cache extends CacheMap<ArgT, ResultT, SideChannel>,
212212
>(
213213
cache: Cache,
214214
config: CacheConfigurator<SideChannel>,

packages/babel-core/src/config/config-chain.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ function buildOverrideEnvDescriptors(
497497
}
498498

499499
function makeChainWalker<
500-
ArgT extends { options: ValidatedOptions; dirname: string }
500+
ArgT extends { options: ValidatedOptions; dirname: string },
501501
>({
502502
root,
503503
env,
@@ -582,8 +582,12 @@ function makeChainWalker<
582582
// that we don't do extra work loading extended configs if a file is
583583
// ignored.
584584
if (
585-
flattenedConfigs.some(({ config: { options: { ignore, only } } }) =>
586-
shouldIgnore(context, ignore, only, dirname),
585+
flattenedConfigs.some(
586+
({
587+
config: {
588+
options: { ignore, only },
589+
},
590+
}) => shouldIgnore(context, ignore, only, dirname),
587591
)
588592
) {
589593
return null;
@@ -713,10 +717,8 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
713717
function dedupDescriptors(
714718
items: Array<UnloadedDescriptor>,
715719
): Array<UnloadedDescriptor> {
716-
const map: Map<
717-
Function,
718-
Map<string | void, { value: UnloadedDescriptor }>
719-
> = new Map();
720+
const map: Map<Function, Map<string | void, { value: UnloadedDescriptor }>> =
721+
new Map();
720722

721723
const descriptors = [];
722724

packages/babel-core/src/config/files/configuration.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ const readConfigJS = makeStrongCache(function* readConfigJS(
205205
// @ts-expect-error - if we want to make it possible to use async configs
206206
yield* [];
207207

208-
options = ((options as any) as (api: ConfigAPI) => {})(
209-
makeConfigAPI(cache),
210-
);
208+
options = (options as any as (api: ConfigAPI) => {})(makeConfigAPI(cache));
211209

212210
assertCache = true;
213211
}
@@ -256,32 +254,30 @@ const packageToBabelConfig = makeWeakCacheSync(
256254
},
257255
);
258256

259-
const readConfigJSON5 = makeStaticFileCache(
260-
(filepath, content): ConfigFile => {
261-
let options;
262-
try {
263-
options = json5.parse(content);
264-
} catch (err) {
265-
err.message = `${filepath}: Error while parsing config - ${err.message}`;
266-
throw err;
267-
}
257+
const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => {
258+
let options;
259+
try {
260+
options = json5.parse(content);
261+
} catch (err) {
262+
err.message = `${filepath}: Error while parsing config - ${err.message}`;
263+
throw err;
264+
}
268265

269-
if (!options) throw new Error(`${filepath}: No config detected`);
266+
if (!options) throw new Error(`${filepath}: No config detected`);
270267

271-
if (typeof options !== "object") {
272-
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
273-
}
274-
if (Array.isArray(options)) {
275-
throw new Error(`${filepath}: Expected config object but found array`);
276-
}
268+
if (typeof options !== "object") {
269+
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
270+
}
271+
if (Array.isArray(options)) {
272+
throw new Error(`${filepath}: Expected config object but found array`);
273+
}
277274

278-
return {
279-
filepath,
280-
dirname: path.dirname(filepath),
281-
options,
282-
};
283-
},
284-
);
275+
return {
276+
filepath,
277+
dirname: path.dirname(filepath),
278+
options,
279+
};
280+
});
285281

286282
const readIgnoreConfig = makeStaticFileCache((filepath, content) => {
287283
const ignoreDir = path.dirname(filepath);

packages/babel-core/src/config/files/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type indexType = typeof import("./index");
33

44
// Kind of gross, but essentially asserting that the exports of this module are the same as the
55
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
6-
((({} as any) as indexBrowserType) as indexType);
6+
({} as any as indexBrowserType as indexType);
77

88
export { findPackageData } from "./package";
99

packages/babel-core/src/config/files/plugins.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
1717
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
1818
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
1919
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
20-
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
21-
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
20+
const OTHER_PLUGIN_ORG_RE =
21+
/^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
22+
const OTHER_PRESET_ORG_RE =
23+
/^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
2224
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
2325

2426
export function resolvePlugin(name: string, dirname: string): string | null {

packages/babel-core/src/config/full.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,10 @@ const makeDescriptorLoader = <Context, API>(
279279
return { value: item, options, dirname, alias };
280280
});
281281

282-
const pluginDescriptorLoader = makeDescriptorLoader<
283-
Context.SimplePlugin,
284-
PluginAPI
285-
>(makePluginAPI);
286-
const presetDescriptorLoader = makeDescriptorLoader<
287-
Context.SimplePreset,
288-
PresetAPI
289-
>(makePresetAPI);
282+
const pluginDescriptorLoader =
283+
makeDescriptorLoader<Context.SimplePlugin, PluginAPI>(makePluginAPI);
284+
const presetDescriptorLoader =
285+
makeDescriptorLoader<Context.SimplePreset, PresetAPI>(makePresetAPI);
290286

291287
/**
292288
* Instantiate a plugin for the given descriptor, returning the plugin/options pair.

packages/babel-core/src/config/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ const loadOptionsRunner = gensync<(opts: unknown) => any>(function* (opts) {
2424
return config?.options ?? null;
2525
});
2626

27-
const createConfigItemRunner = gensync<
28-
(...args: Parameters<typeof createConfigItemImpl>) => ConfigItem
29-
>(createConfigItemImpl);
27+
const createConfigItemRunner =
28+
gensync<(...args: Parameters<typeof createConfigItemImpl>) => ConfigItem>(
29+
createConfigItemImpl,
30+
);
3031

3132
const maybeErrback = runner => (opts: unknown, callback?: Function) => {
3233
if (callback === undefined && typeof opts === "function") {

0 commit comments

Comments
 (0)