Skip to content
Prev Previous commit
Next Next commit
better notice
  • Loading branch information
hyoban committed May 6, 2025
commit 87544726849522b0e4873cc4b967ab925451bb46
18 changes: 14 additions & 4 deletions lib/util/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ try {
resolveDefaultConfigPathAlias = null;
}

const CAN_NOT_RESOLVE_TAILWIND_CONFIG_PATH_ERROR =
'Cannot resolve default tailwindcss config path. Please manually set the config option.';

function notice() {
if (process.env.NODE_ENV !== 'test') {
console.warn(CAN_NOT_RESOLVE_TAILWIND_CONFIG_PATH_ERROR);
return {};
} else {
throw new Error(CAN_NOT_RESOLVE_TAILWIND_CONFIG_PATH_ERROR);
}
}

function getOption(context, name) {
// Options (defined at rule level)
const options = context.options[0] || {};
Expand All @@ -28,13 +40,11 @@ function getOption(context, name) {
return '^class(Name)?$';
case 'config':
if (resolveDefaultConfigPathAlias === null) {
console.warn('Cannot resolve default config path. Please manually set the config option.');
return {};
return notice();
} else {
const path = resolveDefaultConfigPathAlias();
if (!path) {
console.warn('Cannot resolve default config path. Please manually set the config option.');
return {};
return notice();
}
return path;
}
Expand Down