| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fa5cff2 commit 8a94e0e
14 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ jobs: | |||
| 11 | 11 | matrix: | |
| 12 | 12 | node-version: | |
| 13 | 13 | - 26 | |
| 14 | - - 14 | ||
| 14 | + - 22 | ||
| 15 | 15 | steps: | |
| 16 | 16 | - uses: actions/checkout@v7 | |
| 17 | 17 | - uses: actions/setup-node@v6 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ import convertColor from 'color-convert'; | |||
| 3 | 3 | import updateLog from 'log-update'; | |
| 4 | 4 | import chalk from '../source/index.js'; | |
| 5 | 5 | ||
| 6 | - const ignoreCharacters = /[^\u{0021}-\u{007E}]/gu; | ||
| 6 | + const ignoreCharacters = /[^\u{0021}-\u{007E}]/gv; | ||
| 7 | 7 | ||
| 8 | 8 | function rainbow(string, offset) { | |
| 9 | 9 | if (!string || string.length === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ for (const key of Object.keys(styles)) { | |||
| 19 | 19 | continue; | |
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | - if (/^bg[^B]/.test(key)) { | ||
| 22 | + if (/^bg[^B]/v.test(key)) { | ||
| 23 | 23 | returnValue = chalk.black(returnValue); | |
| 24 | 24 | } | |
| 25 | 25 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,27 +6,27 @@ | |||
| 6 | 6 | "repository": "chalk/chalk", | |
| 7 | 7 | "funding": "https://github.com/chalk/chalk?sponsor=1", | |
| 8 | 8 | "type": "module", | |
| 9 | - "main": "./source/index.js", | ||
| 10 | - "exports": "./source/index.js", | ||
| 9 | + "exports": { | ||
| 10 | + "types": "./source/index.d.ts", | ||
| 11 | + "default": "./source/index.js" | ||
| 12 | + }, | ||
| 11 | 13 | "imports": { | |
| 12 | 14 | "#ansi-styles": "./source/vendor/ansi-styles/index.js", | |
| 13 | 15 | "#supports-color": { | |
| 14 | 16 | "node": "./source/vendor/supports-color/index.js", | |
| 15 | 17 | "default": "./source/vendor/supports-color/browser.js" | |
| 16 | 18 | } | |
| 17 | 19 | }, | |
| 18 | - "types": "./source/index.d.ts", | ||
| 19 | 20 | "sideEffects": false, | |
| 20 | 21 | "engines": { | |
| 21 | - "node": "^12.17.0 || ^14.13 || >=16.0.0" | ||
| 22 | + "node": ">=22" | ||
| 22 | 23 | }, | |
| 23 | 24 | "scripts": { | |
| 24 | - "test": "xo && c8 ava && tsd", | ||
| 25 | + "test": "xo && c8 ava && tsc --noEmit --types node source/index.d.ts", | ||
| 25 | 26 | "bench": "matcha benchmark.js" | |
| 26 | 27 | }, | |
| 27 | 28 | "files": [ | |
| 28 | - "source", | ||
| 29 | - "!source/index.test-d.ts" | ||
| 29 | + "source" | ||
| 30 | 30 | ], | |
| 31 | 31 | "keywords": [ | |
| 32 | 32 | "color", | |
@@ -51,31 +51,35 @@ | |||
| 51 | 51 | "text" | |
| 52 | 52 | ], | |
| 53 | 53 | "devDependencies": { | |
| 54 | - "@types/node": "^16.11.10", | ||
| 54 | + "@types/node": "^26.1.1", | ||
| 55 | 55 | "ansi-styles": "^6.2.3", | |
| 56 | - "ava": "^3.15.0", | ||
| 57 | - "c8": "^7.10.0", | ||
| 58 | - "color-convert": "^2.0.1", | ||
| 59 | - "execa": "^6.0.0", | ||
| 60 | - "log-update": "^5.0.0", | ||
| 56 | + "ava": "^8.0.1", | ||
| 57 | + "c8": "^12.0.0", | ||
| 58 | + "color-convert": "^3.1.3", | ||
| 59 | + "execa": "^10.0.0", | ||
| 60 | + "log-update": "^8.0.0", | ||
| 61 | 61 | "matcha": "^0.7.0", | |
| 62 | - "tsd": "^0.19.0", | ||
| 63 | - "xo": "^0.54.2", | ||
| 62 | + "typescript": "^6.0.3", | ||
| 63 | + "xo": "^4.0.0", | ||
| 64 | 64 | "yoctodelay": "^2.0.0" | |
| 65 | 65 | }, | |
| 66 | - "xo": { | ||
| 67 | - "ignores": [ | ||
| 68 | - "source/vendor" | ||
| 69 | - ], | ||
| 70 | - "rules": { | ||
| 71 | - "unicorn/prefer-string-slice": "off", | ||
| 72 | - "@typescript-eslint/consistent-type-imports": "off", | ||
| 73 | - "@typescript-eslint/consistent-type-exports": "off", | ||
| 74 | - "@typescript-eslint/consistent-type-definitions": "off", | ||
| 75 | - "unicorn/expiring-todo-comments": "off", | ||
| 76 | - "no-warning-comments": "off" | ||
| 66 | + "xo": [ | ||
| 67 | + { | ||
| 68 | + "ignores": [ | ||
| 69 | + "source/vendor" | ||
| 70 | + ] | ||
| 71 | + }, | ||
| 72 | + { | ||
| 73 | + "rules": { | ||
| 74 | + "unicorn/prefer-string-slice": "off", | ||
| 75 | + "@typescript-eslint/consistent-type-imports": "off", | ||
| 76 | + "@typescript-eslint/consistent-type-exports": "off", | ||
| 77 | + "@typescript-eslint/consistent-type-definitions": "off", | ||
| 78 | + "unicorn/expiring-todo-comments": "off", | ||
| 79 | + "no-warning-comments": "off" | ||
| 80 | + } | ||
| 77 | 81 | } | |
| 78 | - }, | ||
| 82 | + ], | ||
| 79 | 83 | "c8": { | |
| 80 | 84 | "reporter": [ | |
| 81 | 85 | "text", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ const levelMapping = [ | |||
| 22 | 22 | const styles = Object.create(null); | |
| 23 | 23 | ||
| 24 | 24 | const applyOptions = (object, options = {}) => { | |
| 25 | - if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { | ||
| 25 | + if (options.level && !(Number.isSafeInteger(options.level) && options.level >= 0 && options.level <= 3)) { | ||
| 26 | 26 | throw new Error('The `level` option should be an integer from 0 to 3'); | |
| 27 | 27 | } | |
| 28 | 28 | ||
@@ -51,6 +51,7 @@ function createChalk(options) { | |||
| 51 | 51 | return chalkFactory(options); | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | + // eslint-disable-next-line unicorn/no-top-level-side-effects -- The prototype chain must be set up at module load. | ||
| 54 | 55 | Object.setPrototypeOf(createChalk.prototype, Function.prototype); | |
| 55 | 56 | ||
| 56 | 57 | for (const [styleName, style] of Object.entries(ansiStyles)) { | |
@@ -185,6 +186,7 @@ const createBuilder = (self, _styler, _isEmpty) => { | |||
| 185 | 186 | const applyStyle = (self, string) => { | |
| 186 | 187 | // Read the level directly off the generator to skip the `level` getter dispatch on this hot path | |
| 187 | 188 | if (self[GENERATOR].level <= 0 || !string) { | |
| 189 | + // eslint-disable-next-line unicorn/no-computed-property-existence-check -- Reads the boolean value, not a property existence check. | ||
| 188 | 190 | return self[IS_EMPTY] ? '' : string; | |
| 189 | 191 | } | |
| 190 | 192 | ||
@@ -195,7 +197,7 @@ const applyStyle = (self, string) => { | |||
| 195 | 197 | } | |
| 196 | 198 | ||
| 197 | 199 | const {openAll, closeAll} = styler; | |
| 198 | - if (string.includes('\u001B')) { | ||
| 200 | + if (string.includes('\u{1B}')) { | ||
| 199 | 201 | while (styler !== undefined) { | |
| 200 | 202 | // Replace any instances already present with a re-opening code | |
| 201 | 203 | // otherwise only the part of the string until said closing code | |
@@ -217,6 +219,7 @@ const applyStyle = (self, string) => { | |||
| 217 | 219 | return openAll + string + closeAll; | |
| 218 | 220 | }; | |
| 219 | 221 | ||
| 222 | + // eslint-disable-next-line unicorn/no-top-level-side-effects -- The style getters must be installed at module load. | ||
| 220 | 223 | Object.defineProperties(createChalk.prototype, styles); | |
| 221 | 224 | ||
| 222 | 225 | const chalk = createChalk(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,8 @@ export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { | |||
| 22 | 22 | let endIndex = 0; | |
| 23 | 23 | let returnValue = ''; | |
| 24 | 24 | do { | |
| 25 | - const gotCR = string[index - 1] === '\r'; | ||
| 26 | - returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix; | ||
| 25 | + const isGotCR = string[index - 1] === '\r'; | ||
| 26 | + returnValue += string.slice(endIndex, (isGotCR ? index - 1 : index)) + prefix + (isGotCR ? '\r\n' : '\n') + postfix; | ||
| 27 | 27 | endIndex = index + 1; | |
| 28 | 28 | index = string.indexOf('\n', endIndex); | |
| 29 | 29 | } while (index !== -1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | 1 | const ANSI_BACKGROUND_OFFSET = 10; | |
| 2 | 2 | ||
| 3 | - const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`; | ||
| 3 | + const wrapAnsi16 = (offset = 0) => code => `\u{1B}[${code + offset}m`; | ||
| 4 | 4 | ||
| 5 | - const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`; | ||
| 5 | + const wrapAnsi256 = (offset = 0) => code => `\u{1B}[${38 + offset};5;${code}m`; | ||
| 6 | 6 | ||
| 7 | - const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`; | ||
| 7 | + const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u{1B}[${38 + offset};2;${red};${green};${blue}m`; | ||
| 8 | 8 | ||
| 9 | 9 | const styles = { | |
| 10 | 10 | modifier: { | |
@@ -76,8 +76,8 @@ function assembleStyles() { | |||
| 76 | 76 | for (const [groupName, group] of Object.entries(styles)) { | |
| 77 | 77 | for (const [styleName, style] of Object.entries(group)) { | |
| 78 | 78 | styles[styleName] = { | |
| 79 | - open: `\u001B[${style[0]}m`, | ||
| 80 | - close: `\u001B[${style[1]}m`, | ||
| 79 | + open: `\u{1B}[${style[0]}m`, | ||
| 80 | + close: `\u{1B}[${style[1]}m`, | ||
| 81 | 81 | }; | |
| 82 | 82 | ||
| 83 | 83 | group[styleName] = styles[styleName]; | |
@@ -96,8 +96,8 @@ function assembleStyles() { | |||
| 96 | 96 | enumerable: false, | |
| 97 | 97 | }); | |
| 98 | 98 | ||
| 99 | - styles.color.close = '\u001B[39m'; | ||
| 100 | - styles.bgColor.close = '\u001B[49m'; | ||
| 99 | + styles.color.close = '\u{1B}[39m'; | ||
| 100 | + styles.bgColor.close = '\u{1B}[49m'; | ||
| 101 | 101 | ||
| 102 | 102 | styles.color.ansi = wrapAnsi16(); | |
| 103 | 103 | styles.color.ansi256 = wrapAnsi256(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments