Implemented strict linting standards and prettier formatting config. (#248)

* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
This commit is contained in:
Jas Singh
2024-09-14 16:20:05 -07:00
committed by GitHub
parent ff13e3dd3c
commit 2c72cc66d8
222 changed files with 13141 additions and 8433 deletions

View File

@@ -1,7 +1,7 @@
import icons from "lib/icons";
import { bash, dependencies, Notify, isAnImage } from "lib/utils";
import options from "options";
import Wallpaper from "services/Wallpaper";
import icons from 'lib/icons';
import { bash, dependencies, Notify, isAnImage } from 'lib/utils';
import options from 'options';
import Wallpaper from 'services/Wallpaper';
const { matugen } = options.theme;
const { mode, scheme_type, contrast } = options.theme.matugen_settings;
@@ -11,42 +11,42 @@ const ensureMatugenWallpaper = (): void => {
if (matugen.value && (!options.wallpaper.image.value.length || !isAnImage(wallpaperPath))) {
Notify({
summary: "Matugen Failed",
summary: 'Matugen Failed',
body: "Please select a wallpaper in 'Theming > General' first.",
iconName: icons.ui.warning,
timeout: 7000
})
timeout: 7000,
});
matugen.value = false;
}
}
};
export const initializeTrackers = (resetCssFunc: Function) => {
matugen.connect("changed", () => {
export const initializeTrackers = (resetCssFunc: () => void): void => {
matugen.connect('changed', () => {
ensureMatugenWallpaper();
options.resetTheme();
})
});
mode.connect("changed", () => {
mode.connect('changed', () => {
options.resetTheme();
})
scheme_type.connect("changed", () => {
});
scheme_type.connect('changed', () => {
options.resetTheme();
})
contrast.connect("changed", () => {
});
contrast.connect('changed', () => {
options.resetTheme();
})
});
Wallpaper.connect("changed", () => {
console.info("Wallpaper changed, regenerating Matugen colors...")
Wallpaper.connect('changed', () => {
console.info('Wallpaper changed, regenerating Matugen colors...');
if (options.theme.matugen.value) {
options.resetTheme();
resetCssFunc();
}
})
});
options.wallpaper.image.connect("changed", () => {
options.wallpaper.image.connect('changed', () => {
if ((!Wallpaper.isRunning() && options.theme.matugen.value) || !options.wallpaper.enable.value) {
console.info("Wallpaper path changed, regenerating Matugen colors...")
console.info('Wallpaper path changed, regenerating Matugen colors...');
options.resetTheme();
resetCssFunc();
}
@@ -54,6 +54,5 @@ export const initializeTrackers = (resetCssFunc: Function) => {
const wallpaperPath = options.wallpaper.image.value;
bash(`wal -i ${wallpaperPath}`);
}
})
}
});
};

View File

@@ -1,27 +1,14 @@
import options from "options";
import { bash, dependencies } from "lib/utils";
import { MatugenColors, RecursiveOptionsObject } from "lib/types/options";
import { initializeTrackers } from "./options_trackers";
import { generateMatugenColors, replaceHexValues } from "../services/matugen/index";
import { isHexColor, isOpt, isRecursiveOptionsObject } from "globals/variables";
import { Opt } from "lib/option";
import options from 'options';
import { bash, dependencies } from 'lib/utils';
import { MatugenColors, RecursiveOptionsObject } from 'lib/types/options';
import { initializeTrackers } from './options_trackers';
import { generateMatugenColors, replaceHexValues } from '../services/matugen/index';
const deps = [
"font",
"theme",
"bar.flatButtons",
"bar.position",
"bar.battery.charging",
"bar.battery.blocks",
];
const deps = ['font', 'theme', 'bar.flatButtons', 'bar.position', 'bar.battery.charging', 'bar.battery.blocks'];
function extractVariables(
theme: RecursiveOptionsObject,
prefix = "",
matugenColors?: MatugenColors
): string[] {
function extractVariables(theme: RecursiveOptionsObject, prefix = '', matugenColors?: MatugenColors): string[] {
let result = [] as string[];
for (let key in theme) {
for (const key in theme) {
if (!theme.hasOwnProperty(key)) {
continue;
}
@@ -31,7 +18,8 @@ function extractVariables(
const newPrefix = prefix ? `${prefix}-${key}` : key;
const isColor = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value.value);
const replacedValue = isColor && matugenColors !== undefined ? replaceHexValues(value.value, matugenColors) : value.value;
const replacedValue =
isColor && matugenColors !== undefined ? replaceHexValues(value.value, matugenColors) : value.value;
if (typeof value === 'function') {
result.push(`$${newPrefix}: ${replacedValue};`);
@@ -49,27 +37,25 @@ function extractVariables(
return result;
}
async function resetCss() {
if (!dependencies("sass")) return;
const resetCss = async (): Promise<void> => {
if (!dependencies('sass')) return;
try {
const matugenColors = await generateMatugenColors();
const variables = [
...extractVariables(options.theme, '', matugenColors),
];
const variables = [...extractVariables(options.theme, '', matugenColors)];
const vars = `${TMP}/variables.scss`
const css = `${TMP}/main.css`
const scss = `${TMP}/entry.scss`
const vars = `${TMP}/variables.scss`;
const css = `${TMP}/main.css`;
const scss = `${TMP}/entry.scss`;
const localScss = `${App.configDir}/scss/main.scss`;
const themeVariables = variables;
const integratedVariables = themeVariables;
const imports = [vars].map(f => `@import '${f}';`);
const imports = [vars].map((f) => `@import '${f}';`);
await Utils.writeFile(integratedVariables.join("\n"), vars);
await Utils.writeFile(integratedVariables.join('\n'), vars);
let mainScss = Utils.readFile(localScss);
mainScss = `${imports}\n${mainScss}`;
@@ -80,11 +66,9 @@ async function resetCss() {
App.applyCss(css, true);
} catch (error) {
error instanceof Error
? logError(error)
: console.error(error);
console.error(error);
}
}
};
initializeTrackers(resetCss);

View File

@@ -1,11 +1,11 @@
.systray button:not(:first-child) {
margin-left: $bar-buttons-systray-spacing;
margin-left: $bar-buttons-systray-spacing;
}
.systray-icon {
font-size: 1.3em;
font-size: 1.3em;
}
.style2.systray {
padding: $bar-buttons-padding_y $bar-buttons-padding_x;
padding: $bar-buttons-padding_y $bar-buttons-padding_x;
}