diff --git a/CHANGELOG b/CHANGELOG index ce18dc7b..4bfc6dc6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +July 10, 2017 - v1.0.5 + + + July 15, 2016 - v1.0.0 * Update parser-lib to v1.0.0. (XhmikosR) diff --git a/dist/cli.js b/dist/cli.js old mode 100644 new mode 100755 index 192d74e9..16f20dda --- a/dist/cli.js +++ b/dist/cli.js @@ -1,7 +1,7 @@ #!/usr/bin/env node /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal diff --git a/dist/csslint-node.js b/dist/csslint-node.js index 9f880233..d2011c3e 100644 --- a/dist/csslint-node.js +++ b/dist/csslint-node.js @@ -1,6 +1,6 @@ /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal @@ -41,7 +41,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "1.0.4"; + api.version = "1.0.5"; //------------------------------------------------------------------------- // Rule Management @@ -1303,6 +1303,72 @@ CSSLint.addRule({ }); +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); CSSLint.addRule({ // rule information diff --git a/dist/csslint-rhino.js b/dist/csslint-rhino.js index 2d01634c..4e76547a 100644 --- a/dist/csslint-rhino.js +++ b/dist/csslint-rhino.js @@ -1,6 +1,6 @@ /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal @@ -7332,6 +7332,10 @@ return require('parserlib'); var clone = (function() { 'use strict'; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} + var nativeMap; try { nativeMap = Map; @@ -7411,11 +7415,11 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { return parent; } - if (parent instanceof nativeMap) { + if (_instanceof(parent, nativeMap)) { child = new nativeMap(); - } else if (parent instanceof nativeSet) { + } else if (_instanceof(parent, nativeSet)) { child = new nativeSet(); - } else if (parent instanceof nativePromise) { + } else if (_instanceof(parent, nativePromise)) { child = new nativePromise(function (resolve, reject) { parent.then(function(value) { resolve(_clone(value, depth - 1)); @@ -7434,7 +7438,7 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { child = new Buffer(parent.length); parent.copy(child); return child; - } else if (parent instanceof Error) { + } else if (_instanceof(parent, Error)) { child = Object.create(parent); } else { if (typeof prototype == 'undefined') { @@ -7457,28 +7461,18 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { allChildren.push(child); } - if (parent instanceof nativeMap) { - var keyIterator = parent.keys(); - while(true) { - var next = keyIterator.next(); - if (next.done) { - break; - } - var keyChild = _clone(next.value, depth - 1); - var valueChild = _clone(parent.get(next.value), depth - 1); + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); child.set(keyChild, valueChild); - } + }); } - if (parent instanceof nativeSet) { - var iterator = parent.keys(); - while(true) { - var next = iterator.next(); - if (next.done) { - break; - } - var entryChild = _clone(next.value, depth - 1); + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); child.add(entryChild); - } + }); } for (var i in parent) { @@ -7605,7 +7599,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "1.0.4"; + api.version = "1.0.5"; //------------------------------------------------------------------------- // Rule Management @@ -8867,6 +8861,72 @@ CSSLint.addRule({ }); +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); CSSLint.addRule({ // rule information diff --git a/dist/csslint-tests.js b/dist/csslint-tests.js index 56d18001..73425326 100644 --- a/dist/csslint-tests.js +++ b/dist/csslint-tests.js @@ -1841,6 +1841,42 @@ function include(path, sandbox) { })(); +(function() { + "use strict"; + var Assert = YUITest.Assert; + + YUITest.TestRunner.add(new YUITest.TestCase({ + + name: "multi-rules-newline", + + "Multi rules must declear in multi lines": function() { + var result = CSSLint.verify(".foo.bar, .hehe { }", { "multi-rules-newline": 1 }); + Assert.areEqual("warning", result.messages[0].type); + Assert.areEqual("Multi rules must declear in multi lines.", result.messages[0].message); + } + + })); + +})(); + +(function() { + "use strict"; + var Assert = YUITest.Assert; + + YUITest.TestRunner.add(new YUITest.TestCase({ + + name: "rule-name", + + "Rule name must be concat with -, not _": function() { + var result = CSSLint.verify(".foo_name { }", { "rule-name": 1 }); + Assert.areEqual("warning", result.messages[0].type); + Assert.areEqual("Rule name must concat with -.", result.messages[0].message); + } + + })); + +})(); + (function() { "use strict"; var Assert = YUITest.Assert; diff --git a/dist/csslint-worker.js b/dist/csslint-worker.js index 52602c80..86bbcb10 100644 --- a/dist/csslint-worker.js +++ b/dist/csslint-worker.js @@ -1,6 +1,6 @@ /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal @@ -7328,6 +7328,10 @@ return require('parserlib'); var clone = (function() { 'use strict'; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} + var nativeMap; try { nativeMap = Map; @@ -7407,11 +7411,11 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { return parent; } - if (parent instanceof nativeMap) { + if (_instanceof(parent, nativeMap)) { child = new nativeMap(); - } else if (parent instanceof nativeSet) { + } else if (_instanceof(parent, nativeSet)) { child = new nativeSet(); - } else if (parent instanceof nativePromise) { + } else if (_instanceof(parent, nativePromise)) { child = new nativePromise(function (resolve, reject) { parent.then(function(value) { resolve(_clone(value, depth - 1)); @@ -7430,7 +7434,7 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { child = new Buffer(parent.length); parent.copy(child); return child; - } else if (parent instanceof Error) { + } else if (_instanceof(parent, Error)) { child = Object.create(parent); } else { if (typeof prototype == 'undefined') { @@ -7453,28 +7457,18 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { allChildren.push(child); } - if (parent instanceof nativeMap) { - var keyIterator = parent.keys(); - while(true) { - var next = keyIterator.next(); - if (next.done) { - break; - } - var keyChild = _clone(next.value, depth - 1); - var valueChild = _clone(parent.get(next.value), depth - 1); + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); child.set(keyChild, valueChild); - } + }); } - if (parent instanceof nativeSet) { - var iterator = parent.keys(); - while(true) { - var next = iterator.next(); - if (next.done) { - break; - } - var entryChild = _clone(next.value, depth - 1); + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); child.add(entryChild); - } + }); } for (var i in parent) { @@ -7601,7 +7595,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "1.0.4"; + api.version = "1.0.5"; //------------------------------------------------------------------------- // Rule Management @@ -8863,6 +8857,72 @@ CSSLint.addRule({ }); +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); CSSLint.addRule({ // rule information diff --git a/dist/csslint-wsh.js b/dist/csslint-wsh.js index 816a47f6..d538f3b9 100644 --- a/dist/csslint-wsh.js +++ b/dist/csslint-wsh.js @@ -1,6 +1,6 @@ /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal @@ -7332,6 +7332,10 @@ return require('parserlib'); var clone = (function() { 'use strict'; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} + var nativeMap; try { nativeMap = Map; @@ -7411,11 +7415,11 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { return parent; } - if (parent instanceof nativeMap) { + if (_instanceof(parent, nativeMap)) { child = new nativeMap(); - } else if (parent instanceof nativeSet) { + } else if (_instanceof(parent, nativeSet)) { child = new nativeSet(); - } else if (parent instanceof nativePromise) { + } else if (_instanceof(parent, nativePromise)) { child = new nativePromise(function (resolve, reject) { parent.then(function(value) { resolve(_clone(value, depth - 1)); @@ -7434,7 +7438,7 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { child = new Buffer(parent.length); parent.copy(child); return child; - } else if (parent instanceof Error) { + } else if (_instanceof(parent, Error)) { child = Object.create(parent); } else { if (typeof prototype == 'undefined') { @@ -7457,28 +7461,18 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { allChildren.push(child); } - if (parent instanceof nativeMap) { - var keyIterator = parent.keys(); - while(true) { - var next = keyIterator.next(); - if (next.done) { - break; - } - var keyChild = _clone(next.value, depth - 1); - var valueChild = _clone(parent.get(next.value), depth - 1); + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); child.set(keyChild, valueChild); - } + }); } - if (parent instanceof nativeSet) { - var iterator = parent.keys(); - while(true) { - var next = iterator.next(); - if (next.done) { - break; - } - var entryChild = _clone(next.value, depth - 1); + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); child.add(entryChild); - } + }); } for (var i in parent) { @@ -7605,7 +7599,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "1.0.4"; + api.version = "1.0.5"; //------------------------------------------------------------------------- // Rule Management @@ -8867,6 +8861,72 @@ CSSLint.addRule({ }); +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); CSSLint.addRule({ // rule information diff --git a/dist/csslint.js b/dist/csslint.js index 665e4a21..8f5aa555 100644 --- a/dist/csslint.js +++ b/dist/csslint.js @@ -1,6 +1,6 @@ /*! -CSSLint v1.0.4 -Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +CSSLint v1.0.5 +Copyright (c) 2017 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal @@ -7332,6 +7332,10 @@ return require('parserlib'); var clone = (function() { 'use strict'; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} + var nativeMap; try { nativeMap = Map; @@ -7411,11 +7415,11 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { return parent; } - if (parent instanceof nativeMap) { + if (_instanceof(parent, nativeMap)) { child = new nativeMap(); - } else if (parent instanceof nativeSet) { + } else if (_instanceof(parent, nativeSet)) { child = new nativeSet(); - } else if (parent instanceof nativePromise) { + } else if (_instanceof(parent, nativePromise)) { child = new nativePromise(function (resolve, reject) { parent.then(function(value) { resolve(_clone(value, depth - 1)); @@ -7434,7 +7438,7 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { child = new Buffer(parent.length); parent.copy(child); return child; - } else if (parent instanceof Error) { + } else if (_instanceof(parent, Error)) { child = Object.create(parent); } else { if (typeof prototype == 'undefined') { @@ -7457,28 +7461,18 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) { allChildren.push(child); } - if (parent instanceof nativeMap) { - var keyIterator = parent.keys(); - while(true) { - var next = keyIterator.next(); - if (next.done) { - break; - } - var keyChild = _clone(next.value, depth - 1); - var valueChild = _clone(parent.get(next.value), depth - 1); + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); child.set(keyChild, valueChild); - } + }); } - if (parent instanceof nativeSet) { - var iterator = parent.keys(); - while(true) { - var next = iterator.next(); - if (next.done) { - break; - } - var entryChild = _clone(next.value, depth - 1); + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); child.add(entryChild); - } + }); } for (var i in parent) { @@ -7605,7 +7599,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "1.0.4"; + api.version = "1.0.5"; //------------------------------------------------------------------------- // Rule Management @@ -8867,6 +8861,72 @@ CSSLint.addRule({ }); +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); CSSLint.addRule({ // rule information diff --git a/src/rules/ex-multi-rules-newline.js b/src/rules/ex-multi-rules-newline.js new file mode 100644 index 00000000..eb712e88 --- /dev/null +++ b/src/rules/ex-multi-rules-newline.js @@ -0,0 +1,38 @@ +CSSLint.addRule({ + + // rule information + id: "multi-rules-newline", + name: "Multi rules must declear in multi lines", + desc: "Multi rules must declear in multi lines", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + // console.log(selectors); + // console.log('*********************************************'); + // console.log(selectors[0].line); + // console.log(selectors[0].text); + // console.log(selectors[1].line); + // console.log(selectors[1].text); + //如果有多个rules + if (selectors.length > 1) { + var lines = []; + for (var i = 0; i < selectors.length; i++) { + var line = selectors[i].line; + if(lines.indexOf(line) !== -1){ + reporter.report("Multi rules must declear in multi lines.", selectors[i].line, selectors[i].col, rule); + return; + } + lines.push(line); + } + } + }); + } + +}); \ No newline at end of file diff --git a/src/rules/ex-rule-name.js b/src/rules/ex-rule-name.js new file mode 100644 index 00000000..034e85d7 --- /dev/null +++ b/src/rules/ex-rule-name.js @@ -0,0 +1,28 @@ +CSSLint.addRule({ + + // rule information + id: "rule-name", + name: "Rule name must concat with -", + desc: "Rule name must concat with -", + url: "", + browsers: "All", + + // initialization + init: function(parser, reporter) { + "use strict"; + var rule = this; + + parser.addListener("startrule", function(event) { + var selectors = event.selectors; + + for (var i = 0; i < selectors.length; i++) { + var text = selectors[i].text; + if(/[_]/.test(text)){ + reporter.report("Rule name must concat with -.", selectors[i].line, selectors[i].col, rule); + return; + } + } + }); + } + +}); \ No newline at end of file diff --git a/tests/rules/ex-multi-rules-newline.js b/tests/rules/ex-multi-rules-newline.js new file mode 100644 index 00000000..834b7542 --- /dev/null +++ b/tests/rules/ex-multi-rules-newline.js @@ -0,0 +1,17 @@ +(function() { + "use strict"; + var Assert = YUITest.Assert; + + YUITest.TestRunner.add(new YUITest.TestCase({ + + name: "multi-rules-newline", + + "Multi rules must declear in multi lines": function() { + var result = CSSLint.verify(".foo.bar, .hehe { }", { "multi-rules-newline": 1 }); + Assert.areEqual("warning", result.messages[0].type); + Assert.areEqual("Multi rules must declear in multi lines.", result.messages[0].message); + } + + })); + +})(); diff --git a/tests/rules/ex-rule-name.js b/tests/rules/ex-rule-name.js new file mode 100644 index 00000000..4fb10a96 --- /dev/null +++ b/tests/rules/ex-rule-name.js @@ -0,0 +1,17 @@ +(function() { + "use strict"; + var Assert = YUITest.Assert; + + YUITest.TestRunner.add(new YUITest.TestCase({ + + name: "rule-name", + + "Rule name must be concat with -, not _": function() { + var result = CSSLint.verify(".foo_name { }", { "rule-name": 1 }); + Assert.areEqual("warning", result.messages[0].type); + Assert.areEqual("Rule name must concat with -.", result.messages[0].message); + } + + })); + +})();