Skip to content

Commit

Permalink
Merge pull request #4460 from bogger33/master
Browse files Browse the repository at this point in the history
Remove/reclassify some csslint rules
  • Loading branch information
nightwing authored Mar 5, 2021
2 parents 150023b + 776e763 commit 2c87398
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 161 deletions.
160 changes: 0 additions & 160 deletions lib/ace/mode/css/csslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7154,52 +7154,6 @@ CSSLint.Util = {
}
};

/*
* Rule: Don't use adjoining classes (.foo.bar).
*/

CSSLint.addRule({

//rule information
id: "adjoining-classes",
name: "Disallow adjoining classes",
desc: "Don't use adjoining classes.",
browsers: "IE6",

//initialization
init: function(parser, reporter){
var rule = this;
parser.addListener("startrule", function(event){
var selectors = event.selectors,
selector,
part,
modifier,
classCount,
i, j, k;

for (i=0; i < selectors.length; i++){
selector = selectors[i];
for (j=0; j < selector.parts.length; j++){
part = selector.parts[j];
if (part.type === parser.SELECTOR_PART_TYPE){
classCount = 0;
for (k=0; k < part.modifiers.length; k++){
modifier = part.modifiers[k];
if (modifier.type === "class"){
classCount++;
}
if (classCount > 1){
reporter.report("Don't use adjoining classes.", part.line, part.col, rule);
}
}
}
}
}
});
}

});

/*
* Rule: Don't use width or height when using padding or border.
*/
Expand Down Expand Up @@ -8309,45 +8263,6 @@ CSSLint.addRule({

});

/*
* Rule: Headings (h1-h6) should not be qualified (namespaced).
*/

CSSLint.addRule({

//rule information
id: "qualified-headings",
name: "Disallow qualified headings",
desc: "Headings should not be qualified (namespaced).",
browsers: "All",

//initialization
init: function(parser, reporter){
var rule = this;

parser.addListener("startrule", function(event){
var selectors = event.selectors,
selector,
part,
i, j;

for (i=0; i < selectors.length; i++){
selector = selectors[i];

for (j=0; j < selector.parts.length; j++){
part = selector.parts[j];
if (part.type === parser.SELECTOR_PART_TYPE){
if (part.elementName && /h[1-6]/.test(part.elementName.toString()) && j > 0){
reporter.report("Heading (" + part.elementName + ") should not be qualified.", part.line, part.col, rule);
}
}
}
}
});
}

});

/*
* Rule: Selectors that look like regular expressions are slow and should be avoided.
*/
Expand Down Expand Up @@ -8720,81 +8635,6 @@ CSSLint.addRule({
}
});

/*
* Rule: Headings (h1-h6) should be defined only once.
*/

CSSLint.addRule({

//rule information
id: "unique-headings",
name: "Headings should only be defined once",
desc: "Headings should be defined only once.",
browsers: "All",

//initialization
init: function(parser, reporter){
var rule = this;

var headings = {
h1: 0,
h2: 0,
h3: 0,
h4: 0,
h5: 0,
h6: 0
};

parser.addListener("startrule", function(event){
var selectors = event.selectors,
selector,
part,
pseudo,
i, j;

for (i=0; i < selectors.length; i++){
selector = selectors[i];
part = selector.parts[selector.parts.length-1];

if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())){

for (j=0; j < part.modifiers.length; j++){
if (part.modifiers[j].type === "pseudo"){
pseudo = true;
break;
}
}

if (!pseudo){
headings[RegExp.$1]++;
if (headings[RegExp.$1] > 1) {
reporter.report("Heading (" + part.elementName + ") has already been defined.", part.line, part.col, rule);
}
}
}
}
});

parser.addListener("endstylesheet", function(){
var prop,
messages = [];

for (prop in headings){
if (headings.hasOwnProperty(prop)){
if (headings[prop] > 1){
messages.push(headings[prop] + " " + prop + "s");
}
}
}

if (messages.length){
reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
}
});
}

});

/*
* Rule: Don't use universal selector because it's slow.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/ace/mode/css_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Worker = exports.Worker = function(sender) {
this.ruleset = null;
this.setDisabledRules("ids|order-alphabetical");
this.setInfoRules(
"adjoining-classes|qualified-headings|zero-units|gradients|" +
"adjoining-classes|zero-units|gradients|box-model|" +
"import|outline-none|vendor-prefix"
);
};
Expand Down

0 comments on commit 2c87398

Please sign in to comment.