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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user