Skip to content

Commit 5298a34

Browse files
committed
Fix some ESLint aggressions. Fix typo on nearestColor file name.
1 parent 73c668f commit 5298a34

File tree

4 files changed

+42
-44
lines changed

4 files changed

+42
-44
lines changed

src/nearest-color/nearesetColor.ts src/nearest-color/nearestColor.ts

+16-17
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ function nearestColor(needle: RGB | string, colors: Array<ColorSpec>): string {
8282
return "";
8383
}
8484

85+
/**
86+
* Given either an array or object of colors, returns an array of
87+
* {@link ColorSpec} objects (with {@link RGB} values).
88+
*
89+
* @private
90+
* @param {Array.<string>|Object} colors An array of hex-based color strings, or
91+
* an object mapping color *names* to hex values.
92+
* @return {Array.<ColorSpec>} An array of {@link ColorSpec} objects
93+
* representing the same colors passed in.
94+
*/
95+
function mapColors(colors: Array<string>): Array<ColorSpec> {
96+
return colors.map((color) => createColorSpec(color));
97+
}
98+
8599
/**
86100
* Provides a matcher to find the nearest color based on the provided list of
87101
* available colors.
@@ -136,30 +150,15 @@ function nearestColor(needle: RGB | string, colors: Array<ColorSpec>): string {
136150
export const nearestColorFrom = (
137151
availableColors: Array<string>
138152
): ((hex: string) => string) => {
139-
let colors = mapColors(availableColors);
140-
var matcher = (hex: string) => nearestColor(hex, colors);
141-
return matcher;
153+
const colors = mapColors(availableColors);
154+
return (hex: string) => nearestColor(hex, colors);
142155
};
143156

144157
type ColorObject = {
145158
name: string;
146159
hex: string;
147160
};
148161

149-
/**
150-
* Given either an array or object of colors, returns an array of
151-
* {@link ColorSpec} objects (with {@link RGB} values).
152-
*
153-
* @private
154-
* @param {Array.<string>|Object} colors An array of hex-based color strings, or
155-
* an object mapping color *names* to hex values.
156-
* @return {Array.<ColorSpec>} An array of {@link ColorSpec} objects
157-
* representing the same colors passed in.
158-
*/
159-
function mapColors(colors: Array<string>): Array<ColorSpec> {
160-
return colors.map((color) => createColorSpec(color));
161-
}
162-
163162
/**
164163
* Parses a color from a string.
165164
*

src/tailwind/colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nearestColorFrom } from "../nearest-color/nearesetColor";
1+
import { nearestColorFrom } from "../nearest-color/nearestColor";
22
import { nearestValue } from "./conversionTables";
33

44
// retrieve the SOLID color for tailwind

src/tailwind/conversionTables.ts

+24-24
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,6 @@ const pixelToTailwindValue = (
2222
];
2323
};
2424

25-
export const pxToMapLetterSpacing = (value: number) =>
26-
pixelToTailwindValue(value, mapLetterSpacing);
27-
28-
// visually, percent / 100 => rem works nicely
29-
export const percentToAbsoluteLineHeight = (value: number) =>
30-
mapAbsoluteLineHeight[
31-
nearestValue(
32-
value / 100,
33-
Object.keys(mapAbsoluteLineHeight).map((d) => +d)
34-
)
35-
];
36-
37-
export const pxToAbsoluteLineHeight = (value: number): string =>
38-
pixelToTailwindValue(value, mapAbsoluteLineHeight);
39-
40-
export const pxToFontSize = (value: number): string =>
41-
pixelToTailwindValue(value, mapFontSize);
42-
43-
export const pxToBorderRadius = (value: number): string =>
44-
pixelToTailwindValue(value, mapBorderRadius);
45-
46-
export const pxToLayoutSize = (value: number): string =>
47-
pixelToTailwindValue(value, mapWidthHeightSize);
48-
4925
const mapLetterSpacing: Record<number, string> = {
5026
"-0.05": "tighter",
5127
"-0.025": "tight",
@@ -110,3 +86,27 @@ const mapWidthHeightSize: Record<number, string> = {
11086
14: "56",
11187
16: "64",
11288
};
89+
90+
export const pxToMapLetterSpacing = (value: number) =>
91+
pixelToTailwindValue(value, mapLetterSpacing);
92+
93+
// visually, percent / 100 => rem works nicely
94+
export const percentToAbsoluteLineHeight = (value: number) =>
95+
mapAbsoluteLineHeight[
96+
nearestValue(
97+
value / 100,
98+
Object.keys(mapAbsoluteLineHeight).map((d) => +d)
99+
)
100+
];
101+
102+
export const pxToAbsoluteLineHeight = (value: number): string =>
103+
pixelToTailwindValue(value, mapAbsoluteLineHeight);
104+
105+
export const pxToFontSize = (value: number): string =>
106+
pixelToTailwindValue(value, mapFontSize);
107+
108+
export const pxToBorderRadius = (value: number): string =>
109+
pixelToTailwindValue(value, mapBorderRadius);
110+
111+
export const pxToLayoutSize = (value: number): string =>
112+
pixelToTailwindValue(value, mapWidthHeightSize);

webpack.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const prod = mode === 'production';
66

77
module.exports = {
88
entry: './src/code.ts',
9-
devtool: 'inline-source-map',
9+
devtool: prod ? false : 'inline-source-map',
1010
resolve: {
1111
alias: {
1212
svelte: path.resolve('node_modules', 'svelte')
@@ -55,5 +55,4 @@ module.exports = {
5555
filename: '[name].css'
5656
})
5757
],
58-
devtool: prod ? false : 'source-map'
5958
};

0 commit comments

Comments
 (0)