Skip to content

Commit

Permalink
Ignore error messages caused by PrettyCSS not recognizing radial-grad…
Browse files Browse the repository at this point in the history
…ient

[PrettyCSS does not recognize
`radial-gradient`](fidian/PrettyCSS#38) and
its vendor-prefixed equivalents, so just work around that by checking to
see if the token for that error is a `radial-gradient` property and ignore
the error if it is.
  • Loading branch information
Mat Brown committed Jan 24, 2016
1 parent b2ca37c commit 64e9bac
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/validations/css/prettycss.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ var i18n = require('i18next-client');
var prettyCSS = require('PrettyCSS');
var Promise = require('es6-promise').Promise;

var RADIAL_GRADIENT_EXPR =
/^(?:(?:-(?:ms|moz|o|webkit)-)?radial-gradient|-webkit-gradient)/;
function isIncorrectlyRejectedRadialGradientValue(value) {
return RADIAL_GRADIENT_EXPR.test(value);
}

var humanErrors = {
'block-expected': function(error) {
return i18n.t(
Expand All @@ -23,6 +29,10 @@ var humanErrors = {
},

'invalid-value': function(error) {
if (isIncorrectlyRejectedRadialGradientValue(error.token.content)) {
return;
}

return i18n.t(
'errors.prettycss.invalid-value',
{error: error.token.content}
Expand Down Expand Up @@ -52,12 +62,14 @@ function convertErrorToAnnotation(error) {
var normalizedCode = error.code.split(':')[0];
if (error.token !== null && humanErrors.hasOwnProperty(normalizedCode)) {
var message = humanErrors[normalizedCode](error);
return {
row: error.token.line - 1, column: error.token.charNum - 1,
raw: message,
text: message,
type: 'error',
};
if (message !== undefined) {
return {
row: error.token.line - 1, column: error.token.charNum - 1,
raw: message,
text: message,
type: 'error',
};
}
}
}

Expand Down

0 comments on commit 64e9bac

Please sign in to comment.