chore: update prettier to 3.5.1 and enable experimentalOperatorPosition (#12715)

This commit is contained in:
Tony 2025-02-16 20:34:19 +08:00 committed by GitHub
parent 7d8252679d
commit 3f680588cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 74 additions and 72 deletions

View File

@ -1,5 +1,6 @@
{ {
"singleQuote": true, "singleQuote": true,
"semi": false, "semi": false,
"trailingComma": "none" "trailingComma": "none",
"experimentalOperatorPosition": "start"
} }

View File

@ -28,8 +28,8 @@ const ignore = [
async function checkFile(file) { async function checkFile(file) {
if ( if (
extensions.some((e) => file.endsWith(e)) && extensions.some((e) => file.endsWith(e))
!ignore.some((i) => file.includes(`/${i}/`) || path.basename(file) == i) && !ignore.some((i) => file.includes(`/${i}/`) || path.basename(file) == i)
) { ) {
const fileStream = fs.createReadStream(file) const fileStream = fs.createReadStream(file)
const rl = readline.createInterface({ const rl = readline.createInterface({
@ -42,11 +42,11 @@ async function checkFile(file) {
for await (let line of rl) { for await (let line of rl) {
// ignore empty lines, allow shebang and bundler license // ignore empty lines, allow shebang and bundler license
if ( if (
line.length === 0 || line.length === 0
line.startsWith('#!') || || line.startsWith('#!')
line.startsWith('// swift-tools-version:') || || line.startsWith('// swift-tools-version:')
line === bundlerLicense || || line === bundlerLicense
line === denoLicense || line === denoLicense
) { ) {
continue continue
} }

View File

@ -1,6 +1,7 @@
body { body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, font-family:
Arial, sans-serif; -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
sans-serif;
margin: auto; margin: auto;
max-width: 38rem; max-width: 38rem;
padding: 2rem; padding: 2rem;

View File

@ -77,8 +77,8 @@
if (typeof data === 'object' && typeof data.payload === 'object') { if (typeof data === 'object' && typeof data.payload === 'object') {
const keys = data.payload ? Object.keys(data.payload) : [] const keys = data.payload ? Object.keys(data.payload) : []
return ( return (
keys.length > 0 && keys.length > 0
keys.every( && keys.every(
(key) => key === 'nonce' || key === 'payload' || key === 'contentType' (key) => key === 'nonce' || key === 'payload' || key === 'contentType'
) )
) )
@ -94,10 +94,10 @@
*/ */
function isIsolationPayload(data) { function isIsolationPayload(data) {
return ( return (
typeof data === 'object' && typeof data === 'object'
'callback' in data && && 'callback' in data
'error' in data && && 'error' in data
!isIsolationMessage(data) && !isIsolationMessage(data)
) )
} }
@ -139,8 +139,8 @@
function waitUntilReady() { function waitUntilReady() {
// consider either a function or an explicitly set null value as the ready signal // consider either a function or an explicitly set null value as the ready signal
if ( if (
typeof window.__TAURI_ISOLATION_HOOK__ === 'function' || typeof window.__TAURI_ISOLATION_HOOK__ === 'function'
window.__TAURI_ISOLATION_HOOK__ === null || window.__TAURI_ISOLATION_HOOK__ === null
) { ) {
sendMessage('__TAURI_ISOLATION_READY__') sendMessage('__TAURI_ISOLATION_READY__')
} else { } else {

View File

@ -23,8 +23,8 @@
const { cmd, callback, error, payload, options } = message const { cmd, callback, error, payload, options } = message
if ( if (
!customProtocolIpcFailed && !customProtocolIpcFailed
(canUseCustomProtocol || cmd === fetchChannelDataCommand) && (canUseCustomProtocol || cmd === fetchChannelDataCommand)
) { ) {
const { contentType, data } = processIpcMessage(payload) const { contentType, data } = processIpcMessage(payload)
fetch(window.__TAURI_INTERNALS__.convertFileSrc(cmd, 'ipc'), { fetch(window.__TAURI_INTERNALS__.convertFileSrc(cmd, 'ipc'), {

View File

@ -33,13 +33,13 @@
*/ */
function isIsolationMessage(event) { function isIsolationMessage(event) {
if ( if (
typeof event.data === 'object' && typeof event.data === 'object'
typeof event.data.payload === 'object' && typeof event.data.payload === 'object'
) { ) {
const keys = Object.keys(event.data.payload || {}) const keys = Object.keys(event.data.payload || {})
return ( return (
keys.length > 0 && keys.length > 0
keys.every( && keys.every(
(key) => key === 'contentType' || key === 'nonce' || key === 'payload' (key) => key === 'contentType' || key === 'nonce' || key === 'payload'
) )
) )
@ -55,10 +55,10 @@
*/ */
function isIsolationPayload(data) { function isIsolationPayload(data) {
return ( return (
typeof data === 'object' && typeof data === 'object'
'callback' in data && && 'callback' in data
'error' in data && && 'error' in data
!isIsolationMessage(data) && !isIsolationMessage(data)
) )
} }
@ -99,27 +99,27 @@
const SERIALIZE_TO_IPC_FN = '__TAURI_TO_IPC_KEY__' const SERIALIZE_TO_IPC_FN = '__TAURI_TO_IPC_KEY__'
if ( if (
typeof data === 'object' && typeof data === 'object'
data !== null && && data !== null
'constructor' in data && && 'constructor' in data
data.constructor === Array && data.constructor === Array
) { ) {
return data.map((v) => serializeIpcPayload(v)) return data.map((v) => serializeIpcPayload(v))
} }
if ( if (
typeof data === 'object' && typeof data === 'object'
data !== null && && data !== null
SERIALIZE_TO_IPC_FN in data && SERIALIZE_TO_IPC_FN in data
) { ) {
return data[SERIALIZE_TO_IPC_FN]() return data[SERIALIZE_TO_IPC_FN]()
} }
if ( if (
typeof data === 'object' && typeof data === 'object'
data !== null && && data !== null
'constructor' in data && && 'constructor' in data
data.constructor === Object && data.constructor === Object
) { ) {
const acc = {} const acc = {}
Object.entries(data).forEach(([k, v]) => { Object.entries(data).forEach(([k, v]) => {

View File

@ -21,8 +21,8 @@
} }
if ( if (
document.readyState === 'complete' || document.readyState === 'complete'
document.readyState === 'interactive' || document.readyState === 'interactive'
) { ) {
toggleDevtoolsHotkey() toggleDevtoolsHotkey()
} else { } else {

View File

@ -16,11 +16,11 @@
document.addEventListener('mousedown', (e) => { document.addEventListener('mousedown', (e) => {
if ( if (
// element has the magic data attribute // element has the magic data attribute
e.target.hasAttribute(TAURI_DRAG_REGION_ATTR) && e.target.hasAttribute(TAURI_DRAG_REGION_ATTR)
// and was left mouse button // and was left mouse button
e.button === 0 && && e.button === 0
// and was normal click to drag or double click to maximize // and was normal click to drag or double click to maximize
(e.detail === 1 || e.detail === 2) && (e.detail === 1 || e.detail === 2)
) { ) {
// macOS maximization happens on `mouseup`, // macOS maximization happens on `mouseup`,
// so we save needed state and early return // so we save needed state and early return
@ -48,14 +48,14 @@
document.addEventListener('mouseup', (e) => { document.addEventListener('mouseup', (e) => {
if ( if (
// element has the magic data attribute // element has the magic data attribute
e.target.hasAttribute(TAURI_DRAG_REGION_ATTR) && e.target.hasAttribute(TAURI_DRAG_REGION_ATTR)
// and was left mouse button // and was left mouse button
e.button === 0 && && e.button === 0
// and was double click // and was double click
e.detail === 2 && && e.detail === 2
// and the cursor hasn't moved from initial mousedown // and the cursor hasn't moved from initial mousedown
e.clientX === x && && e.clientX === x
e.clientY === y && e.clientY === y
) { ) {
window.__TAURI_INTERNALS__.invoke( window.__TAURI_INTERNALS__.invoke(
'plugin:window|internal_toggle_maximize' 'plugin:window|internal_toggle_maximize'

View File

@ -23,7 +23,7 @@
"example:api:dev": "pnpm run --filter \"api\" tauri dev" "example:api:dev": "pnpm run --filter \"api\" tauri dev"
}, },
"devDependencies": { "devDependencies": {
"prettier": "^3.4.2" "prettier": "^3.5.1"
}, },
"packageManager": "pnpm@9.9.0", "packageManager": "pnpm@9.9.0",
"pnpm": { "pnpm": {

View File

@ -62,14 +62,14 @@ export async function newMenu(
// about predefined menu item icon // about predefined menu item icon
if ( if (
'item' in opts && 'item' in opts
opts.item && && opts.item
typeof opts.item === 'object' && && typeof opts.item === 'object'
'About' in opts.item && && 'About' in opts.item
opts.item.About && && opts.item.About
typeof opts.item.About === 'object' && && typeof opts.item.About === 'object'
'icon' in opts.item.About && && 'icon' in opts.item.About
opts.item.About.icon && opts.item.About.icon
) { ) {
opts.item.About.icon = transformImage(opts.item.About.icon) opts.item.About.icon = transformImage(opts.item.About.icon)
} }

View File

@ -46,8 +46,8 @@ export function itemFromKind([rid, id, kind]: [number, string, ItemKind]):
/* eslint-enable @typescript-eslint/no-unsafe-return */ /* eslint-enable @typescript-eslint/no-unsafe-return */
} }
export type SubmenuOptions = Omit<MenuItemOptions, 'accelerator' | 'action'> & export type SubmenuOptions = Omit<MenuItemOptions, 'accelerator' | 'action'>
MenuOptions & MenuOptions
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */ /** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
export class Submenu extends MenuItemBase { export class Submenu extends MenuItemBase {

View File

@ -74,8 +74,8 @@ class WebviewWindow {
*/ */
constructor( constructor(
label: WebviewLabel, label: WebviewLabel,
options: Omit<WebviewOptions, 'x' | 'y' | 'width' | 'height'> & options: Omit<WebviewOptions, 'x' | 'y' | 'width' | 'height'>
WindowOptions = {} & WindowOptions = {}
) { ) {
this.label = label this.label = label
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@ -240,17 +240,17 @@ function applyMixins(
).forEach((extendedClass: { prototype: unknown }) => { ).forEach((extendedClass: { prototype: unknown }) => {
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => { Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
if ( if (
typeof baseClass.prototype === 'object' && typeof baseClass.prototype === 'object'
baseClass.prototype && && baseClass.prototype
name in baseClass.prototype && name in baseClass.prototype
) )
return return
Object.defineProperty( Object.defineProperty(
baseClass.prototype, baseClass.prototype,
name, name,
// eslint-disable-next-line // eslint-disable-next-line
Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ?? Object.getOwnPropertyDescriptor(extendedClass.prototype, name)
Object.create(null) ?? Object.create(null)
) )
}) })
}) })

View File

@ -13,8 +13,8 @@ importers:
.: .:
devDependencies: devDependencies:
prettier: prettier:
specifier: ^3.4.2 specifier: ^3.5.1
version: 3.4.2 version: 3.5.1
crates/tauri-schema-worker: crates/tauri-schema-worker:
devDependencies: devDependencies:
@ -1698,8 +1698,8 @@ packages:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
prettier@3.4.2: prettier@3.5.1:
resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} resolution: {integrity: sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==}
engines: {node: '>=14'} engines: {node: '>=14'}
hasBin: true hasBin: true
@ -3592,7 +3592,7 @@ snapshots:
prelude-ls@1.2.1: {} prelude-ls@1.2.1: {}
prettier@3.4.2: {} prettier@3.5.1: {}
printable-characters@1.0.42: {} printable-characters@1.0.42: {}