Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix showing of incorrect missing package in customSyntax require handling #5763

Merged
merged 4 commits into from Dec 8, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/getPostcssResult.js
Expand Up @@ -94,10 +94,18 @@ function getCustomSyntax(customSyntax) {
try {
resolved = require(customSyntax);
} catch (error) {
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
if (error && typeof error === 'object' && error.code === 'MODULE_NOT_FOUND') {
if (
error &&
typeof error === 'object' &&
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
error.code === 'MODULE_NOT_FOUND' &&
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
error.message.includes(customSyntax)
) {
console.error('Stylelint MODULE_NOT_FOUND', error);
dlaub3 marked this conversation as resolved.
Show resolved Hide resolved

throw new Error(
`Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`,
`Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.\n\nCaused by: ${error}`,
);
}

Expand Down