-
-
Notifications
You must be signed in to change notification settings - Fork 930
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
Catch rule execution exceptions #5012
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -107,16 +107,27 @@ function lintPostcssResult(stylelintOptions, postcssResult, config) { | |||
|
||||
performRules.push( | ||||
Promise.all( | ||||
postcssRoots.map((postcssRoot) => | ||||
ruleFunction(primaryOption, secondaryOptions, { | ||||
fix: | ||||
stylelintOptions.fix && | ||||
// Next two conditionals are temporary measures until #2643 is resolved | ||||
isFileFixCompatible && | ||||
!postcssResult.stylelint.disabledRanges[ruleName], | ||||
newline, | ||||
})(postcssRoot, postcssResult), | ||||
), | ||||
postcssRoots.map(async (postcssRoot) => { | ||||
try { | ||||
return await ruleFunction(primaryOption, secondaryOptions, { | ||||
fix: | ||||
stylelintOptions.fix && | ||||
// Next two conditionals are temporary measures until #2643 is resolved | ||||
isFileFixCompatible && | ||||
!postcssResult.stylelint.disabledRanges[ruleName], | ||||
newline, | ||||
})(postcssRoot, postcssResult); | ||||
} catch (ex) { | ||||
const fileName = | ||||
postcssRoot.source && postcssRoot.source.input | ||||
? postcssRoot.source.input.file | ||||
: 'unknown file'; | ||||
|
||||
// eslint-disable-next-line no-console | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we feel about disabling this rule here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, disabling it here seems no problems. 👍 {
"no-console": ["error", { "allow": ["warn", "error"] }]
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About this, I've opened a new issue: stylelint/eslint-config-stylelint#108 |
||||
console.error(`Rule ${ruleName} threw an unknown exception from ${fileName}`); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMO] I have some suggestions about this message:
For example:
See also:
|
||||
throw ex; | ||||
} | ||||
}), | ||||
), | ||||
); | ||||
}); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I test this change with
--stdin
, the message includesundefined
instead ofunknown file
:So, can we add test cases about this change? It seems good to me to add them to
lib/__tests__/standalone.test.js
.