chore: update tsconfig

fix-undefined-label
Amio 2022-04-30 16:10:24 +08:00 zatwierdzone przez Amio Jin
rodzic ef2f2914d8
commit 49b999f5da
5 zmienionych plików z 14 dodań i 10 usunięć

Wyświetl plik

@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
node: [8, 10, 12]
node: [8, 10, 12, 14, 16, 18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

Wyświetl plik

@ -1,8 +1,8 @@
// import widthsVerdana110 from './widths-verdana-110.json'
// @ts-ignore
const widthsVerdana110 = require('./widths-verdana-110.json')
const widthsVerdana110: number[] = require('./widths-verdana-110.json')
const calcWidth = (charWidthTable) => {
const calcWidth = (charWidthTable: number[]) => {
const fallbackWidth = charWidthTable[64] // Width as "@" for overflows
return ([...text]) => {

Wyświetl plik

@ -10,4 +10,4 @@ export default {
gray: '999',
cyan: '1BC',
black: '2A2A2A'
}
} as Record<string, string>

Wyświetl plik

@ -3,11 +3,12 @@ import { Verdana110 as calcWidth } from './calc-text-width'
import colorPresets from './color-presets'
type StyleOption = 'flat' | 'classic'
type ColorPreset = keyof typeof colorPresets
interface BadgenOptions {
status: string;
subject?: string;
color?: string;
color?: ColorPreset;
label?: string;
labelColor?: string
style?: StyleOption;
@ -38,16 +39,16 @@ export function badgen ({
labelColor = colorPresets[labelColor] || labelColor
iconWidth = iconWidth * 10
const iconSpanWidth = icon ? (label.length ? iconWidth + 30 : iconWidth - 18) : 0
const iconSpanWidth = icon ? (label?.length ? iconWidth + 30 : iconWidth - 18) : 0
const sbTextStart = icon ? (iconSpanWidth + 50) : 50
const sbTextWidth = calcWidth(label)
const sbTextWidth = label ? calcWidth(label) : 0
const stTextWidth = calcWidth(status)
const sbRectWidth = sbTextWidth + 100 + iconSpanWidth
const stRectWidth = stTextWidth + 100
const width = sbRectWidth + stRectWidth
const xlink = icon ? ' xmlns:xlink="http://www.w3.org/1999/xlink"' : ''
label = sanitize(label)
label = label ? sanitize(label) : undefined
status = sanitize(status)
color = sanitize(color)
labelColor = sanitize(labelColor)
@ -93,7 +94,7 @@ export function badgen ({
</svg>`
}
function bare ({ status, color, style, scale }) {
function bare ({ status, color = 'blue', style, scale = 1 }: BadgenOptions) {
typeAssert(typeof status === 'string', '<status> must be string')
color = colorPresets[color] || color || colorPresets.blue

Wyświetl plik

@ -1,5 +1,7 @@
{
"compilerOptions": {
"strict": true,
"target": "es2017",
"module": "commonjs",
"lib": ["esnext", "dom"],
@ -12,7 +14,8 @@
"resolveJsonModule": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
},
"include": ["src"]
}