Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
refactor: removed lint ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
brianacnguyen committed Jun 4, 2024
1 parent d71784a commit ccecf0c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 50 deletions.
28 changes: 16 additions & 12 deletions src/css/brandColors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable guard-for-in */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { readFileSync } from 'fs';
import { resolve } from 'path';

Expand All @@ -11,20 +9,26 @@ const brandColorsCSS = readFileSync(brandColorsCSSPath, 'utf8');

describe('Brand Colors CSS', () => {
for (const color in brandColors) {
if (color !== 'white' && color !== 'black') {
for (const shade in brandColors[color]) {
const variableName = `--brand-colors-${color}-${color}${shade}`;
const colorValue = brandColors[color][shade].value;
if (Object.prototype.hasOwnProperty.call(brandColors, color)) {
if (color !== 'white' && color !== 'black') {
for (const shade in brandColors[color]) {
if (Object.prototype.hasOwnProperty.call(brandColors[color], shade)) {
const variableName = `--brand-colors-${color}-${color}${shade}`;
const colorValue: string = brandColors[color][shade].value;
it(`should have the correct value for ${variableName}`, () => {
expect(brandColorsCSS).toContain(
`${variableName}: ${colorValue};`,
);
});
}
}
} else {
const variableName = `--brand-colors-${color}`;
const colorValue: string = brandColors[color].value;
it(`should have the correct value for ${variableName}`, () => {
expect(brandColorsCSS).toContain(`${variableName}: ${colorValue};`);
});
}
} else {
const variableName = `--brand-colors-${color}`;
const colorValue = brandColors[color].value;
it(`should have the correct value for ${variableName}`, () => {
expect(brandColorsCSS).toContain(`${variableName}: ${colorValue};`);
});
}
}
});
41 changes: 22 additions & 19 deletions src/css/darkTheme.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable guard-for-in */
import { readFileSync } from 'fs';
import { resolve } from 'path';

Expand All @@ -10,27 +9,31 @@ const darkThemeCSS = readFileSync(darkThemeCSSPath, 'utf8');

describe('Dark Theme Colors CSS', () => {
for (const section in darkTheme) {
for (const key in darkTheme[section]) {
const variableName = `--color-${section}-${key.replace(/_/gu, '-')}`;
const { value } = darkTheme[section][key];
if (Object.prototype.hasOwnProperty.call(darkTheme, section)) {
for (const key in darkTheme[section]) {
if (Object.prototype.hasOwnProperty.call(darkTheme[section], key)) {
const variableName = `--color-${section}-${key.replace(/_/gu, '-')}`;
const { value } = darkTheme[section][key];

let cssValue: string;
if (value.startsWith('{')) {
const parts: string[] = value.slice(1, -1).split('.');
const color: string | undefined = parts[0];
const shade: string | undefined = parts[1];
if (color && shade) {
cssValue = `var(--brand-colors-${color}-${color}${shade})`;
} else {
throw new Error(`Invalid color or shade: ${value as string}`);
let cssValue: string;
if (value.startsWith('{')) {
const parts: string[] = value.slice(1, -1).split('.');
const color: string | undefined = parts[0];
const shade: string | undefined = parts[1];
if (color && shade) {
cssValue = `var(--brand-colors-${color}-${color}${shade})`;
} else {
throw new Error(`Invalid color or shade: ${value as string}`);
}
} else {
cssValue = value;
}

it(`should have the correct value for ${variableName}`, () => {
expect(darkThemeCSS).toContain(`${variableName}: ${cssValue};`);
});
}
} else {
cssValue = value;
}

it(`should have the correct value for ${variableName}`, () => {
expect(darkThemeCSS).toContain(`${variableName}: ${cssValue};`);
});
}
}
});
41 changes: 22 additions & 19 deletions src/css/lightTheme.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable guard-for-in */
import { readFileSync } from 'fs';
import { resolve } from 'path';

Expand All @@ -10,27 +9,31 @@ const lightThemeCSS = readFileSync(lightThemeCSSPath, 'utf8');

describe('Light Theme Colors CSS', () => {
for (const section in lightTheme) {
for (const key in lightTheme[section]) {
const variableName = `--color-${section}-${key.replace(/_/gu, '-')}`;
const { value } = lightTheme[section][key];
if (Object.prototype.hasOwnProperty.call(lightTheme, section)) {
for (const key in lightTheme[section]) {
if (Object.prototype.hasOwnProperty.call(lightTheme[section], key)) {
const variableName = `--color-${section}-${key.replace(/_/gu, '-')}`;
const { value } = lightTheme[section][key];

let cssValue: string;
if (value.startsWith('{')) {
const parts: string[] = value.slice(1, -1).split('.');
const color: string | undefined = parts[0];
const shade: string | undefined = parts[1];
if (color && shade) {
cssValue = `var(--brand-colors-${color}-${color}${shade})`;
} else {
throw new Error(`Invalid color or shade: ${value as string}`);
let cssValue: string;
if (value.startsWith('{')) {
const parts: string[] = value.slice(1, -1).split('.');
const color: string | undefined = parts[0];
const shade: string | undefined = parts[1];
if (color && shade) {
cssValue = `var(--brand-colors-${color}-${color}${shade})`;
} else {
throw new Error(`Invalid color or shade: ${value as string}`);
}
} else {
cssValue = value;
}

it(`should have the correct value for ${variableName}`, () => {
expect(lightThemeCSS).toContain(`${variableName}: ${cssValue};`);
});
}
} else {
cssValue = value;
}

it(`should have the correct value for ${variableName}`, () => {
expect(lightThemeCSS).toContain(`${variableName}: ${cssValue};`);
});
}
}
});

0 comments on commit ccecf0c

Please sign in to comment.