From c0d8e7ed8a3ec549c81597fc06163276142d948d Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Sun, 4 Oct 2020 10:56:24 +1300 Subject: [PATCH] Update test dependencies (#414) --- examples/rainbow.js | 4 +++- index.d.ts | 32 ++++++++++++++++---------------- index.test-d.ts | 38 +++++++++++++++++++------------------- package.json | 12 ++++++------ source/templates.js | 4 ++-- test/instance.js | 4 ++-- test/template-literal.js | 2 +- 7 files changed, 49 insertions(+), 47 deletions(-) diff --git a/examples/rainbow.js b/examples/rainbow.js index 813e026..6e0664c 100644 --- a/examples/rainbow.js +++ b/examples/rainbow.js @@ -3,7 +3,9 @@ const chalk = require('..'); const ignoreChars = /[^!-~]/g; -const delay = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds)); +const delay = milliseconds => new Promise(resolve => { + setTimeout(resolve, milliseconds); +}); function rainbow(string, offset) { if (!string || string.length === 0) { diff --git a/index.d.ts b/index.d.ts index 9cd88f3..8fa375f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -181,7 +181,7 @@ declare namespace chalk { chalk.hex('#DEADED'); ``` */ - hex(color: string): Chalk; + hex: (color: string) => Chalk; /** Use keyword color value to set text color. @@ -195,27 +195,27 @@ declare namespace chalk { chalk.keyword('orange'); ``` */ - keyword(color: string): Chalk; + keyword: (color: string) => Chalk; /** Use RGB values to set text color. */ - rgb(red: number, green: number, blue: number): Chalk; + rgb: (red: number, green: number, blue: number) => Chalk; /** Use HSL values to set text color. */ - hsl(hue: number, saturation: number, lightness: number): Chalk; + hsl: (hue: number, saturation: number, lightness: number) => Chalk; /** Use HSV values to set text color. */ - hsv(hue: number, saturation: number, value: number): Chalk; + hsv: (hue: number, saturation: number, value: number) => Chalk; /** Use HWB values to set text color. */ - hwb(hue: number, whiteness: number, blackness: number): Chalk; + hwb: (hue: number, whiteness: number, blackness: number) => Chalk; /** Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color. @@ -223,12 +223,12 @@ declare namespace chalk { 30 <= code && code < 38 || 90 <= code && code < 98 For example, 31 for red, 91 for redBright. */ - ansi(code: number): Chalk; + ansi: (code: number) => Chalk; /** Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color. */ - ansi256(index: number): Chalk; + ansi256: (index: number) => Chalk; /** Use HEX value to set background color. @@ -242,7 +242,7 @@ declare namespace chalk { chalk.bgHex('#DEADED'); ``` */ - bgHex(color: string): Chalk; + bgHex: (color: string) => Chalk; /** Use keyword color value to set background color. @@ -256,27 +256,27 @@ declare namespace chalk { chalk.bgKeyword('orange'); ``` */ - bgKeyword(color: string): Chalk; + bgKeyword: (color: string) => Chalk; /** Use RGB values to set background color. */ - bgRgb(red: number, green: number, blue: number): Chalk; + bgRgb: (red: number, green: number, blue: number) => Chalk; /** Use HSL values to set background color. */ - bgHsl(hue: number, saturation: number, lightness: number): Chalk; + bgHsl: (hue: number, saturation: number, lightness: number) => Chalk; /** Use HSV values to set background color. */ - bgHsv(hue: number, saturation: number, value: number): Chalk; + bgHsv: (hue: number, saturation: number, value: number) => Chalk; /** Use HWB values to set background color. */ - bgHwb(hue: number, whiteness: number, blackness: number): Chalk; + bgHwb: (hue: number, whiteness: number, blackness: number) => Chalk; /** Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color. @@ -285,12 +285,12 @@ declare namespace chalk { For example, 31 for red, 91 for redBright. Use the foreground code, not the background code (for example, not 41, nor 101). */ - bgAnsi(code: number): Chalk; + bgAnsi: (code: number) => Chalk; /** Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color. */ - bgAnsi256(index: number): Chalk; + bgAnsi256: (index: number) => Chalk; /** Modifier: Resets the current color chain. diff --git a/index.test-d.ts b/index.test-d.ts index aa9e2f5..ba91b63 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,4 @@ -import {expectType, expectError} from 'tsd'; +import {expectType, expectAssignable, expectError} from 'tsd'; import chalk = require('.'); // - Helpers - @@ -13,7 +13,7 @@ if (chalk.supportsColor) { } // - stderr - -expectType(chalk.stderr); +expectAssignable(chalk.stderr); expectType(chalk.stderr.supportsColor); if (chalk.stderr.supportsColor) { expectType(chalk.stderr.supportsColor.hasBasic); @@ -41,22 +41,22 @@ expectType(chalk`Hello {bold.red ${name}}`); expectType(chalk`Works with numbers {bold.red ${1}}`); // -- Color methods -- -expectType(chalk.hex('#DEADED')); -expectType(chalk.keyword('orange')); -expectType(chalk.rgb(0, 0, 0)); -expectType(chalk.hsl(0, 0, 0)); -expectType(chalk.hsv(0, 0, 0)); -expectType(chalk.hwb(0, 0, 0)); -expectType(chalk.ansi(30)); -expectType(chalk.ansi256(0)); -expectType(chalk.bgHex('#DEADED')); -expectType(chalk.bgKeyword('orange')); -expectType(chalk.bgRgb(0, 0, 0)); -expectType(chalk.bgHsl(0, 0, 0)); -expectType(chalk.bgHsv(0, 0, 0)); -expectType(chalk.bgHwb(0, 0, 0)); -expectType(chalk.bgAnsi(30)); -expectType(chalk.bgAnsi256(0)); +expectAssignable(chalk.hex('#DEADED')); +expectAssignable(chalk.keyword('orange')); +expectAssignable(chalk.rgb(0, 0, 0)); +expectAssignable(chalk.hsl(0, 0, 0)); +expectAssignable(chalk.hsv(0, 0, 0)); +expectAssignable(chalk.hwb(0, 0, 0)); +expectAssignable(chalk.ansi(30)); +expectAssignable(chalk.ansi256(0)); +expectAssignable(chalk.bgHex('#DEADED')); +expectAssignable(chalk.bgKeyword('orange')); +expectAssignable(chalk.bgRgb(0, 0, 0)); +expectAssignable(chalk.bgHsl(0, 0, 0)); +expectAssignable(chalk.bgHsv(0, 0, 0)); +expectAssignable(chalk.bgHwb(0, 0, 0)); +expectAssignable(chalk.bgAnsi(30)); +expectAssignable(chalk.bgAnsi256(0)); // -- Modifiers -- expectType(chalk.reset('foo')); @@ -158,5 +158,5 @@ expectType(chalk.red.bgGreen.bold`Hello {italic.blue ${name}}`); expectType(chalk.strikethrough.cyanBright.bgBlack`Works with {reset {bold numbers}} {bold.red ${1}}`); // -- Color types == -expectType('red'); +expectAssignable('red'); expectError('hotpink'); diff --git a/package.json b/package.json index 0d99f0f..7a3bd25 100644 --- a/package.json +++ b/package.json @@ -46,14 +46,14 @@ }, "devDependencies": { "ava": "^2.4.0", - "coveralls": "^3.0.7", - "execa": "^4.0.0", - "import-fresh": "^3.1.0", + "coveralls": "^3.1.0", + "execa": "^4.0.3", + "import-fresh": "^3.2.1", "matcha": "^0.7.0", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "resolve-from": "^5.0.0", - "tsd": "^0.7.4", - "xo": "^0.28.2" + "tsd": "^0.13.1", + "xo": "^0.33.1" }, "xo": { "rules": { diff --git a/source/templates.js b/source/templates.js index b130949..bfdaba8 100644 --- a/source/templates.js +++ b/source/templates.js @@ -22,11 +22,11 @@ function unescape(c) { const bracket = c[1] === '{'; if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) { - return String.fromCharCode(parseInt(c.slice(1), 16)); + return String.fromCharCode(Number.parseInt(c.slice(1), 16)); } if (u && bracket) { - return String.fromCodePoint(parseInt(c.slice(2, -1), 16)); + return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16)); } return ESCAPES.get(c) || c; diff --git a/test/instance.js b/test/instance.js index e936333..37c72eb 100644 --- a/test/instance.js +++ b/test/instance.js @@ -17,10 +17,10 @@ test('the `level` option should be a number from 0 to 3', t => { /* eslint-disable no-new */ t.throws(() => { new chalk.Instance({level: 10}); - }, /should be an integer from 0 to 3/); + }, {message: /should be an integer from 0 to 3/}); t.throws(() => { new chalk.Instance({level: -1}); - }, /should be an integer from 0 to 3/); + }, {message: /should be an integer from 0 to 3/}); /* eslint-enable no-new */ }); diff --git a/test/template-literal.js b/test/template-literal.js index 2f75e03..c918a5b 100644 --- a/test/template-literal.js +++ b/test/template-literal.js @@ -179,7 +179,7 @@ test('throws if an extra unescaped } is found', t => { test('should not parse upper-case escapes', t => { const instance = new chalk.Instance({level: 0}); - t.is(instance`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000a`, 'N\nT\tX07\x07U000A\u000AU000a\u000A'); + t.is(instance`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000A`, 'N\nT\tX07\x07U000A\u000AU000a\u000A'); }); test('should properly handle undefined template interpolated values', t => {