prettier and eslint ignore valid syntax for qml specific syntax. Clippy lint resolved in .rs. unused py files commented to be ignored by ruff

This commit is contained in:
2026-05-19 23:53:09 +02:00
parent ceca949535
commit dd49198cf7
10 changed files with 240 additions and 224 deletions
+18 -18
View File
@@ -1,26 +1,26 @@
name: Format (JS/TS) name: Format (JS/TS)
on: on:
pull_request: pull_request:
jobs: jobs:
format: format:
runs-on: alpine runs-on: alpine
container: node:20-alpine container: node:20-alpine
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install tools - name: Install tools
run: | run: |
apk add --no-cache \ apk add --no-cache \
git git
- name: Prettier - name: Prettier
run: | run: |
if [ -n "$(find . \( -iname "*.js" -o -iname "*.jsx" -o -iname "*.ts" -o -iname "*.tsx" -o -iname "*.mjs" -o -iname "*.cjs" \) -print -quit)" ]; then if [ -n "$(find . \( -iname "*.js" -o -iname "*.jsx" -o -iname "*.ts" -o -iname "*.tsx" -o -iname "*.mjs" -o -iname "*.cjs" \) -print -quit)" ]; then
npx --yes prettier --check "**/*.{js,jsx,ts,tsx,mjs,cjs}" --ignore-path .gitignore npx --yes prettier --check "**/*.{js,jsx,ts,tsx,mjs,cjs}" --ignore-path .gitignore
else else
echo "No JS/TS files found" echo "No JS/TS files found"
fi fi
+25 -25
View File
@@ -1,33 +1,33 @@
name: Lint (JS/TS) name: Lint (JS/TS)
on: on:
pull_request: pull_request:
jobs: jobs:
lint: lint:
runs-on: alpine runs-on: alpine
container: node:20-alpine container: node:20-alpine
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install tools - name: Install tools
run: | run: |
apk add --no-cache \ apk add --no-cache \
git git
- name: ESLint - name: ESLint
run: | run: |
if [ -n "$(find . \( -iname "*.js" -o -iname "*.jsx" -o -iname "*.ts" -o -iname "*.tsx" -o -iname "*.mjs" -o -iname "*.cjs" \) -print -quit)" ]; then if [ -n "$(find . \( -iname "*.js" -o -iname "*.jsx" -o -iname "*.ts" -o -iname "*.tsx" -o -iname "*.mjs" -o -iname "*.cjs" \) -print -quit)" ]; then
if [ -f package.json ]; then if [ -f package.json ]; then
npm install --no-audit --no-fund npm install --no-audit --no-fund
fi fi
if [ -f eslint.config.js ] || [ -f eslint.config.mjs ] || [ -f eslint.config.cjs ] || [ -f .eslintrc ] || [ -f .eslintrc.js ] || [ -f .eslintrc.cjs ] || [ -f .eslintrc.json ] || [ -f .eslintrc.yaml ] || [ -f .eslintrc.yml ]; then if [ -f eslint.config.js ] || [ -f eslint.config.mjs ] || [ -f eslint.config.cjs ] || [ -f .eslintrc ] || [ -f .eslintrc.js ] || [ -f .eslintrc.cjs ] || [ -f .eslintrc.json ] || [ -f .eslintrc.yaml ] || [ -f .eslintrc.yml ]; then
npx --yes eslint . npx --yes eslint .
else else
echo "No eslint config found" echo "No eslint config found"
fi fi
else else
echo "No JS/TS files found" echo "No JS/TS files found"
fi fi
+19 -19
View File
@@ -1,27 +1,27 @@
name: Lint (Python) name: Lint (Python)
on: on:
pull_request: pull_request:
jobs: jobs:
lint: lint:
runs-on: alpine runs-on: alpine
container: node:20-alpine container: node:20-alpine
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install tools - name: Install tools
run: | run: |
apk add --no-cache \ apk add --no-cache \
git \ git \
python3 \ python3 \
py3-pip py3-pip
- name: Ruff - name: Ruff
run: | run: |
python3 -m venv .venv python3 -m venv .venv
. .venv/bin/activate . .venv/bin/activate
pip install --no-cache-dir ruff pip install --no-cache-dir ruff
ruff check . ruff check .
+26 -26
View File
@@ -1,34 +1,34 @@
name: Lint (Rust) name: Lint (Rust)
on: on:
pull_request: pull_request:
jobs: jobs:
lint: lint:
runs-on: alpine runs-on: alpine
container: node:20-alpine container: node:20-alpine
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install tools - name: Install tools
run: | run: |
apk add --no-cache \ apk add --no-cache \
git \ git \
cargo \ cargo \
rust \ rust \
rust-clippy rust-clippy
- name: Clippy - name: Clippy
run: | run: |
if [ -n "$(find . -name "Cargo.toml" -print -quit)" ]; then if [ -n "$(find . -name "Cargo.toml" -print -quit)" ]; then
find . -name "Cargo.toml" -print0 | while IFS= read -r -d '' manifest; do find . -name "Cargo.toml" -print0 | while IFS= read -r -d '' manifest; do
cargo clippy --manifest-path "$manifest" -- -D warnings cargo clippy --manifest-path "$manifest" -- -D warnings
done done
elif [ -n "$(find . -name "*.rs" -print -quit)" ]; then elif [ -n "$(find . -name "*.rs" -print -quit)" ]; then
echo "Rust files found but no Cargo.toml" echo "Rust files found but no Cargo.toml"
exit 1 exit 1
else else
echo "No Rust project found" echo "No Rust project found"
fi fi
+2
View File
@@ -0,0 +1,2 @@
scripts/fzf.js
scripts/fuzzysort.js
+12 -10
View File
@@ -1,11 +1,13 @@
import json # import json
import typer # import typer
from zshell.assets.schemes.catppuccin import catppuccin # from zshell.assets.schemes.catppuccin import catppuccin
#
# app = typer.Typer()
#
# SCHEMES = catppuccin.variants.flavors
#
#
# @app.command()
# def set():
app = typer.Typer() # TODO: Currently unsused
SCHEMES = catppuccin.variants.flavors
@app.command()
def set():
+15 -13
View File
@@ -1,14 +1,16 @@
import typer # import typer
import subprocess # import subprocess
#
# from typing import Optional
#
# app = typer.Typer()
#
# RECORDER = "gpu-screen-recorder"
# HOME = str(os.getenv("HOME"))
# CONFIG = Path(HOME + "/.config/zshell/config.json")
#
#
# @app.command()
# def start():
from typing import Optional # TODO: Currently unused
app = typer.Typer()
RECORDER = "gpu-screen-recorder"
HOME = str(os.getenv("HOME"))
CONFIG = Path(HOME + "/.config/zshell/config.json")
@app.command()
def start():
+12 -10
View File
@@ -1,14 +1,16 @@
export default [ export default [
{ {
files: ["**/*.{js,jsx,ts,tsx,mjs,cjs}"], ignores: ["scripts/fzf.js", "scripts/fuzzysort.js"],
languageOptions: {
ecmaVersion: 2021,
sourceType: "module"
}, },
linterOptions: { {
reportUnusedDisableDirectives: true files: ["**/*.{js,jsx,ts,tsx,mjs,cjs}"],
languageOptions: {
ecmaVersion: 2021,
sourceType: "module",
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
rules: {},
}, },
rules: {
}
}
]; ];
+95 -95
View File
@@ -3,141 +3,141 @@
// Translated to Js from Cython with an LLM and reviewed // Translated to Js from Cython with an LLM and reviewed
function min3(a, b, c) { function min3(a, b, c) {
return a < b && a < c ? a : b < c ? b : c; return a < b && a < c ? a : b < c ? b : c;
} }
function max3(a, b, c) { function max3(a, b, c) {
return a > b && a > c ? a : b > c ? b : c; return a > b && a > c ? a : b > c ? b : c;
} }
function min2(a, b) { function min2(a, b) {
return a < b ? a : b; return a < b ? a : b;
} }
function max2(a, b) { function max2(a, b) {
return a > b ? a : b; return a > b ? a : b;
} }
function levenshteinDistance(s1, s2) { function levenshteinDistance(s1, s2) {
let len1 = s1.length; let len1 = s1.length;
let len2 = s2.length; let len2 = s2.length;
if (len1 === 0) return len2; if (len1 === 0) return len2;
if (len2 === 0) return len1; if (len2 === 0) return len1;
if (len2 > len1) { if (len2 > len1) {
[s1, s2] = [s2, s1]; [s1, s2] = [s2, s1];
[len1, len2] = [len2, len1]; [len1, len2] = [len2, len1];
}
let prev = new Array(len2 + 1);
let curr = new Array(len2 + 1);
for (let j = 0; j <= len2; j++) {
prev[j] = j;
}
for (let i = 1; i <= len1; i++) {
curr[0] = i;
for (let j = 1; j <= len2; j++) {
let cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
curr[j] = min3(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
} }
[prev, curr] = [curr, prev];
}
return prev[len2]; let prev = new Array(len2 + 1);
let curr = new Array(len2 + 1);
for (let j = 0; j <= len2; j++) {
prev[j] = j;
}
for (let i = 1; i <= len1; i++) {
curr[0] = i;
for (let j = 1; j <= len2; j++) {
let cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
curr[j] = min3(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
}
[prev, curr] = [curr, prev];
}
return prev[len2];
} }
function partialRatio(shortS, longS) { function partialRatio(shortS, longS) {
let lenS = shortS.length; let lenS = shortS.length;
let lenL = longS.length; let lenL = longS.length;
let best = 0.0; let best = 0.0;
if (lenS === 0) return 1.0; if (lenS === 0) return 1.0;
for (let i = 0; i <= lenL - lenS; i++) { for (let i = 0; i <= lenL - lenS; i++) {
let sub = longS.slice(i, i + lenS); let sub = longS.slice(i, i + lenS);
let dist = levenshteinDistance(shortS, sub); let dist = levenshteinDistance(shortS, sub);
let score = 1.0 - dist / lenS; let score = 1.0 - dist / lenS;
if (score > best) best = score; if (score > best) best = score;
} }
return best; return best;
} }
function computeScore(s1, s2) { function computeScore(s1, s2) {
if (s1 === s2) return 1.0; if (s1 === s2) return 1.0;
let dist = levenshteinDistance(s1, s2); let dist = levenshteinDistance(s1, s2);
let maxLen = max2(s1.length, s2.length); let maxLen = max2(s1.length, s2.length);
if (maxLen === 0) return 1.0; if (maxLen === 0) return 1.0;
let full = 1.0 - dist / maxLen; let full = 1.0 - dist / maxLen;
let part = let part =
s1.length < s2.length ? partialRatio(s1, s2) : partialRatio(s2, s1); s1.length < s2.length ? partialRatio(s1, s2) : partialRatio(s2, s1);
let score = 0.85 * full + 0.15 * part; let score = 0.85 * full + 0.15 * part;
if (s1 && s2 && s1[0] !== s2[0]) { if (s1 && s2 && s1[0] !== s2[0]) {
score -= 0.05; score -= 0.05;
}
let lenDiff = Math.abs(s1.length - s2.length);
if (lenDiff >= 3) {
score -= (0.05 * lenDiff) / maxLen;
}
let commonPrefixLen = 0;
let minLen = min2(s1.length, s2.length);
for (let i = 0; i < minLen; i++) {
if (s1[i] === s2[i]) {
commonPrefixLen++;
} else {
break;
} }
}
score += 0.02 * commonPrefixLen;
if (s1.includes(s2) || s2.includes(s1)) { let lenDiff = Math.abs(s1.length - s2.length);
score += 0.06; if (lenDiff >= 3) {
} score -= (0.05 * lenDiff) / maxLen;
}
return Math.max(0.0, Math.min(1.0, score)); let commonPrefixLen = 0;
let minLen = min2(s1.length, s2.length);
for (let i = 0; i < minLen; i++) {
if (s1[i] === s2[i]) {
commonPrefixLen++;
} else {
break;
}
}
score += 0.02 * commonPrefixLen;
if (s1.includes(s2) || s2.includes(s1)) {
score += 0.06;
}
return Math.max(0.0, Math.min(1.0, score));
} }
function computeTextMatchScore(s1, s2) { function computeTextMatchScore(s1, s2) {
if (s1 === s2) return 1.0; if (s1 === s2) return 1.0;
let dist = levenshteinDistance(s1, s2); let dist = levenshteinDistance(s1, s2);
let maxLen = max2(s1.length, s2.length); let maxLen = max2(s1.length, s2.length);
if (maxLen === 0) return 1.0; if (maxLen === 0) return 1.0;
let full = 1.0 - dist / maxLen; let full = 1.0 - dist / maxLen;
let part = let part =
s1.length < s2.length ? partialRatio(s1, s2) : partialRatio(s2, s1); s1.length < s2.length ? partialRatio(s1, s2) : partialRatio(s2, s1);
let score = 0.4 * full + 0.6 * part; let score = 0.4 * full + 0.6 * part;
let lenDiff = Math.abs(s1.length - s2.length); let lenDiff = Math.abs(s1.length - s2.length);
if (lenDiff >= 10) { if (lenDiff >= 10) {
score -= (0.02 * lenDiff) / maxLen; score -= (0.02 * lenDiff) / maxLen;
}
let commonPrefixLen = 0;
let minLen = min2(s1.length, s2.length);
for (let i = 0; i < minLen; i++) {
if (s1[i] === s2[i]) {
commonPrefixLen++;
} else {
break;
} }
}
score += 0.01 * commonPrefixLen;
if (s1.includes(s2) || s2.includes(s1)) { let commonPrefixLen = 0;
score += 0.2; let minLen = min2(s1.length, s2.length);
} for (let i = 0; i < minLen; i++) {
if (s1[i] === s2[i]) {
commonPrefixLen++;
} else {
break;
}
}
score += 0.01 * commonPrefixLen;
return Math.max(0.0, Math.min(1.0, score)); if (s1.includes(s2) || s2.includes(s1)) {
score += 0.2;
}
return Math.max(0.0, Math.min(1.0, score));
} }
+16 -8
View File
@@ -39,8 +39,10 @@ pub fn apply_rounded_corners(img: RgbaImage, radius: f32) -> RgbaImage {
); );
let mut pixmap = rgba_image_to_pixmap(&img); let mut pixmap = rgba_image_to_pixmap(&img);
let mut dst_paint = PixmapPaint::default(); let dst_paint = PixmapPaint {
dst_paint.blend_mode = BlendMode::DestinationIn; blend_mode: BlendMode::DestinationIn,
..Default::default()
};
pixmap.draw_pixmap(0, 0, mask.as_ref(), &dst_paint, Transform::identity(), None); pixmap.draw_pixmap(0, 0, mask.as_ref(), &dst_paint, Transform::identity(), None);
pixmap_to_rgba_image(pixmap) pixmap_to_rgba_image(pixmap)
} }
@@ -69,8 +71,10 @@ pub fn apply_drop_shadow(
let shadow_x = (extra_left as f32 + offset_x) as i32; let shadow_x = (extra_left as f32 + offset_x) as i32;
let shadow_y = (extra_top as f32 + offset_y) as i32; let shadow_y = (extra_top as f32 + offset_y) as i32;
let mut sp = PixmapPaint::default(); let sp = PixmapPaint {
sp.blend_mode = BlendMode::Source; blend_mode: BlendMode::Source,
..Default::default()
};
shadow_pixmap.draw_pixmap( shadow_pixmap.draw_pixmap(
shadow_x, shadow_x,
shadow_y, shadow_y,
@@ -87,8 +91,10 @@ pub fn apply_drop_shadow(
let blurred_pixmap = rgba_image_to_pixmap(&blurred); let blurred_pixmap = rgba_image_to_pixmap(&blurred);
let mut canvas = Pixmap::new(canvas_w, canvas_h).expect("canvas pixmap"); let mut canvas = Pixmap::new(canvas_w, canvas_h).expect("canvas pixmap");
let mut p = PixmapPaint::default(); let p = PixmapPaint {
p.blend_mode = BlendMode::Source; blend_mode: BlendMode::Source,
..Default::default()
};
canvas.draw_pixmap( canvas.draw_pixmap(
0, 0,
0, 0,
@@ -98,8 +104,10 @@ pub fn apply_drop_shadow(
None, None,
); );
let mut p2 = PixmapPaint::default(); let p2 = PixmapPaint {
p2.blend_mode = BlendMode::SourceOver; blend_mode: BlendMode::SourceOver,
..Default::default()
};
canvas.draw_pixmap( canvas.draw_pixmap(
extra_left as i32, extra_left as i32,
extra_top as i32, extra_top as i32,