From c5da9d257919af75430ca3c84ed230fa40960c78 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Sun, 16 Feb 2025 10:36:53 +0800 Subject: [PATCH] chore: update prettier to 3.5.1 and enable `experimentalOperatorPosition` (#2427) --- .prettierrc | 3 ++- .scripts/ci/check-license-header.js | 12 +++++----- package.json | 2 +- plugins/fs/guest-js/index.ts | 8 +++---- plugins/geolocation/README.md | 4 ++-- plugins/nfc/guest-js/index.ts | 4 ++-- plugins/opener/guest-js/init.ts | 24 +++++++++---------- plugins/shell/guest-js/init.ts | 12 +++++----- .../examples/tauri-app/src/style.css | 5 ++-- pnpm-lock.yaml | 10 ++++---- 10 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.prettierrc b/.prettierrc index 299b9e14..6ca6fdd2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "singleQuote": true, "semi": false, - "trailingComma": "none" + "trailingComma": "none", + "experimentalOperatorPosition": "start" } diff --git a/.scripts/ci/check-license-header.js b/.scripts/ci/check-license-header.js index ed653809..4341e5a2 100644 --- a/.scripts/ci/check-license-header.js +++ b/.scripts/ci/check-license-header.js @@ -32,8 +32,8 @@ const ignore = [ async function checkFile(file) { if ( - extensions.some((e) => file.endsWith(e)) && - !ignore.some((i) => file.includes(`${path.sep}${i}`)) + extensions.some((e) => file.endsWith(e)) + && !ignore.some((i) => file.includes(`${path.sep}${i}`)) ) { const fileStream = fs.createReadStream(file) const rl = readline.createInterface({ @@ -46,10 +46,10 @@ async function checkFile(file) { for await (let line of rl) { // ignore empty lines, allow shebang, swift-tools-version and bundler license if ( - line.length === 0 || - line.startsWith('#!') || - line.startsWith('// swift-tools-version:') || - ignoredLicenses.includes(line) + line.length === 0 + || line.startsWith('#!') + || line.startsWith('// swift-tools-version:') + || ignoredLicenses.includes(line) ) { continue } diff --git a/package.json b/package.json index a3d5a543..f1a37b02 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "eslint": "9.19.0", "eslint-config-prettier": "10.0.1", "eslint-plugin-security": "3.0.1", - "prettier": "3.4.2", + "prettier": "3.5.1", "rollup": "4.34.7", "tslib": "2.8.1", "typescript": "5.7.3", diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 9d894bc5..e0438d58 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -604,8 +604,8 @@ async function copyFile( options?: CopyFileOptions ): Promise { if ( - (fromPath instanceof URL && fromPath.protocol !== 'file:') || - (toPath instanceof URL && toPath.protocol !== 'file:') + (fromPath instanceof URL && fromPath.protocol !== 'file:') + || (toPath instanceof URL && toPath.protocol !== 'file:') ) { throw new TypeError('Must be a file URL.') } @@ -919,8 +919,8 @@ async function rename( options?: RenameOptions ): Promise { if ( - (oldPath instanceof URL && oldPath.protocol !== 'file:') || - (newPath instanceof URL && newPath.protocol !== 'file:') + (oldPath instanceof URL && oldPath.protocol !== 'file:') + || (newPath instanceof URL && newPath.protocol !== 'file:') ) { throw new TypeError('Must be a file URL.') } diff --git a/plugins/geolocation/README.md b/plugins/geolocation/README.md index bf8e1741..5d306cee 100644 --- a/plugins/geolocation/README.md +++ b/plugins/geolocation/README.md @@ -118,8 +118,8 @@ import { let permissions = await checkPermissions() if ( - permissions.location === 'prompt' || - permissions.location === 'prompt-with-rationale' + permissions.location === 'prompt' + || permissions.location === 'prompt-with-rationale' ) { permissions = await requestPermissions(['location']) } diff --git a/plugins/nfc/guest-js/index.ts b/plugins/nfc/guest-js/index.ts index 96f7a72d..051a1841 100644 --- a/plugins/nfc/guest-js/index.ts +++ b/plugins/nfc/guest-js/index.ts @@ -181,8 +181,8 @@ function encodeURI(uri: string): number[] { protocols.slice(1).forEach(function (protocol) { if ( - (prefix.length === 0 || prefix === 'urn:') && - uri.indexOf(protocol) === 0 + (prefix.length === 0 || prefix === 'urn:') + && uri.indexOf(protocol) === 0 ) { prefix = protocol } diff --git a/plugins/opener/guest-js/init.ts b/plugins/opener/guest-js/init.ts index 046db99c..6f81141a 100644 --- a/plugins/opener/guest-js/init.ts +++ b/plugins/opener/guest-js/init.ts @@ -9,13 +9,13 @@ window.addEventListener('click', function (evt) { // return early if if ( // event was prevented - evt.defaultPrevented || + evt.defaultPrevented // or not a left click - evt.button !== 0 || + || evt.button !== 0 // or meta key pressed - evt.metaKey || + || evt.metaKey // or al key pressed - evt.altKey + || evt.altKey ) return @@ -28,16 +28,16 @@ window.addEventListener('click', function (evt) { // return early if if ( // not tirggered from element - !a || + !a // or doesn't have a href - !a.href || + || !a.href // or not supposed to be open in a new tab - !( - a.target === '_blank' || + || !( + a.target === '_blank' // or ctrl key pressed - evt.ctrlKey || + || evt.ctrlKey // or shift key pressed - evt.shiftKey + || evt.shiftKey ) ) return @@ -47,9 +47,9 @@ window.addEventListener('click', function (evt) { // return early if if ( // same origin (internal navigation) - url.origin === window.location.origin || + url.origin === window.location.origin // not default protocols - ['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p) + || ['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p) ) return diff --git a/plugins/shell/guest-js/init.ts b/plugins/shell/guest-js/init.ts index 58d0001e..b7e68a15 100644 --- a/plugins/shell/guest-js/init.ts +++ b/plugins/shell/guest-js/init.ts @@ -12,11 +12,11 @@ function openLinks(): void { if (target.matches('a')) { const t = target as HTMLAnchorElement if ( - t.href !== '' && - ['http://', 'https://', 'mailto:', 'tel:'].some((v) => + t.href !== '' + && ['http://', 'https://', 'mailto:', 'tel:'].some((v) => t.href.startsWith(v) - ) && - t.target === '_blank' + ) + && t.target === '_blank' ) { void invoke('plugin:shell|open', { path: t.href @@ -31,8 +31,8 @@ function openLinks(): void { } if ( - document.readyState === 'complete' || - document.readyState === 'interactive' + document.readyState === 'complete' + || document.readyState === 'interactive' ) { openLinks() } else { diff --git a/plugins/websocket/examples/tauri-app/src/style.css b/plugins/websocket/examples/tauri-app/src/style.css index 915efaee..04e208d3 100644 --- a/plugins/websocket/examples/tauri-app/src/style.css +++ b/plugins/websocket/examples/tauri-app/src/style.css @@ -10,8 +10,9 @@ body { margin: 0; padding: 8px; box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, + Cantarell, 'Helvetica Neue', sans-serif; } a { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb7c73a3..e68ff196 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,8 +40,8 @@ importers: specifier: 3.0.1 version: 3.0.1 prettier: - specifier: 3.4.2 - version: 3.4.2 + specifier: 3.5.1 + version: 3.5.1 rollup: specifier: 4.34.7 version: 4.34.7 @@ -1990,8 +1990,8 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - prettier@3.4.2: - resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} + prettier@3.5.1: + resolution: {integrity: sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==} engines: {node: '>=14'} hasBin: true @@ -4079,7 +4079,7 @@ snapshots: prelude-ls@1.2.1: {} - prettier@3.4.2: {} + prettier@3.5.1: {} process-warning@4.0.0: {}