Updates prettier to latest version. (#51000)

There are some incoming docs / MDX changes where prettier will throw an error when using the older version. Updating prettier before I bring in those changes.

Looks like the most notable change is adding parentheses around `typeof` checks in TypeScript. 

**Before**

```
export type Locale = typeof i18n['locales'][number]
```

**After**

```
export type Locale = (typeof i18n)['locales'][number]
```
This commit is contained in:
Michael Novotny
2023-06-09 14:58:19 +00:00
committed by GitHub
parent 2a2890cae6
commit 55b29fb351
26 changed files with 51 additions and 63 deletions
+1
View File
@@ -40,3 +40,4 @@ bench/nested-deps/pages/**/*
bench/nested-deps/components/**/*
**/convex/_generated/**
**/.tina/__generated__/**
+1 -1
View File
@@ -3,4 +3,4 @@ export const i18n = {
locales: ['en', 'de', 'cs'],
} as const
export type Locale = typeof i18n['locales'][number]
export type Locale = (typeof i18n)['locales'][number]
+2 -2
View File
@@ -11,10 +11,10 @@ const documents = {
export function graphql(
source: '\n query GetAllPosts($first: Int!) {\n postCollection(first: $first) {\n edges {\n node {\n id\n title\n slug\n }\n }\n }\n }\n'
): typeof documents['\n query GetAllPosts($first: Int!) {\n postCollection(first: $first) {\n edges {\n node {\n id\n title\n slug\n }\n }\n }\n }\n']
): (typeof documents)['\n query GetAllPosts($first: Int!) {\n postCollection(first: $first) {\n edges {\n node {\n id\n title\n slug\n }\n }\n }\n }\n']
export function graphql(
source: '\n query GetPostBySlug($slug: String!) {\n post(by: { slug: $slug }) {\n id\n title\n slug\n }\n }\n'
): typeof documents['\n query GetPostBySlug($slug: String!) {\n post(by: { slug: $slug }) {\n id\n title\n slug\n }\n }\n']
): (typeof documents)['\n query GetPostBySlug($slug: String!) {\n post(by: { slug: $slug }) {\n id\n title\n slug\n }\n }\n']
export function graphql(source: string): unknown
export function graphql(source: string) {
@@ -11,10 +11,10 @@ const documents = {
export function graphql(
source: '\n mutation UpdateName($name: String!) {\n updateName(name: $name) {\n id\n name\n status\n }\n }\n'
): typeof documents['\n mutation UpdateName($name: String!) {\n updateName(name: $name) {\n id\n name\n status\n }\n }\n']
): (typeof documents)['\n mutation UpdateName($name: String!) {\n updateName(name: $name) {\n id\n name\n status\n }\n }\n']
export function graphql(
source: '\n query Viewer {\n viewer {\n id\n name\n status\n }\n }\n'
): typeof documents['\n query Viewer {\n viewer {\n id\n name\n status\n }\n }\n']
): (typeof documents)['\n query Viewer {\n viewer {\n id\n name\n status\n }\n }\n']
export function graphql(source: string): unknown
export function graphql(source: string) {
+1 -1
View File
@@ -194,7 +194,7 @@
"postcss-pseudoelements": "5.0.0",
"postcss-short-size": "4.0.0",
"postcss-trolling": "0.1.7",
"prettier": "2.5.1",
"prettier": "2.8.8",
"pretty-bytes": "5.3.0",
"pretty-ms": "7.0.0",
"random-seed": "0.3.0",
+1 -1
View File
@@ -47,7 +47,7 @@
"cross-spawn": "6.0.5",
"glob": "8.0.3",
"got": "10.7.0",
"prettier-plugin-tailwindcss": "0.2.4",
"prettier-plugin-tailwindcss": "0.3.0",
"prompts": "2.1.0",
"tar": "6.1.15",
"update-check": "1.5.4",
+9 -9
View File
@@ -1,11 +1,11 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript"
}
},
"module": {
"type": "commonjs"
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript"
}
}
},
"module": {
"type": "commonjs"
}
}
@@ -62,7 +62,7 @@ export async function webpackBuildImpl(
duration: number
pluginState: any
turbotraceContext?: TurbotraceContext
serializedPagesManifestEntries?: typeof NextBuildContext['serializedPagesManifestEntries']
serializedPagesManifestEntries?: (typeof NextBuildContext)['serializedPagesManifestEntries']
}> {
let result: CompilerResult | null = {
warnings: [],
+1 -1
View File
@@ -6,7 +6,7 @@ export function traverseModules(
callback: (
mod: any,
chunk: webpack.Chunk,
chunkGroup: typeof compilation.chunkGroups[0],
chunkGroup: (typeof compilation.chunkGroups)[0],
modId: string | number
) => any
) {
+1 -1
View File
@@ -35,7 +35,7 @@ if (typeof window === 'undefined') {
}
const VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const
type LoadingValue = typeof VALID_LOADING_VALUES[number]
type LoadingValue = (typeof VALID_LOADING_VALUES)[number]
type ImageConfig = ImageConfigComplete & {
allSizes: number[]
output?: 'standalone' | 'export'
+2 -2
View File
@@ -39,7 +39,7 @@ if (typeof window === 'undefined') {
}
const VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const
type LoadingValue = typeof VALID_LOADING_VALUES[number]
type LoadingValue = (typeof VALID_LOADING_VALUES)[number]
type ImageConfig = ImageConfigComplete & { allSizes: number[] }
export type ImageLoader = (resolverProps: ImageLoaderProps) => string
@@ -194,7 +194,7 @@ const VALID_LAYOUT_VALUES = [
'responsive',
undefined,
] as const
type LayoutValue = typeof VALID_LAYOUT_VALUES[number]
type LayoutValue = (typeof VALID_LAYOUT_VALUES)[number]
type PlaceholderValue = 'blur' | 'empty'
@@ -7,7 +7,7 @@ const WEB_VITALS = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB']
const initialHref = location.href
let isRegistered = false
let userReportHandler: ReportCallback | undefined
type Attribution = typeof WEB_VITALS[number]
type Attribution = (typeof WEB_VITALS)[number]
function onReport(metric: Metric): void {
if (userReportHandler) {
@@ -7,7 +7,7 @@ const WEB_VITALS = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB']
const initialHref = location.href
let isRegistered = false
let userReportHandler: ReportCallback | undefined
type Attribution = typeof WEB_VITALS[number]
type Attribution = (typeof WEB_VITALS)[number]
function onReport(metric: Metric): void {
if (userReportHandler) {
+1 -1
View File
@@ -53,7 +53,7 @@ const routerEvents = [
'hashChangeStart',
'hashChangeComplete',
] as const
export type RouterEvent = typeof routerEvents[number]
export type RouterEvent = (typeof routerEvents)[number]
const coreMethodFields = [
'push',
+1 -1
View File
@@ -28,7 +28,7 @@ type Config = {
// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules
const VALID_SEVERITY = ['off', 'warn', 'error'] as const
type Severity = typeof VALID_SEVERITY[number]
type Severity = (typeof VALID_SEVERITY)[number]
function isValidSeverity(severity: string): severity is Severity {
return VALID_SEVERITY.includes(severity as Severity)
+1 -1
View File
@@ -233,7 +233,7 @@ export interface ExperimentalConfig {
*/
serverComponentsExternalPackages?: string[]
webVitalsAttribution?: Array<typeof WEB_VITALS[number]>
webVitalsAttribution?: Array<(typeof WEB_VITALS)[number]>
turbo?: ExperimentalTurboOptions
turbotrace?: {
@@ -226,7 +226,7 @@ const normalizeOutputPath = (dir: string) => dir.replace(/[/\\]server$/, '')
export const getEntries = (
dir: string
): NonNullable<ReturnType<typeof entriesMap['get']>> => {
): NonNullable<ReturnType<(typeof entriesMap)['get']>> => {
dir = normalizeOutputPath(dir)
const entries = entriesMap.get(dir) || {}
entriesMap.set(dir, entries)
@@ -303,7 +303,7 @@ class Invalidator {
}
function disposeInactiveEntries(
entries: NonNullable<ReturnType<typeof entriesMap['get']>>,
entries: NonNullable<ReturnType<(typeof entriesMap)['get']>>,
maxInactiveAge: number
) {
Object.keys(entries).forEach((entryKey) => {
@@ -21,7 +21,7 @@ export function isInterceptionRouteAppPath(path: string): boolean {
export function extractInterceptionRouteInformation(path: string) {
let interceptingRoute: string | undefined,
marker: typeof INTERCEPTION_ROUTE_MARKERS[number] | undefined,
marker: (typeof INTERCEPTION_ROUTE_MARKERS)[number] | undefined,
interceptedRoute: string | undefined
for (const segment of path.split('/')) {
@@ -156,7 +156,7 @@ export async function makeResolver(
}
type GetEdgeFunctionInfo =
typeof DevServer['prototype']['getEdgeFunctionInfo']
(typeof DevServer)['prototype']['getEdgeFunctionInfo']
const getEdgeFunctionInfo = (
original: GetEdgeFunctionInfo
): GetEdgeFunctionInfo => {
+1 -1
View File
@@ -16,7 +16,7 @@ export const HTTP_METHODS = [
* A type representing the valid HTTP methods that can be implemented by
* Next.js's Custom App Routes.
*/
export type HTTP_METHOD = typeof HTTP_METHODS[number]
export type HTTP_METHOD = (typeof HTTP_METHODS)[number]
/**
* Checks to see if the passed string is an HTTP method. Note that this is case
@@ -54,7 +54,7 @@ export async function clearModuleContext(
) {
const handleContext = (
key: string,
cache: ReturnType<typeof moduleContexts['get']>,
cache: ReturnType<(typeof moduleContexts)['get']>,
context: typeof moduleContexts | typeof pendingModuleCaches
) => {
const prev = cache?.paths.get(path)?.replace(WEBPACK_HASH_REGEX, '')
@@ -161,7 +161,7 @@ function getDecorateUnhandledRejection(runtime: EdgeRuntime) {
const NativeModuleMap = (() => {
const mods: Record<
`node:${typeof SUPPORTED_NATIVE_MODULES[number]}`,
`node:${(typeof SUPPORTED_NATIVE_MODULES)[number]}`,
unknown
> = {
'node:buffer': pick(BufferImplementation, [
+1 -1
View File
@@ -63,7 +63,7 @@ export class BloomFilter {
return data
}
import(data: ReturnType<typeof this['export']>) {
import(data: ReturnType<(typeof this)['export']>) {
this.numItems = data.numItems
this.errorRate = data.errorRate
this.numBits = data.numBits
+1 -1
View File
@@ -6,7 +6,7 @@ export const VALID_LOADERS = [
'custom',
] as const
export type LoaderValue = typeof VALID_LOADERS[number]
export type LoaderValue = (typeof VALID_LOADERS)[number]
export type ImageLoaderProps = {
src: string
+1 -1
View File
@@ -50,7 +50,7 @@ export type NextWebVitalsMetric = {
} & (
| {
label: 'web-vital'
name: typeof WEB_VITALS[number]
name: (typeof WEB_VITALS)[number]
}
| {
label: 'custom'
+13 -26
View File
@@ -153,7 +153,7 @@ importers:
postcss-pseudoelements: 5.0.0
postcss-short-size: 4.0.0
postcss-trolling: 0.1.7
prettier: 2.5.1
prettier: 2.8.8
pretty-bytes: 5.3.0
pretty-ms: 7.0.0
random-seed: 0.3.0
@@ -337,7 +337,7 @@ importers:
postcss-pseudoelements: 5.0.0
postcss-short-size: 4.0.0
postcss-trolling: 0.1.7
prettier: 2.5.1
prettier: 2.8.8
pretty-bytes: 5.3.0
pretty-ms: 7.0.0
random-seed: 0.3.0
@@ -428,7 +428,7 @@ importers:
cross-spawn: 6.0.5
glob: 8.0.3
got: 10.7.0
prettier-plugin-tailwindcss: 0.2.4
prettier-plugin-tailwindcss: 0.3.0
prompts: 2.1.0
tar: 6.1.15
update-check: 1.5.4
@@ -452,7 +452,7 @@ importers:
cross-spawn: 6.0.5
glob: 8.0.3
got: 10.7.0
prettier-plugin-tailwindcss: 0.2.4_prettier@2.5.1
prettier-plugin-tailwindcss: 0.3.0_prettier@2.8.8
prompts: 2.1.0
tar: 6.1.15
update-check: 1.5.4
@@ -6146,7 +6146,7 @@ packages:
dependencies:
'@mdx-js/mdx': 2.2.1
source-map: 0.7.3
webpack: 5.86.0
webpack: 5.86.0_@[email protected]
transitivePeerDependencies:
- supports-color
@@ -6820,7 +6820,6 @@ packages:
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-darwin-x64/1.3.55:
@@ -6829,7 +6828,6 @@ packages:
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm-gnueabihf/1.3.55:
@@ -6838,7 +6836,6 @@ packages:
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-gnu/1.3.55:
@@ -6847,7 +6844,6 @@ packages:
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-musl/1.3.55:
@@ -6856,7 +6852,6 @@ packages:
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-gnu/1.3.55:
@@ -6865,7 +6860,6 @@ packages:
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-musl/1.3.55:
@@ -6874,7 +6868,6 @@ packages:
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-arm64-msvc/1.3.55:
@@ -6883,7 +6876,6 @@ packages:
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-ia32-msvc/1.3.55:
@@ -6892,7 +6884,6 @@ packages:
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-x64-msvc/1.3.55:
@@ -6901,7 +6892,6 @@ packages:
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core/1.3.55_@[email protected]:
@@ -6926,7 +6916,6 @@ packages:
'@swc/core-win32-arm64-msvc': 1.3.55
'@swc/core-win32-ia32-msvc': 1.3.55
'@swc/core-win32-x64-msvc': 1.3.55
dev: true
/@swc/helpers/0.4.14:
resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}
@@ -20897,12 +20886,11 @@ packages:
engines: {node: '>=4'}
dev: true
/prettier-plugin-tailwindcss/0.2.4_prettier@2.5.1:
resolution: {integrity: sha512-wMyugRI2yD8gqmMpZSS8kTA0gGeKozX/R+w8iWE+yiCZL09zY0SvfiHfHabNhjGhzxlQ2S2VuTxPE3T72vppCQ==}
/prettier-plugin-tailwindcss/0.3.0_prettier@2.8.8:
resolution: {integrity: sha512-009/Xqdy7UmkcTBpwlq7jsViDqXAYSOMLDrHAdTMlVZOrKfM2o9Ci7EMWTMZ7SkKBFTG04UM9F9iM2+4i6boDA==}
engines: {node: '>=12.17.0'}
peerDependencies:
'@ianvs/prettier-plugin-sort-imports': '*'
'@prettier/plugin-php': '*'
'@prettier/plugin-pug': '*'
'@shopify/prettier-plugin-liquid': '*'
'@shufo/prettier-plugin-blade': '*'
@@ -20912,6 +20900,7 @@ packages:
prettier-plugin-css-order: '*'
prettier-plugin-import-sort: '*'
prettier-plugin-jsdoc: '*'
prettier-plugin-marko: '*'
prettier-plugin-organize-attributes: '*'
prettier-plugin-organize-imports: '*'
prettier-plugin-style-order: '*'
@@ -20920,8 +20909,6 @@ packages:
peerDependenciesMeta:
'@ianvs/prettier-plugin-sort-imports':
optional: true
'@prettier/plugin-php':
optional: true
'@prettier/plugin-pug':
optional: true
'@shopify/prettier-plugin-liquid':
@@ -20938,6 +20925,8 @@ packages:
optional: true
prettier-plugin-jsdoc:
optional: true
prettier-plugin-marko:
optional: true
prettier-plugin-organize-attributes:
optional: true
prettier-plugin-organize-imports:
@@ -20949,11 +20938,11 @@ packages:
prettier-plugin-twig-melody:
optional: true
dependencies:
prettier: 2.5.1
prettier: 2.8.8
dev: true
/prettier/2.5.1:
resolution: {integrity: sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==}
/prettier/2.8.8:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
engines: {node: '>=10.13.0'}
hasBin: true
dev: true
@@ -23925,7 +23914,6 @@ packages:
serialize-javascript: 6.0.1
terser: 5.17.7
webpack: 5.86.0_@[email protected]
dev: true
/terser/5.10.0:
resolution: {integrity: sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==}
@@ -25283,7 +25271,6 @@ packages:
- '@swc/core'
- esbuild
- uglify-js
dev: true
/websocket-driver/0.7.3:
resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==}
@@ -7,7 +7,7 @@ createNextDescribe(
files: __dirname,
},
({ next }) => {
type BrowserInterface = Awaited<ReturnType<typeof next['browser']>>
type BrowserInterface = Awaited<ReturnType<(typeof next)['browser']>>
const getTopScroll = async (browser: BrowserInterface) =>
await browser.eval('document.documentElement.scrollTop')