Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev dependencies (to silence some warnings on some sites) #84

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 22
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
24 changes: 12 additions & 12 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
export type CSPair = { // eslint-disable-line @typescript-eslint/naming-convention
/**
The ANSI terminal control sequence for starting this style.
*/
Expand All @@ -8,9 +8,9 @@ export interface CSPair { // eslint-disable-line @typescript-eslint/naming-conve
The ANSI terminal control sequence for ending this style.
*/
readonly close: string;
}
};

export interface ColorBase {
export type ColorBase = {
/**
The ANSI terminal control sequence for ending this color.
*/
Expand All @@ -21,9 +21,9 @@ export interface ColorBase {
ansi256(code: number): string;

ansi16m(red: number, green: number, blue: number): string;
}
};

export interface Modifier {
export type Modifier = {
/**
Resets the current color chain.
*/
Expand Down Expand Up @@ -70,9 +70,9 @@ export interface Modifier {
Puts a horizontal line through the center of the text. (Not widely supported)
*/
readonly strikethrough: CSPair;
}
};

export interface ForegroundColor {
export type ForegroundColor = {
readonly black: CSPair;
readonly red: CSPair;
readonly green: CSPair;
Expand Down Expand Up @@ -100,9 +100,9 @@ export interface ForegroundColor {
readonly cyanBright: CSPair;
readonly magentaBright: CSPair;
readonly whiteBright: CSPair;
}
};

export interface BackgroundColor {
export type BackgroundColor = {
readonly bgBlack: CSPair;
readonly bgRed: CSPair;
readonly bgGreen: CSPair;
Expand Down Expand Up @@ -130,9 +130,9 @@ export interface BackgroundColor {
readonly bgCyanBright: CSPair;
readonly bgMagentaBright: CSPair;
readonly bgWhiteBright: CSPair;
}
};

export interface ConvertColor {
export type ConvertColor = {
/**
Convert from the RGB color space to the ANSI 256 color space.

Expand Down Expand Up @@ -178,7 +178,7 @@ export interface ConvertColor {
@param hex - A hexadecimal string containing RGB data.
*/
hexToAnsi(hex: string): number;
}
};

/**
Basic modifier names.
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function assembleStyles() {
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
Object.defineProperties(styles, {
rgbToAnsi256: {
value: (red, green, blue) => {
value(red, green, blue) {
// We use the extended greyscale palette here, with the exception of
// black and white. normal palette only has 4 greyscale shades.
if (red === green && green === blue) {
Expand All @@ -132,7 +132,7 @@ function assembleStyles() {
enumerable: false,
},
hexToRgb: {
value: hex => {
value(hex) {
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
if (!matches) {
return [0, 0, 0];
Expand Down Expand Up @@ -161,7 +161,7 @@ function assembleStyles() {
enumerable: false,
},
ansi256ToAnsi: {
value: code => {
value(code) {
if (code < 8) {
return 30 + code;
}
Expand Down
8 changes: 7 additions & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {expectAssignable, expectError, expectType} from 'tsd';
import ansiStyles, {CSPair, ModifierName, ForegroundColorName, BackgroundColorName, ColorName} from './index.js';
import ansiStyles, {
type BackgroundColorName,
type ColorName,
type CSPair,
type ForegroundColorName,
type ModifierName,
} from './index.js';

expectType<ReadonlyMap<number, number>>(ansiStyles.codes);

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"text"
],
"devDependencies": {
"ava": "^3.15.0",
"ava": "^6.1.3",
"svg-term-cli": "^2.1.1",
"tsd": "^0.19.0",
"xo": "^0.47.0"
"tsd": "^0.31.1",
"xo": "^0.58.0"
}
}
7 changes: 6 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import test from 'ava';
import ansiStyles, {modifierNames, foregroundColorNames, backgroundColorNames, colorNames} from '../index.js';
import ansiStyles, {
backgroundColorNames,
colorNames,
foregroundColorNames,
modifierNames,
} from '../index.js';

test('return ANSI escape codes', t => {
t.is(ansiStyles.green.open, '\u001B[32m');
Expand Down