Skip to content

Commit

Permalink
chore(biome): update config and scripts (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored Sep 24, 2024
1 parent d62fc40 commit dad74fe
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
12 changes: 7 additions & 5 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
Expand All @@ -11,11 +11,8 @@
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"useEditorconfig": true,
"lineWidth": 80,
"attributePosition": "auto",
"ignore": ["pnpm-lock.yaml"]
},
"organizeImports": { "enabled": true },
Expand Down Expand Up @@ -60,6 +57,11 @@
"attributePosition": "auto"
}
},
"css": {
"formatter": {
"quoteStyle": "single"
}
},
"overrides": [
{
"include": ["**/*.{yml,yaml,md}"],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"wxt": "0.19.9"
},
"scripts": {
"check": "biome check",
"lint": "biome check .",
"format": "biome format --write .",
"dev": "wxt",
"dev:firefox": "wxt --browser firefox",
"build": "wxt build",
Expand Down
3 changes: 2 additions & 1 deletion src/entries/content/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ async function findIconMatch(
for (const ext of fileExtensions) {
if (ext in associations.fileExtensions)
return associations.fileExtensions[ext];
if (ext in associations.languageIds) return associations.languageIds[ext];
if (ext in associations.languageIds)
return associations.languageIds[ext];
}

return '_file';
Expand Down
16 changes: 13 additions & 3 deletions src/entries/popup/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ async function init() {
const associations = await customAssociations.getValue();

for (const [key, el] of Object.entries({
fileExtensions: document.querySelector('ul#associations-file-extensions'),
fileExtensions: document.querySelector(
'ul#associations-file-extensions',
),
fileNames: document.querySelector('ul#associations-file-names'),
folderNames: document.querySelector('ul#associations-folder-names'),
} as Record<keyof Associations, HTMLUListElement>) as Array<
Expand Down Expand Up @@ -136,7 +138,11 @@ async function init() {
associations[key][inputA.value] = inputB.value as IconName;
await customAssociations.setValue(associations);
}
if (!addedEmpty && inputA.checkValidity() && inputB.checkValidity()) {
if (
!addedEmpty &&
inputA.checkValidity() &&
inputB.checkValidity()
) {
addEmpty();
addedEmpty = true;
}
Expand All @@ -146,7 +152,11 @@ async function init() {
associations[key][inputA.value] = inputB.value as IconName;
await customAssociations.setValue(associations);
}
if (!addedEmpty && inputA.checkValidity() && inputB.checkValidity()) {
if (
!addedEmpty &&
inputA.checkValidity() &&
inputB.checkValidity()
) {
addEmpty();
addedEmpty = true;
}
Expand Down
13 changes: 2 additions & 11 deletions src/entries/popup/styles.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
body {
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Open Sans',
'Helvetica Neue',
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue',
sans-serif;

width: 600px;
Expand Down
18 changes: 12 additions & 6 deletions wxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ export default defineConfig({
},
hooks: {
'build:before': async () => {
const ICON_DIR = join(__dirname, './vscode-icons/icons/css-variables/');
const ICON_DIR = join(
__dirname,
'./vscode-icons/icons/css-variables/',
);
const icons = {};

for await (const entry of hfs.list(ICON_DIR)) {
icons[entry.name.replace('.svg', '')] = await hfs
.text(join(ICON_DIR, entry.name))
.then((text) => {
return optimize(text.replaceAll('--vscode-ctp', '--ctp'), {
js2svg: { useShortTags: false },
})
return optimize(
text.replaceAll('--vscode-ctp', '--ctp'),
{
js2svg: { useShortTags: false },
},
)
.data.replace(
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">',
'',
Expand All @@ -58,8 +64,8 @@ export default defineConfig({
await hfs.write(
join(__dirname, './src/associations.json'),
JSON.stringify(
jiti(__dirname)('./vscode-icons/src/defaults/index.ts').defaultConfig
.associations,
jiti(__dirname)('./vscode-icons/src/defaults/index.ts')
.defaultConfig.associations,
),
);
},
Expand Down

0 comments on commit dad74fe

Please sign in to comment.