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

Commit

Permalink
Merge pull request #12 from michijs/master_lint
Browse files Browse the repository at this point in the history
[master] Linting changes
  • Loading branch information
lsegurado authored Apr 25, 2024
2 parents d77fe9f + 1a2bffb commit 72534eb
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/constants/references.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { References } from "../types";
import type { References } from "../types";

export const references = {
/**Incandescent/tungsten */
Expand Down
18 changes: 9 additions & 9 deletions src/converters/hexToRgba.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RGBA } from "../types";
import type { RGBA } from "../types";

export const hexToRgba = (hex: string): RGBA => {
let r = 0;
Expand All @@ -12,16 +12,16 @@ export const hexToRgba = (hex: string): RGBA => {
// #FFFFFF
// #FFFFFF00
if ([4, 5].includes(hex.length)) {
r = parseInt(hex.slice(1, 2).repeat(2), 16);
g = parseInt(hex.slice(2, 3).repeat(2), 16);
b = parseInt(hex.slice(3, 4).repeat(2), 16);
if (hex.length === 5) a = parseInt(hex.slice(4, 5).repeat(2), 16);
r = Number.parseInt(hex.slice(1, 2).repeat(2), 16);
g = Number.parseInt(hex.slice(2, 3).repeat(2), 16);
b = Number.parseInt(hex.slice(3, 4).repeat(2), 16);
if (hex.length === 5) a = Number.parseInt(hex.slice(4, 5).repeat(2), 16);
} else {
if ([7, 9].includes(hex.length)) {
r = parseInt(hex.slice(1, 3), 16);
g = parseInt(hex.slice(3, 5), 16);
b = parseInt(hex.slice(5, 7), 16);
if (hex.length === 9) a = parseInt(hex.slice(7, 9), 16);
r = Number.parseInt(hex.slice(1, 3), 16);
g = Number.parseInt(hex.slice(3, 5), 16);
b = Number.parseInt(hex.slice(5, 7), 16);
if (hex.length === 9) a = Number.parseInt(hex.slice(7, 9), 16);
} else
throw "Not supported Hex, we only support Hex with 3, 4, 6 or 8 digits";
}
Expand Down
2 changes: 1 addition & 1 deletion src/converters/hslToRgb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HSL, RGB } from "../types";
import type { HSL, RGB } from "../types";

const HueToRgb = (v1: number, v2: number, vH: number) => {
if (vH < 0) vH += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/hsvToRgb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HSV, RGB } from "src/types";
import type { HSV, RGB } from "src/types";

export const hsvToRgb = ({ h, s, v }: HSV): RGB => {
if (s === 0)
Expand Down
2 changes: 1 addition & 1 deletion src/converters/labToLch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LAB, LCH } from "../types";
import type { LAB, LCH } from "../types";

export const labToLch = ({ l, a, b }: LAB): LCH => {
// Convert to polar form
Expand Down
2 changes: 1 addition & 1 deletion src/converters/labToXyz.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultReference } from "../constants";
import { LAB, XYZ } from "../types";
import type { LAB, XYZ } from "../types";

const calculate = (x: number) => {
const pow = Math.pow(x, 3);
Expand Down
2 changes: 1 addition & 1 deletion src/converters/lchToLab.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LAB, LCH } from "../types";
import type { LAB, LCH } from "../types";

export const lchToLab = ({ l, c, h }: LCH): LAB => ({
l,
Expand Down
2 changes: 1 addition & 1 deletion src/converters/lchToRgb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { labToXyz } from "./labToXyz";
import { lchToLab } from "./lchToLab";
import { LCH, RGB, XYZ } from "../types";
import type { LCH, RGB, XYZ } from "../types";
import { xyzToRgb } from "./xyzToRgb";
import { DefaultReference } from "../constants";

Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbToHex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RGB } from "../types";
import type { RGB } from "../types";

export const toHex = (x: number) => {
const asHex = x.toString(16);
Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbToHsl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HSL, RGB } from "../types";
import type { HSL, RGB } from "../types";

export const rgbToHsl = ({ r, g, b }: RGB): HSL => {
const varR = r / 255;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbToHsv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HSV, RGB } from "src/types";
import type { HSV, RGB } from "src/types";

export const rgbToHsv = ({ r, g, b }: RGB): HSV => {
const varR = r / 255;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbToLch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hexToRgba } from "./hexToRgba";
import { labToLch } from "./labToLch";
import { rgbToXyz } from "./rgbToXyz";
import { LCH, XYZ } from "../types";
import type { LCH, XYZ } from "../types";
import { xyzToLab } from "./xyzToLab";
import { DefaultReference } from "../constants";

Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbToXyz.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RGB, XYZ } from "../types";
import type { RGB, XYZ } from "../types";

const calculate = (x: number) =>
(x > 0.04045 ? Math.pow((x + 0.055) / 1.055, 2.4) : x / 12.92) * 100;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/rgbaToHex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rgbToHex, toHex } from "./rgbToHex";
import { RGBA } from "../types";
import type { RGBA } from "../types";

export const rgbaToHex = ({ a, ...rgb }: RGBA) => `${rgbToHex(rgb)}${toHex(a)}`;
2 changes: 1 addition & 1 deletion src/converters/xyzToLab.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultReference } from "../constants";
import { LAB, XYZ } from "../types";
import type { LAB, XYZ } from "../types";

const calculate = (x: number) =>
x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/xyzToRgb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RGB, XYZ } from "../types";
import type { RGB, XYZ } from "../types";

const calculate = (x: number) =>
(x > 0.0031308 ? 1.055 * Math.pow(x, 1 / 2.4) - 0.055 : 12.92 * x) * 255;
Expand Down

0 comments on commit 72534eb

Please sign in to comment.