diff --git a/deps/weex-styler/index.js b/deps/weex-styler/index.js index 080b3b988f7ed82420fb450838a6caeb18b5f2f4..990bc4e1c8ea20bd161c717fe18e2eb0d5bd04d2 100644 --- a/deps/weex-styler/index.js +++ b/deps/weex-styler/index.js @@ -39,20 +39,25 @@ function expand (subResult, camelCasedName, ruleResult) { }) } else if (camelCasedName === 'margin' || camelCasedName === 'padding') { - const spliceName = [camelCasedName + 'Top', camelCasedName + 'Right', camelCasedName + 'Bottom', camelCasedName + 'Left'] + const spliceName = [camelCasedName + 'Top', camelCasedName + 'Right', camelCasedName + 'Bottom', + camelCasedName + 'Left'] util.splitAttr(ruleResult, subResult.value, spliceName) } else if (camelCasedName === 'borderWidth') { - util.splitAttr(ruleResult, subResult.value, ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth']) + util.splitAttr(ruleResult, subResult.value, ['borderTopWidth', 'borderRightWidth', + 'borderBottomWidth', 'borderLeftWidth']) } else if (camelCasedName === 'borderColor') { - util.splitAttr(ruleResult, subResult.value, ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor']) + util.splitAttr(ruleResult, subResult.value, ['borderTopColor', 'borderRightColor', + 'borderBottomColor', 'borderLeftColor']) } else if (camelCasedName === 'borderStyle') { - util.splitAttr(ruleResult, subResult.value, ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle']) + util.splitAttr(ruleResult, subResult.value, ['borderTopStyle', 'borderRightStyle', + 'borderBottomStyle', 'borderLeftStyle']) } else if (camelCasedName === 'borderRadius') { - util.splitAttr(ruleResult, subResult.value, ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius']) + util.splitAttr(ruleResult, subResult.value, ['borderBottomLeftRadius', 'borderBottomRightRadius', + 'borderTopLeftRadius', 'borderTopRightRadius']) } else if (camelCasedName === 'gridGap') { util.splitAttr(ruleResult, subResult.value, ['gridRowsGap', 'gridColumnsGap']) @@ -95,7 +100,8 @@ function flexExpand(rule, ruleLog) { ruleLog.push({ line: declaration.position.start.line, column: declaration.position.start.column, - reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + '` attribute is incorrect.' + reason: 'ERROR: Value `' + declaration.value + '` of the `' + + declaration.property + '` attribute is incorrect.' }) } } @@ -121,51 +127,62 @@ function getUnit(value) { function checkFlexOne(rule, ruleLog, declaration, values, i) { const array = ['none', 'auto', 'initial'] if (array.includes(values[0])) { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex', value: values[0], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex', + value: values[0], position: declaration.position}) } else if (getUnit(values[0]) === 'px') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', value: values[0], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', value: + values[0], position: declaration.position}) } else if (getUnit(values[0]) === 'none') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', value: values[0], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', value: + values[0], position: declaration.position}) } else { ruleLog.push({ line: declaration.position.start.line, column: declaration.position.start.column, - reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + '` attribute is incorrect.' + - 'It must be a number, a number with unit `' + 'px`' + ', none, auto, or initial.' + reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + + '` attribute is incorrect.' + 'It must be a number, a number with unit `' + + 'px`' + ', none, auto, or initial.' }) } } function checkFlexTwo(rule, ruleLog, declaration, values, i) { if (getUnit(values[0]) === 'none') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', value: values[0], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', + value: values[0], position: declaration.position}) if (getUnit(values[1]) === 'px') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', value: values[1], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', + value: values[1], position: declaration.position}) } else if (getUnit(values[1]) === 'none') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-shrink', value: values[1], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-shrink', + value: values[1], position: declaration.position}) } else { ruleLog.push({ line: declaration.position.start.line, column: declaration.position.start.column, - reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + '` attribute is incorrect. Value `' + - values[1] + '` must be a number or a number with unit `' + 'px`.' + reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + + '` attribute is incorrect. Value `' + values[1] + + '` must be a number or a number with unit `' + 'px`.' }) } } else { ruleLog.push({ line: declaration.position.start.line, column: declaration.position.start.column, - reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + '` attribute is incorrect. Value `' + - values[0] + '` must be a number.' + reason: 'ERROR: Value `' + declaration.value + '` of the `' + declaration.property + + '` attribute is incorrect. Value `' + values[0] + '` must be a number.' }) } } function checkFlexThree(rule, ruleLog, declaration, values, i) { if (getUnit(values[0]) === 'none' && getUnit(values[1]) === 'none' && getUnit(values[2]) === 'px') { - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', value: values[0], position: declaration.position}) - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-shrink', value: values[1], position: declaration.position}) - rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', value: values[2], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-grow', + value: values[0], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-shrink', + value: values[1], position: declaration.position}) + rule.declarations.splice(i, 0, {type: 'declaration', property: 'flex-basis', + value: values[2], position: declaration.position}) } else { ruleLog.push({ line: declaration.position.start.line, diff --git a/deps/weex-styler/lib/validator.js b/deps/weex-styler/lib/validator.js index 52782e311be663e90697e7f0a2b70cf061e01bbb..f9ea22b9ab47caf9e449a460c955bcb501513811 100644 --- a/deps/weex-styler/lib/validator.js +++ b/deps/weex-styler/lib/validator.js @@ -263,7 +263,8 @@ var LENGTH = function LENGTH(v, SUPPORT_UNIT) { { value: parseFloat(v) + SUPPORT_UNIT[0], reason: function(k, v) { - return 'WARNING: No unit is specified for the `'+util.camelCaseToHyphened(k)+'` attribute. The default unit is ' + SUPPORT_UNIT[0] + return 'WARNING: No unit is specified for the `' + util.camelCaseToHyphened(k) + + '` attribute. The default unit is ' + SUPPORT_UNIT[0] } } } else if (SUPPORT_UNIT.indexOf(unit) > -1) { @@ -272,7 +273,8 @@ var LENGTH = function LENGTH(v, SUPPORT_UNIT) { return { value: parseFloat(v) + SUPPORT_UNIT[0], reason: function reason(k, v, result) { - return 'ERROR: The `' + k + '` attribute does not support `' + unit + '`. The default unit is ' + SUPPORT_UNIT[0] + return 'ERROR: The `' + k + '` attribute does not support `' + unit + + '`. The default unit is ' + SUPPORT_UNIT[0] } } } @@ -312,7 +314,8 @@ var LENGTH = function LENGTH(v, SUPPORT_UNIT) { return { value: null, reason: function reason(k, v, result) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support the `' + v + '` value (only numbers are supported).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support the `' + v + + '` value (only numbers are supported).' } } } @@ -543,7 +546,8 @@ var STYLE_VALIDATOR = function STYLE_VALIDATOR(v) { return { value: null, reason: function (k,v) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (the support value is `' + styleList.join('`|`') + '`).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (the support value is `' + styleList.join('`|`') + '`).' } } } @@ -660,7 +664,8 @@ var BORDER_VALIDATOR = function BORDER_VALIDATOR (value, name) { value: res, reason: reasons.length > 0 ? function (k, v) { return ( - logTypes[index] + ': There are some problems with value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute. \n ' + reasons.join(' \n')) + logTypes[index] + ': There are some problems with value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute. \n ' + reasons.join(' \n')) } : null } } @@ -670,7 +675,8 @@ var BORDER_VALIDATOR = function BORDER_VALIDATOR (value, name) { value: null, reason: function reason (k, v, result) { return 'ERROR: The `' + util.camelCaseToHyphened(k) + - '` attribute does not support value `' + v + '` (this value does not meet the inspection standards for the width, style, and color).' + '` attribute does not support value `' + v + + '` (this value does not meet the inspection standards for the width, style, and color).' } } } @@ -780,7 +786,8 @@ var BOX_SHADOW_VALIDATOR = function BOX_SHADOW_VALIDATOR(value, name) { value: res, reason: reasons.length > 0 ? function (k, v) { return ( - logTypes[index] + ': There are some problems with value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute. \n ' + reasons.join(' \n')) + logTypes[index] + ': There are some problems with value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute. \n ' + reasons.join(' \n')) } : null } } @@ -849,7 +856,8 @@ var NUMBER_VALIDATOR = function NUMBER_VALIDATOR(v, isInt) { return { value: null, reason: function reason(k, v, result) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (only numbers are supported).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (only numbers are supported).' } } } @@ -891,7 +899,8 @@ var TRANSITION_PROPERTY_VALIDATOR = function TRANSITION_PROPERTY_VALIDATOR(v) { return { value: null, reason: function reason(k, v, result) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (only CSS attributes support this value).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (only CSS attributes support this value).' } } } @@ -930,7 +939,8 @@ var TRANSITION_INTERVAL_VALIDATOR = function TRANSITION_INTERVAL_VALIDATOR(v) { return { value: null, reason: function reason(k, v, result) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (only seconds and milliseconds are supported).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (only seconds and milliseconds are supported).' } } } @@ -955,7 +965,8 @@ var TRANSITION_TIMING_FUNCTION_VALIDATOR = function TRANSITION_TIMING_FUNCTION_V let NUM_REGEXP = /^[-]?\d*\.?\d+$/ if (match = v.match(/^cubic-bezier\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*\)$/)) { /* istanbul ignore else */ - if (match[1].match(NUM_REGEXP) && match[2].match(NUM_REGEXP) && match[3].match(NUM_REGEXP) && match[4].match(NUM_REGEXP)) { + if (match[1].match(NUM_REGEXP) && match[2].match(NUM_REGEXP) && + match[3].match(NUM_REGEXP) && match[4].match(NUM_REGEXP)) { ret = [parseFloat(match[1]), parseFloat(match[2]), parseFloat(match[3]), parseFloat(match[4])].join(',') return {value: 'cubic-bezier(' + ret + ')'} } @@ -978,7 +989,8 @@ var TRANSITION_TIMING_FUNCTION_VALIDATOR = function TRANSITION_TIMING_FUNCTION_V value: null, reason: function reason(k, v, result) { return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + - '` (supported values include `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`, `cubic-bezier(n,n,n,n)` and `steps(n[, start|end])`).' + '` (supported values include `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`,' + + '`cubic-bezier(n,n,n,n)` and `steps(n[, start|end])`).' } } } @@ -1128,7 +1140,8 @@ var TRANSFORM_VALIDATOR = function TRANSFORM_VALIDATOR(v) { value: result ? JSON.stringify(result) : null, reason: reasonMaps.length > 0 ? function(k, v) { - return logTypes[allLength] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') + return logTypes[allLength] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') } : null } } @@ -1181,7 +1194,8 @@ var ROTATE3D_VALIDATOR = function ROTATE3D_VALIDATOR(v) { value: length < 2 ? resultValues.join(' ') : null, reason: reasonMaps.length > 0 ? function (k, v) { - return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') + return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') } : null } } @@ -1214,7 +1228,8 @@ var MULTIPLE_POSITION_VALIDATOR = function MULTIPLE_POSITION_VALIDATOR(v, valida value: length < 2 ? resultValues.join(' ') : null, reason: reasonMaps.length > 0 ? function (k, v) { - return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') + return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') } : null } } @@ -1246,7 +1261,8 @@ function genEnumValidator(list) { value: v, reason: name !== 'objectFit' ? function reason(k, v, result) { - return 'NOTE: Value `' + v + '` is the default value of the `' + util.camelCaseToHyphened(k) + '` attribute (the value can be removed).' + return 'NOTE: Value `' + v + '` is the default value of the `' + util.camelCaseToHyphened(k) + + '` attribute (the value can be removed).' } : null } } @@ -1254,7 +1270,8 @@ function genEnumValidator(list) { return { value: null, reason: function reason(k, v, result) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (the supported value is `' + list.join('`|`') + '`).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (the supported value is `' + list.join('`|`') + '`).' } } } @@ -1305,7 +1322,8 @@ var BACKGROUND_VALIDATOR = function BACKGROUND_VALIDATOR(v) { value: length < 2 ? JSON.stringify(resultValues) : null, reason: reasonMaps.length > 0 ? function (k, v) { - return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') + return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join(' \n ') } : null } } @@ -1313,7 +1331,8 @@ var BACKGROUND_VALIDATOR = function BACKGROUND_VALIDATOR(v) { return { value: null, reason: function (k, v) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute is incorrect.' } } } @@ -1372,14 +1391,16 @@ var LINEAR_GRADIENT_VALIDATOR = function LINEAR_GRADIENT_VALIDATOR(v) { value: length < 2 ? JSON.stringify(result) : null, reason: reasonMaps.length > 0 ? function (k, v) { - return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join('\n ') + return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join('\n ') }: null } } return { value: null, reason: function (k, v) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect.' } } } @@ -1427,14 +1448,16 @@ var ARRAY_COLOR_STOP_VALIDATOR = function ARRAY_COLOR_STOP_VALIDATOR(v) { value: length < 2 ? JSON.stringify(resultValues) : null, reason: reasonMaps.length > 0 ? function (k, v) { - return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect. \n ' + reasonMaps.join('\n ') + return logTypes[length] + ': Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect. \n ' + reasonMaps.join('\n ') } : null } } return { value: null, reason: function (k, v) { - return 'ERROR: The format of value `' + v + '` of the `'+ util.camelCaseToHyphened(k) + '` attribute is incorrect. Please specify at least two colors.' + return 'ERROR: The format of value `' + v + '` of the `'+ util.camelCaseToHyphened(k) + + '` attribute is incorrect. Please specify at least two colors.' } } } @@ -1480,7 +1503,8 @@ var ANGLE_VALIDATOR = function ANGLE_VALIDATOR(v) { value: angle + SUPPORT_CSS_ANGLE_UNIT[0], reason: function(k, v) { return 'ERROR: The `' + util.camelCaseToHyphened(k) + - '` attribute does not support `' + unit + '`. It only supports `' + JSON.stringify(SUPPORT_CSS_ANGLE_UNIT) + '`.' + '` attribute does not support `' + unit + '`. It only supports `' + + JSON.stringify(SUPPORT_CSS_ANGLE_UNIT) + '`.' } } } @@ -1489,7 +1513,8 @@ var ANGLE_VALIDATOR = function ANGLE_VALIDATOR(v) { return { value: parseFloat(v) + SUPPORT_CSS_ANGLE_UNIT[0], reason: function(k, v) { - return 'WARNING: No unit is specified for the value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute. The default unit is `' + SUPPORT_CSS_ANGLE_UNIT[0] + '`.' + return 'WARNING: No unit is specified for the value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute. The default unit is `' + SUPPORT_CSS_ANGLE_UNIT[0] + '`.' } } } @@ -1497,7 +1522,8 @@ var ANGLE_VALIDATOR = function ANGLE_VALIDATOR(v) { return { value: null, reason: function(k, v) { - return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + '` (only numbers are supported).' + return 'ERROR: The `' + util.camelCaseToHyphened(k) + '` attribute does not support value `' + v + + '` (only numbers are supported).' } } } @@ -1533,7 +1559,8 @@ var GRADIENT_DIRECTION_VALIDATOR = function GRADIENT_DIRECTION_VALIDATOR(v) { value: invalid ? null : v, reason: invalid ? function (k, v) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute is incorrect.' } : null } } @@ -1585,7 +1612,8 @@ var URL_VALIDATOR = function URL_VALIDATOR(v) { return { value: null, reason: function (k, v) { - return 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute must be none or url(...).' + return 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute must be none or url(...).' } } } @@ -1599,7 +1627,8 @@ var NAME_VALIDATOR = function NAME_VALIDATOR(v) { return { value: null, reason: function(k, v) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect.' } } } @@ -1617,7 +1646,8 @@ var ITERATIONCOUNT_VALIDATOR = function ITERATIONCOUNT_VALIDATOR(v) { return { value: null, reason: function(k, v) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect (only integers and infinity are supported).' + return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is incorrect (only integers and infinity are supported).' } } } @@ -1768,8 +1798,10 @@ var MYLOCATION_VALIDATOR = function MYLOCATION_VALIDATOR(v) { value : null, reason: function(k, v) { return reason == 'value' ? - 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute does not meet the inspection standards for the color or url.' : - 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute must be set in order(color color url).' + 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute does not meet the inspection standards for the color or url.' : + 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute must be set in order(color color url).' } } } @@ -1806,7 +1838,8 @@ var TRANSFORM_ORIGIN_VALIDATOR = function TRANSFORM_ORIGIN_VALIDATOR(v) { return { value: null, reason: function (k, v) { - return 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is invalid. such as left 100px or 50% bottom.' + return 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + + '` attribute is invalid. such as left 100px or 50% bottom.' } } } @@ -1834,7 +1867,8 @@ var CHECK_TRANSFORM_ORIGIN = function CHECK_TRANSFORM_ORIGIN(values) { } } }) - if (directions.length != 2 || directions.length === 2 && (directions[0] === 'vertical' || directions[1] === 'horizon')) { + if (directions.length != 2 || directions.length === 2 && + (directions[0] === 'vertical' || directions[1] === 'horizon')) { reasons.push(function (k, v) { return 'ERROR: Value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' }) @@ -1934,7 +1968,8 @@ var DATE_VALIDATOR = function DATE_VALIDATOR(v) { return { value: null, reason:function (k, v, result) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute is incorrect.' } } } @@ -1948,7 +1983,8 @@ var FILTER_VALIDATOR = function FILTER_VALIDATOR(v) { return { value: null, reason:function (k, v, result) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute is incorrect.' } } } @@ -1962,7 +1998,8 @@ var FILTER_PERCENTAGE_VALIDATOR = function FILTER_PERCENTAGE_VALIDATOR(v) { if (FILTER_STYLE_REGEXP.test(v)) { const values = v.trim().split(/\s+/) if(values[1] && values.length === 2){ - const blurStyleValidator = genEnumValidator(['small_light', 'medium_light', 'large_light', 'xlarge_light', 'small_dark', 'medium_dark', 'large_dark', 'xlarge_dark']) + const blurStyleValidator = genEnumValidator(['small_light', 'medium_light', 'large_light', 'xlarge_light', + 'small_dark', 'medium_dark', 'large_dark', 'xlarge_dark']) const blurStyleResult = blurStyleValidator(values[1]) if(util.isValidValue(blurStyleResult.value)){ return { value: v } @@ -1984,7 +2021,8 @@ var FILTER_PERCENTAGE_VALIDATOR = function FILTER_PERCENTAGE_VALIDATOR(v) { return { value: null, reason:function (k, v, result) { - return 'ERROR: The format of value `' + v + '` of the `' + util.camelCaseToHyphened(k) + '` attribute is incorrect.' + return 'ERROR: The format of value `' + v + '` of the `' + + util.camelCaseToHyphened(k) + '` attribute is incorrect.' } } } @@ -2198,7 +2236,8 @@ var RICH_PROP_NAME_GROUPS = { flexShrink: NUMBER_VALIDATOR, flexBasis: LENGTH_VALIDATOR, flexDirection: genEnumValidator(['row', 'column', 'column-reverse', 'row-reverse']), - justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly']), + justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', + 'space-around', 'space-evenly']), alignItems: genEnumValidator(['stretch', 'flex-start', 'flex-end', 'center', 'baseline']), alignContent: genEnumValidator(['stretch', 'flex-start', 'flex-end', 'center', 'space-between', 'space-around']), alignSelf: genEnumValidator(["auto", "flex-start", "flex-end", "center", "baseline", "stretch"]) @@ -2233,7 +2272,8 @@ var RICH_PROP_NAME_GROUPS = { fontSize: LENGTH_VALIDATOR, fontStyle: genEnumValidator(['normal', 'italic']), fontFamily: ANYTHING_VALIDATOR, - fontWeight: genEnumValidator(['normal', 'lighter', 'bold', 'bolder', "medium", "regular", '100', '200', '300', '400', '500', '600', '700', '800', '900']), + fontWeight: genEnumValidator(['normal', 'lighter', 'bold', 'bolder', "medium", "regular", '100', '200', '300', + '400', '500', '600', '700', '800', '900']), textDecoration: genEnumValidator(['none', 'underline', 'line-through']), textAlign: genEnumValidator(['start', 'end', 'left', 'center', 'right']), textOverflow: genEnumValidator(['clip', 'ellipsis']), @@ -2657,7 +2697,8 @@ var LITE_PROP_NAME_GROUPS = { flexbox: { flexDirection: genEnumValidator(['row', 'column']), flexWrap: genEnumValidator(['nowrap', 'wrap']), - justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly']), + justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', + 'space-around', 'space-evenly']), alignItems: genEnumValidator(['stretch', 'flex-start', 'flex-end', 'center']), }, position: { @@ -2778,7 +2819,8 @@ var CARD_PROP_NAME_GROUPS = { flexShrink: NUMBER_VALIDATOR, flexBasis: LENGTH_VALIDATOR, flexDirection: genEnumValidator(['row', 'column', 'column-reverse', 'row-reverse']), - justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly']), + justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between', + 'space-around', 'space-evenly']), alignItems: genEnumValidator(['stretch', 'flex-start', 'flex-end', 'center', 'baseline']), alignContent: genEnumValidator(['stretch', 'flex-start', 'flex-end', 'center', 'space-between', 'space-around']), }, @@ -2813,7 +2855,8 @@ var CARD_PROP_NAME_GROUPS = { letterSpacing: LENGTH_VALIDATOR, fontStyle: genEnumValidator(['normal', 'italic']), fontFamily: ANYTHING_VALIDATOR, - fontWeight: genEnumValidator(['normal', 'lighter', 'bold', 'bolder', "medium", "regular", '100', '200', '300', '400', '500', '600', '700', '800', '900']), + fontWeight: genEnumValidator(['normal', 'lighter', 'bold', 'bolder', "medium", "regular", '100', '200', '300', + '400', '500', '600', '700', '800', '900']), textDecoration: genEnumValidator(['none', 'underline', 'line-through']), textAlign: genEnumValidator(['start', 'end', 'left', 'center', 'right']), textOverflow: genEnumValidator(['clip', 'ellipsis']), @@ -2958,7 +3001,8 @@ function validate(name, value) { result = {value: value} var suggestedName = SUGGESTED_PROP_NAME_GROUP[name] var suggested = suggestedName ? ', suggest `' + util.camelCaseToHyphened(suggestedName) + '`' : '' - log = {reason: 'WARNING: `' + util.camelCaseToHyphened(name) + '` is not a standard attribute name and may not be supported' + suggested} + log = {reason: 'WARNING: `' + util.camelCaseToHyphened(name) + + '` is not a standard attribute name and may not be supported' + suggested} } return { value: result.value, diff --git a/src/json.js b/src/json.js index 7772f5dc40b6c2f0f975f6e1ea3c5b7845ad2235..3a36add11e45251259abff75d121cf8cbd1a5fba 100644 --- a/src/json.js +++ b/src/json.js @@ -47,7 +47,10 @@ module.exports = function (source) { return '"' + item + '"' }) source = source.replace(REG_THIS, item => { - if (item.charAt(item.length-1) !== '\"' && item.charAt(item.length-1) !== '\'' && item.slice(-2) !== '\"\,' && item.slice(-2) !== '\'\,') { + if (item.charAt(item.length-1) !== '\"' && + item.charAt(item.length-1) !== '\'' && + item.slice(-2) !== '\"\,' && + item.slice(-2) !== '\'\,') { if (item.charAt(item.length-1) === ',') { item = `"{{${transCardArray(item.slice(0, -1))}}}",`.replace(/this\./g, '') } else { diff --git a/src/script.js b/src/script.js index ad985510d16f822da8e4c314367682b88318bc5e..2504cd3dbbf1652014f563be7b9383e0e9c06350 100644 --- a/src/script.js +++ b/src/script.js @@ -43,10 +43,12 @@ module.exports = function (source, map) { if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH) { const appName = process.env.abilityType === 'page' ? 'app.js' : `${process.env.abilityType}.js` if (path.basename(this.resourcePath) !== appName) { - parsed += `\nvar moduleOwn = exports.default || module.exports;\nvar accessors = ['public', 'protected', 'private']; + parsed += `\nvar moduleOwn = exports.default || module.exports;\n` + + `var accessors = ['public', 'protected', 'private']; if (moduleOwn.data && accessors.some(function (acc) { return moduleOwn[acc]; - })) {\n throw new Error('For VM objects, attribute data must not coexist with public, protected, or private. Please replace data with public.'); + })) {\n throw new Error('For VM objects, attribute data must not coexist with public,` + + ` protected, or private. Please replace data with public.'); } else if (!moduleOwn.data) { moduleOwn.data = {};\n moduleOwn._descriptor = {};\n accessors.forEach(function(acc) { var accType = typeof moduleOwn[acc]; @@ -56,7 +58,8 @@ if (moduleOwn.data && accessors.some(function (acc) { moduleOwn._descriptor[name] = {access : acc}; } } else if (accType === 'function') { - console.warn('For VM objects, attribute ' + acc + ' value must not be a function. Change the value to an object.'); + console.warn('For VM objects, attribute ' + acc +` + + ` ' value must not be a function. Change the value to an object.'); }\n });\n}` } let result = `module.exports = function(module, exports, $app_require$){${parsed}}`