Skip to content

Commit 044d1f4

Browse files
committed
chore: remove picocolors
1 parent e55db0b commit 044d1f4

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@coderwyd/eslint-config",
33
"type": "module",
44
"version": "4.7.0",
5-
"packageManager": "pnpm@10.17.1",
5+
"packageManager": "pnpm@10.18.1",
66
"description": "Donny's ESLint config",
77
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
88
"license": "MIT",
@@ -107,7 +107,6 @@
107107
"jsonc-eslint-parser": "^2.4.1",
108108
"local-pkg": "^1.1.2",
109109
"parse-gitignore": "^2.0.0",
110-
"picocolors": "^1.1.1",
111110
"prompts": "^2.4.2",
112111
"vue-eslint-parser": "^10.2.0",
113112
"yaml-eslint-parser": "^1.3.0",

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/typegen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { writeFile } from 'node:fs/promises'
2+
import { styleText } from 'node:util'
23
import { flatConfigsToRulesDTS } from 'eslint-typegen/core'
34
import { builtinRules } from 'eslint/use-at-your-own-risk'
4-
import picocolors from 'picocolors'
55
import {
66
command,
77
comments,
@@ -69,4 +69,4 @@ export type ConfigNames = ${configNames.map((i) => `'${i}'`).join(' | ')}
6969

7070
await writeFile('src/types/typegen.d.ts', dts)
7171

72-
console.log(picocolors.green('Type definitions generated!'))
72+
console.log(styleText('green', 'Type definitions generated!'))

src/cli/constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import c from 'picocolors'
1+
import { styleText } from 'node:util'
22
import { devDependencies, version } from '../../package.json'
33

4-
export const ARROW: string = c.cyan('→')
5-
export const CHECK: string = c.green('✔')
6-
export const CROSS: string = c.red('✘')
7-
export const WARN: string = c.yellow('ℹ')
4+
export const ARROW: string = styleText('cyan', '→')
5+
export const CHECK: string = styleText('green', '✔')
6+
export const CROSS: string = styleText('red', '✘')
7+
export const WARN: string = styleText('yellow', 'ℹ')
88

99
export const eslintVersion: string = devDependencies.eslint
1010
export { version }

src/cli/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import process from 'node:process'
2-
import c from 'picocolors'
2+
import { styleText } from 'node:util'
33
import yargs from 'yargs'
44
import { hideBin } from 'yargs/helpers'
55
import { CROSS, version } from './constants'
66
import { run } from './run'
77

88
function header() {
9-
console.log(`\n${c.green(`@coderwyd/eslint-config `)}${c.dim(`v${version}`)}`)
9+
console.log(
10+
`\n${styleText('green', `@coderwyd/eslint-config `)}${styleText('dim', `v${version}`)}`,
11+
)
1012
}
1113

1214
const instance = yargs(hideBin(process.argv))
@@ -29,8 +31,8 @@ const instance = yargs(hideBin(process.argv))
2931
try {
3032
await run(args)
3133
} catch (error) {
32-
console.error(c.inverse(c.red(' Failed to migrate ')))
33-
console.error(c.red(`${CROSS} ${String(error)}`))
34+
console.error(styleText(['red', 'inverse'], ' Failed to migrate '))
35+
console.error(styleText('red', `${CROSS} ${String(error)}`))
3436
process.exit(1)
3537
}
3638
},

src/cli/run.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import fs from 'node:fs'
22
import fsp from 'node:fs/promises'
33
import path from 'node:path'
44
import process from 'node:process'
5+
import { styleText } from 'node:util'
56
// @ts-expect-error missing types
67
import parse from 'parse-gitignore'
7-
import c from 'picocolors'
88

99
import prompts from 'prompts'
1010
import {
@@ -36,7 +36,8 @@ export async function run(options: RuleOptions = {}): Promise<void> {
3636

3737
if (fs.existsSync(pathFlatConfig)) {
3838
console.log(
39-
c.yellow(
39+
styleText(
40+
'yellow',
4041
`${WARN} eslint.config.js already exists, migration wizard exited.`,
4142
),
4243
)
@@ -55,7 +56,12 @@ export async function run(options: RuleOptions = {}): Promise<void> {
5556
}
5657

5758
// Update package.json
58-
console.log(c.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`))
59+
console.log(
60+
styleText(
61+
'cyan',
62+
`${ARROW} bumping @coderwyd/eslint-config to v${version}`,
63+
),
64+
)
5965
const pkgContent = await fsp.readFile(pathPackageJSON, 'utf-8')
6066
const pkg: Record<string, any> = JSON.parse(pkgContent)
6167

@@ -65,13 +71,13 @@ export async function run(options: RuleOptions = {}): Promise<void> {
6571
if (!pkg.devDependencies.eslint) pkg.devDependencies.eslint = eslintVersion
6672

6773
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2))
68-
console.log(c.green(`${CHECK} changes wrote to package.json`))
74+
console.log(styleText('green', `${CHECK} changes wrote to package.json`))
6975

7076
// End update package.json
7177
// Update eslint files
7278
const eslintIgnores: string[] = []
7379
if (fs.existsSync(pathESLintIngore)) {
74-
console.log(c.cyan(`${ARROW} migrating existing .eslintignore`))
80+
console.log(styleText('cyan', `${ARROW} migrating existing .eslintignore`))
7581
const content = await fsp.readFile(pathESLintIngore, 'utf-8')
7682
const parsed = parse(content)
7783
const globs = parsed.globs()
@@ -105,7 +111,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
105111
}
106112

107113
await fsp.writeFile(pathFlatConfig, eslintConfigContent)
108-
console.log(c.green(`${CHECK} created eslint.config.js`))
114+
console.log(styleText('green', `${CHECK} created eslint.config.js`))
109115

110116
const files = fs.readdirSync(cwd)
111117
const legacyConfig: string[] = []
@@ -115,7 +121,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
115121
})
116122
if (legacyConfig.length > 0) {
117123
console.log(`${WARN} you can now remove those files manually:`)
118-
console.log(` ${c.dim(legacyConfig.join(', '))}`)
124+
console.log(` ${styleText('dim', legacyConfig.join(', '))}`)
119125
}
120126

121127
// End update eslint files
@@ -155,7 +161,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
155161

156162
if (!fs.existsSync(settingsPath)) {
157163
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, 'utf-8')
158-
console.log(c.green(`${CHECK} created .vscode/settings.json`))
164+
console.log(styleText('green', `${CHECK} created .vscode/settings.json`))
159165
} else {
160166
let settingsContent = await fsp.readFile(settingsPath, 'utf8')
161167

@@ -167,13 +173,13 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
167173
settingsContent += `${vscodeSettingsString}}\n`
168174

169175
await fsp.writeFile(settingsPath, settingsContent, 'utf-8')
170-
console.log(c.green(`${CHECK} updated .vscode/settings.json`))
176+
console.log(styleText('green', `${CHECK} updated .vscode/settings.json`))
171177
}
172178
}
173179

174180
// End update .vscode/settings.json
175-
console.log(c.green(`${CHECK} migration completed`))
181+
console.log(styleText('green', `${CHECK} migration completed`))
176182
console.log(
177-
`Now you can update the dependencies and run ${c.blue('eslint . --fix')}\n`,
183+
`Now you can update the dependencies and run ${styleText('blue', 'eslint . --fix')}\n`,
178184
)
179185
}

0 commit comments

Comments
 (0)