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,16 +1,16 @@
import { defaultColorMap } from "lib/types/defaults/options";
import { HexColor, MatugenColors } from "lib/types/options";
import { getMatugenVariations } from "./variations";
import { bash, dependencies, Notify, isAnImage } from "lib/utils";
import options from "options";
import icons from "lib/icons";
import { Variable } from "types/variable";
import { defaultColorMap } from 'lib/types/defaults/options';
import { ColorMapValue, ColorMapKey, HexColor, MatugenColors } from 'lib/types/options';
import { getMatugenVariations } from './variations';
import { bash, dependencies, Notify, isAnImage } from 'lib/utils';
import options from 'options';
import icons from 'lib/icons';
import { Variable } from 'types/variable';
const { scheme_type, contrast } = options.theme.matugen_settings;
const { matugen } = options.theme;
const updateOptColor = (color: HexColor, opt: Variable<HexColor>) => {
const updateOptColor = (color: HexColor, opt: Variable<HexColor>): void => {
opt.value = color;
}
};
export async function generateMatugenColors(): Promise<MatugenColors | undefined> {
if (!matugen.value || !dependencies('matugen')) {
@@ -21,18 +21,18 @@ export async function generateMatugenColors(): Promise<MatugenColors | undefined
try {
if (!wallpaperPath.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,
});
return;
}
const normalizedContrast = contrast.value > 1 ? 1
: contrast.value < -1 ? -1
: contrast.value
const contents = await bash(`matugen image ${wallpaperPath} -t scheme-${scheme_type.value} --contrast ${normalizedContrast} --json hex`);
const normalizedContrast = contrast.value > 1 ? 1 : contrast.value < -1 ? -1 : contrast.value;
const contents = await bash(
`matugen image ${wallpaperPath} -t scheme-${scheme_type.value} --contrast ${normalizedContrast} --json hex`,
);
return JSON.parse(contents).colors[options.theme.matugen_settings.mode.value];
} catch (error) {
@@ -42,6 +42,10 @@ export async function generateMatugenColors(): Promise<MatugenColors | undefined
}
}
const isColorValid = (color: string): color is ColorMapKey => {
return defaultColorMap.hasOwnProperty(color);
};
export const replaceHexValues = (incomingHex: HexColor, matugenColors: MatugenColors): HexColor => {
if (!options.theme.matugen.value) {
return incomingHex;
@@ -49,11 +53,18 @@ export const replaceHexValues = (incomingHex: HexColor, matugenColors: MatugenCo
const matugenVariation = getMatugenVariations(matugenColors, options.theme.matugen_settings.variation.value);
updateOptColor(matugenVariation.base, options.theme.bar.menus.menu.media.card.color as Variable<HexColor>);
for (let curColor of Object.keys(defaultColorMap)) {
if (defaultColorMap[curColor] === incomingHex) {
return matugenVariation[curColor];
for (const curColor of Object.keys(defaultColorMap)) {
const currentColor: string = curColor;
if (!isColorValid(currentColor)) {
continue;
}
const curColorValue: ColorMapValue = defaultColorMap[currentColor];
if (curColorValue === incomingHex) {
return matugenVariation[currentColor];
}
}
return incomingHex;
}
};