Skip to content

Commit 2c6d8a0

Browse files
committed
Consistent prefix in logError/logWarning
1 parent 95faad8 commit 2c6d8a0

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/knip/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const main = async () => {
111111
process.exitCode = 2;
112112
if (!args.debug && error instanceof Error && isKnownError(error)) {
113113
const knownErrors = getKnownErrors(error);
114-
for (const knownError of knownErrors) logError('ERROR', knownError.message);
114+
for (const knownError of knownErrors) logError(knownError.message);
115115
if (hasErrorCause(knownErrors[0])) {
116116
console.error('Reason:', knownErrors[0].cause.message);
117117
if (isModuleNotFoundError(knownErrors[0].cause))

packages/knip/src/util/create-options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ export const createOptions = async (options: CreateOptions) => {
6666
const invalid = value.filter((v: string) => !validIssueTypes.has(v));
6767
if (invalid.length > 0) {
6868
loadedConfig[key] = value.filter((v: string) => validIssueTypes.has(v));
69-
for (const name of invalid) logWarning('WARNING', `Ignored unknown issue type "${name}" in ${key}`);
69+
for (const name of invalid) logWarning(`Ignored unknown issue type "${name}" in ${key}`);
7070
}
7171
} else if (typeof value === 'object') {
7272
for (const name in value) {
7373
if (!validIssueTypes.has(name)) {
7474
delete value[name];
75-
logWarning('WARNING', `Ignored unknown issue type "${name}" in ${key}`);
75+
logWarning(`Ignored unknown issue type "${name}" in ${key}`);
7676
}
7777
}
7878
}

packages/knip/src/util/log.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* oxlint-disable no-console */
22
import st from './colors.ts';
33

4-
export const logWarning = (prefix: string, message: string) => {
5-
console.warn(`${st.yellow(prefix)}: ${message}`);
4+
export const logWarning = (message: string) => {
5+
console.warn(`${st.yellow('WARNING')}: ${message}`);
66
};
77

8-
export const logError = (prefix: string, message: string) => {
9-
console.error(`${st.red(prefix)}: ${message}`);
8+
export const logError = (message: string) => {
9+
console.error(`${st.red('ERROR')}: ${message}`);
1010
};

packages/knip/src/util/map-workspaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default async function mapWorkspaces(cwd: string, workspaces: string[]):
4141
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
4242
debugLog('*', `Unable to load package.json for ${name}`);
4343
} else if (error instanceof SyntaxError) {
44-
logWarning('WARNING', `Skipping workspace ${name}: invalid JSON in ${manifestPath} (${error.message})`);
44+
logWarning(`Skipping workspace ${name}: invalid JSON in ${manifestPath} (${error.message})`);
4545
} else throw error;
4646
}
4747
}

0 commit comments

Comments
 (0)