Skip to content

Commit

Permalink
cleanup(angular): migrate angular to picocolors
Browse files Browse the repository at this point in the history
migrates `@nx/angular` from `chalk` to `picocolors`

Part of es-tooling/ecosystem-cleanup#117
  • Loading branch information
Phillip9587 committed Dec 20, 2024
1 parent efa5ba2 commit e4376ea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
10 changes: 9 additions & 1 deletion packages/angular/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
"rules": {
"no-restricted-imports": [
"error",
{
"name": "chalk",
"message": "Please use `picocolors` in place of `chalk` for rendering terminal colors"
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
Expand Down
1 change: 0 additions & 1 deletion packages/angular/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@schematics",
"@phenomnomnominal/tsquery",
"@typescript-eslint/",
"chalk",
"ignore",
"minimatch",
"rxjs-for-await",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dependencies": {
"@phenomnomnominal/tsquery": "~5.0.1",
"@typescript-eslint/type-utils": "^8.0.0",
"chalk": "^4.1.0",
"picocolors": "^1.1.0",
"magic-string": "~0.30.2",
"minimatch": "9.0.3",
"semver": "^7.5.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk = require('chalk');
import * as pc from 'picocolors';
import {
arrayToString,
getProjectValidationResultMessage,
Expand Down Expand Up @@ -48,10 +48,10 @@ describe('getProjectValidationResultMessage', () => {
},
]);

expect(message).toBe(`${chalk.bold(`Validation results`)}:
expect(message).toBe(`${pc.bold(`Validation results`)}:
- Simple error message with hint
${chalk.dim(chalk.italic(` Some hint message`))}
${pc.dim(pc.italic(` Some hint message`))}
- Simple error message without hint
Expand All @@ -60,7 +60,7 @@ describe('getProjectValidationResultMessage', () => {
- First error message
- Second error message
- Third error message
${chalk.dim(chalk.italic(` - Some hint message`))}
${pc.dim(pc.italic(` - Some hint message`))}
- Message group without hint:
- Errors:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk = require('chalk');
import * as pc from 'picocolors';
import type { ValidationError } from './types';

export function arrayToString(array: string[]): string {
Expand All @@ -18,7 +18,7 @@ export function arrayToString(array: string[]): string {
export function getProjectValidationResultMessage(
validationResult: ValidationError[]
): string {
return `${chalk.bold('Validation results')}:
return `${pc.bold('Validation results')}:
${validationResult
.map((error) => getValidationErrorText(error))
Expand All @@ -31,12 +31,12 @@ function getValidationErrorText({
hint,
}: ValidationError): string {
let lines = message
? [`- ${message}`, ...(hint ? [chalk.dim(chalk.italic(` ${hint}`))] : [])]
? [`- ${message}`, ...(hint ? [pc.dim(pc.italic(` ${hint}`))] : [])]
: [
`- ${messageGroup.title}:`,
' - Errors:',
...messageGroup.messages.map((message) => ` - ${message}`),
...(hint ? [chalk.dim(chalk.italic(` - ${hint}`))] : []),
...(hint ? [pc.dim(pc.italic(` - ${hint}`))] : []),
];

return lines.join('\n ');
Expand Down

0 comments on commit e4376ea

Please sign in to comment.