stylus-help
Advanced tools
Comparing version 1.5.1 to 1.6.1
@@ -95,3 +95,3 @@ // Generated by CoffeeScript 1.8.0 | ||
processData = function(command, args) { | ||
var addError, alphabetizeCheck, arr, attr, attributeSet, attribute_info, breathing_room, buf, config, count, data, file, file_name, files, filesTotal, indent, index, infractions, join, line, line_num, line_number, obj, postJsonChecks, preJsonChecks, pre_spaces, processed, read_files, reg, rules, sizeOf, spaces, tag, tagFound, tag_found_test, total_return, val, z_index, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m; | ||
var addError, alphabetizeCheck, arr, attr, attributeSet, attribute_info, breathing_room, buf, config, count, data, file, file_name, files, filesTotal, indent, index, infractions, join, line, line_num, line_number, obj, postJsonChecks, preJsonChecks, pre_spaces, processed, read_files, reg, rules, sizeOf, spaces, tag, tagFound, tag_found_test, total_return, val, validate, z_index, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m; | ||
read_files = getFiles(args); | ||
@@ -110,3 +110,2 @@ switch (command) { | ||
alphabetize_check: 'This area needs to be alphabetized', | ||
dupe_tag_check: 'Duplicate tags found.. please consolidate', | ||
style_attribute_check: 'Invalid stylus declaration!' | ||
@@ -171,3 +170,3 @@ }; | ||
postJsonChecks = function() { | ||
var arr, att, attribute, attribute_info, check_1, check_2, comma_space, data, dupe, dupe_tag_check, file, file_name, index, key, line, line_num, lines, no_colon_semicolon, pair, s_ac, star_selector, style_attribute_check, stylus_stags, tag, total_tags, _i, _j, _len, _len1, _name, _ref, _ref1, _results; | ||
var att, attribute, attribute_info, check_1, check_2, comma_space, data, file, file_name, key, line, line_num, no_colon_semicolon, pair, s_ac, star_selector, style_attribute_check, stylus_stags, total_tags, _results; | ||
data = processData('convertStyleToJson', args); | ||
@@ -180,63 +179,54 @@ stylus_stags = []; | ||
star_selector = config.star_selector, style_attribute_check = config.style_attribute_check, no_colon_semicolon = config.no_colon_semicolon; | ||
comma_space = config.comma_space, dupe_tag_check = config.dupe_tag_check; | ||
comma_space = config.comma_space; | ||
_results = []; | ||
for (file_name in data) { | ||
file = data[file_name]; | ||
for (line_num in file) { | ||
attribute_info = file[line_num]; | ||
if (attribute_info.tag === '') { | ||
continue; | ||
} | ||
line = parseInt(line_num, 10); | ||
if (total_tags[_name = attribute_info.tag] == null) { | ||
total_tags[_name] = []; | ||
} | ||
total_tags[attribute_info.tag].push(line - 1); | ||
if (star_selector) { | ||
if (/\*/.test(attribute_info.tag)) { | ||
addError(star_selector, attribute_info.tag, line_num - 1, file_name); | ||
_results.push((function() { | ||
var _i, _len, _name, _ref, _ref1, _results1; | ||
_results1 = []; | ||
for (line_num in file) { | ||
attribute_info = file[line_num]; | ||
if (attribute_info.tag === '') { | ||
continue; | ||
} | ||
} | ||
_ref = attribute_info.rules; | ||
for (key = _i = 0, _len = _ref.length; _i < _len; key = ++_i) { | ||
attribute = _ref[key]; | ||
if (style_attribute_check) { | ||
att = attribute.trim(); | ||
pair = att.split(' '); | ||
if ((pair != null ? pair.length : void 0) === 2 && valid_selectors[pair[0]]) { | ||
if (_ref1 = pair[1], __indexOf.call(valid_selectors[pair[0]], _ref1) < 0) { | ||
s_ac = style_attribute_check; | ||
addError(s_ac, attribute, line + key, file_name); | ||
} | ||
} | ||
line = parseInt(line_num, 10); | ||
if (total_tags[_name = attribute_info.tag] == null) { | ||
total_tags[_name] = []; | ||
} | ||
if (no_colon_semicolon) { | ||
if (/;|:/.test(attribute)) { | ||
addError(no_colon_semicolon, attribute, line + key, file_name); | ||
total_tags[attribute_info.tag].push(line - 1); | ||
if (star_selector) { | ||
if (/\*/.test(attribute_info.tag)) { | ||
addError(star_selector, attribute_info.tag, line_num - 1, file_name); | ||
} | ||
} | ||
if (comma_space) { | ||
check_1 = attribute.match(/,/g); | ||
check_2 = attribute.match(/,\s/g); | ||
if ((check_1 != null ? check_1.length : void 0) !== (check_2 != null ? check_2.length : void 0)) { | ||
addError(comma_space, attribute, line + key, file_name); | ||
_ref = attribute_info.rules; | ||
for (key = _i = 0, _len = _ref.length; _i < _len; key = ++_i) { | ||
attribute = _ref[key]; | ||
if (style_attribute_check) { | ||
att = attribute.trim(); | ||
pair = att.split(' '); | ||
if ((pair != null ? pair.length : void 0) === 2 && valid_selectors[pair[0]]) { | ||
if (_ref1 = pair[1], __indexOf.call(valid_selectors[pair[0]], _ref1) < 0) { | ||
s_ac = style_attribute_check; | ||
addError(s_ac, attribute, line + key, file_name); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (dupe_tag_check) { | ||
for (tag in total_tags) { | ||
arr = total_tags[tag]; | ||
if (arr.length > 1) { | ||
lines = arr.join(','); | ||
for (index = _j = 0, _len1 = arr.length; _j < _len1; index = ++_j) { | ||
dupe = arr[index]; | ||
addError(dupe_tag_check, tag, dupe, file_name); | ||
if (no_colon_semicolon) { | ||
if (/;|:/.test(attribute)) { | ||
addError(no_colon_semicolon, attribute, line + key, file_name); | ||
} | ||
} | ||
if (comma_space) { | ||
check_1 = attribute.match(/,/g); | ||
check_2 = attribute.match(/,\s/g); | ||
if ((check_1 != null ? check_1.length : void 0) !== (check_2 != null ? check_2.length : void 0)) { | ||
addError(comma_space, attribute, line + key, file_name); | ||
} | ||
} | ||
} | ||
_results1.push(total_tags = []); | ||
} | ||
_results.push(total_tags = []); | ||
} else { | ||
_results.push(void 0); | ||
} | ||
return _results1; | ||
})()); | ||
} | ||
@@ -314,2 +304,21 @@ return _results; | ||
case 'convertStyleToJson': | ||
validate = (function(_this) { | ||
return function(_arg) { | ||
var rule, rules, tag, _j, _len1; | ||
tag = _arg.tag, rules = _arg.rules; | ||
if (!(tag && rules)) { | ||
return false; | ||
} | ||
for (_j = 0, _len1 = rules.length; _j < _len1; _j++) { | ||
rule = rules[_j]; | ||
if (/filter: url\(/.test(rule)) { | ||
return false; | ||
} | ||
} | ||
if (/@css/.test(tag)) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
})(this); | ||
total_return = {}; | ||
@@ -337,3 +346,3 @@ processed = 0; | ||
obj = {}; | ||
tag_found_test = /((\n|^)(\s)*(\.|&|>|#|@media).+)|(\n|^)(\s)*(table|td|th|tr|div|span|a|h1|h2|h3|h4|h5|h6|strong|em|quote|form|fieldset|label|input|textarea|button|body|img|ul|li|html|object|iframe|p|blockquote|abbr|address|cite|del|dfn|ins|kbd|q|samp|sup|var|b|i|dl|dt|dd|ol|legend|caption|tbody|tfoot|thead|article|aside|canvas|details|figcaption|figure|footer|header|hgroup|menu|nav|section|summary|time|mark|audio|video)(,| |\.|$).*/; | ||
tag_found_test = /((\n|^)(\s)*(\.|&|>|\#|@media).+)|(\n|^)(\s)*(table|td|th|tr|div|span|a|h1|h2|h3|h4|h5|h6|strong|em|quote|form|fieldset|label|input|textarea|button|body|img|ul|li|html|object|iframe|p|blockquote|abbr|address|cite|del|dfn|ins|kbd|q|samp|sup|var|b|i|dl|dt|dd|ol|legend|caption|tbody|tfoot|thead|article|aside|canvas|details|figcaption|figure|footer|header|hgroup|menu|nav|section|summary|time|mark|audio|video|circle|path|text|ellipse|line|polygon|polyline)(\:.+|,|\s|\.|$).*/; | ||
data = fs.readFileSync(file, 'utf8'); | ||
@@ -351,11 +360,16 @@ data = data.split('\n'); | ||
line = line != null ? line.replace(/^\s*\/\/.+/, '') : void 0; | ||
if (line.match(tag_found_test)) { | ||
if (tag_found_test.test(line)) { | ||
tagFound = true; | ||
if (attributeSet.length) { | ||
line_number = parseInt(line_num, 10) + 1 - attributeSet.length; | ||
obj[line_number] = { | ||
indent: indent, | ||
rules: attributeSet, | ||
tag: tag.trim() | ||
}; | ||
if (validate({ | ||
tag: tag, | ||
rules: attributeSet | ||
})) { | ||
obj[line_number] = { | ||
indent: indent, | ||
rules: attributeSet, | ||
tag: tag.trim() | ||
}; | ||
} | ||
attributeSet = []; | ||
@@ -381,7 +395,12 @@ indent = 0; | ||
line_number = parseInt(line_num, 10) - attributeSet.length; | ||
obj[line_number] = { | ||
indent: indent, | ||
rules: attributeSet, | ||
tag: tag.trim() | ||
}; | ||
if (validate({ | ||
tag: tag, | ||
rules: attributeSet | ||
})) { | ||
obj[line_number] = { | ||
indent: indent, | ||
rules: attributeSet, | ||
tag: tag.trim() | ||
}; | ||
} | ||
tag = ''; | ||
@@ -388,0 +407,0 @@ attributeSet = []; |
@@ -41,3 +41,3 @@ { | ||
}, | ||
"version": "1.5.1" | ||
"version": "1.6.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45283
673