* Fix XO linting and update some dev dependencies Fixes #275 * Add some badges to the readme * Tiny travis.yml tweak * Require Node.js 6 * Validate the `level` option Fixes #248 * Add failing test for #234 (#235) * Add type definitions badge (#286) * Add Tidelift mention in the readme * Replace RawGit URL Fixes #305 * Fix ignore chars regex flags in rainbow example (#306) Use global matches rather than stopping after the first match. * Strict mode in Flow definition (#309) * Add security section * Add docs comments and tests for TypeScript definitions (#299) Fixes #293 * Update dependencies and meta tweaks * Type definition improvements * Enforce `chalk.constructor` to be called with `new` in TypeScript * Add extra level/enabled property info in the readme (#308) * Code style tweaks * Change tagged template literal argument type to accept `unknown` instead of just `string` (#316)
86 lines
2.2 KiB
JavaScript
86 lines
2.2 KiB
JavaScript
// @flow
|
|
import chalk from '..';
|
|
|
|
// $ExpectError (Can't have typo in option name)
|
|
chalk.constructor({levl: 1});
|
|
chalk.constructor({level: 1});
|
|
|
|
// $ExpectError (Option must have proper type)
|
|
new chalk.constructor({enabled: 'true'});
|
|
new chalk.constructor({enabled: true});
|
|
|
|
// $ExpectError (Can't have typo in chalk method)
|
|
chalk.rd('foo');
|
|
chalk.red('foo');
|
|
|
|
// $ExpectError (Can't have typo in chalk method)
|
|
chalk.gren`foo`;
|
|
chalk.green`foo`;
|
|
|
|
// $ExpectError (Can't have typo in chalk method)
|
|
chalk.red.bgBlu.underline('foo');
|
|
chalk.red.bgBlue.underline('foo');
|
|
|
|
// $ExpectError (Level must be 0, 1, 2, or 3)
|
|
const badCtx = chalk.constructor({level: 4});
|
|
const ctx = chalk.constructor({level: 3});
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
ctx.gry('foo');
|
|
ctx.grey('foo');
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
ctx`foo`.value();
|
|
ctx`foo`.valueOf();
|
|
|
|
// $ExpectError (Can't have typo in property name)
|
|
chalk.abled = true;
|
|
chalk.enabled = true;
|
|
|
|
// $ExpectError (Can't use invalid Level for property setter)
|
|
chalk.level = 10;
|
|
chalk.level = 1;
|
|
|
|
const chalkInstance = new chalk.constructor();
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
chalkInstance.blu('foo');
|
|
chalkInstance.blue('foo');
|
|
chalkInstance`foo`;
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
chalk.keywrd('orange').bgBlue('foo');
|
|
chalk.keyword('orange').bgBlue('foo');
|
|
|
|
// $ExpectError (rgb should take in 3 numbers)
|
|
chalk.rgb(1, 14).bgBlue('foo');
|
|
chalk.rgb(1, 14, 9).bgBlue('foo');
|
|
|
|
// $ExpectError (hsl should take in 3 numbers)
|
|
chalk.hsl(1, 14, '9').bgBlue('foo');
|
|
chalk.hsl(1, 14, 9).bgBlue('foo');
|
|
|
|
// $ExpectError (hsv should take in 3 numbers)
|
|
chalk.hsv(1, 14).bgBlue('foo');
|
|
chalk.hsv(1, 14, 9).bgBlue('foo');
|
|
|
|
// $ExpectError (hwb should take in 3 numbers)
|
|
chalk.hwb(1, 14).bgBlue('foo');
|
|
chalk.hwb(1, 14, 9).bgBlue('foo');
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
chalk.visibl('foo');
|
|
chalk.visible('foo');
|
|
|
|
// $ExpectError (Can't have typo in method name)
|
|
chalk.red.visibl('foo');
|
|
chalk.red.visible('foo');
|
|
chalk.visible.red('foo');
|
|
|
|
// $ExpectError (Can't write to readonly property)
|
|
chalk.black = 'foo';
|
|
chalk.black;
|
|
|
|
// $ExpectError (Can't write to readonly property)
|
|
chalk.reset = 'foo';
|
|
console.log(chalk.reset);
|