diff options
| author | Amaury Levé | 2018-06-26 10:16:36 +0200 | 
|---|---|---|
| committer | Elena Vilchik | 2018-06-26 12:28:30 +0200 | 
| commit | ce2d1faa94e608b5548bed628cf5294c516258c4 (patch) | |
| tree | 253f0335f4f6570128f5617e411322ed4324f91a | |
| parent | 8db7b98e916e6c5707c338bdd6dd607de15469f3 (diff) | |
| download | sonar-css-ce2d1faa94e608b5548bed628cf5294c516258c4.tar.bz2 | |
Rule S4660: Pseudo-element selectors should be valid
6 files changed, 66 insertions, 1 deletions
| diff --git a/its/plugin/projects/issues-project/src/file2.less b/its/plugin/projects/issues-project/src/file2.less index 7054386..fde33bf 100644 --- a/its/plugin/projects/issues-project/src/file2.less +++ b/its/plugin/projects/issues-project/src/file2.less @@ -17,7 +17,7 @@ a:unknown {                                                   /* S4659 | selecto  }  .class1 { -    width: 100px; +  width: 100px;  }  .class1 {                                                     /* S4666 | no-duplicate-selectors */ diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java index a66ce70..c463622 100644 --- a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java @@ -44,6 +44,7 @@ import org.sonar.css.plugin.rules.NoEmptySource;  import org.sonar.css.plugin.rules.NoExtraSemicolons;  import org.sonar.css.plugin.rules.PropertyNoUnknown;  import org.sonar.css.plugin.rules.SelectorPseudoClassNoUnknown; +import org.sonar.css.plugin.rules.SelectorPseudoElementNoUnknown;  import org.sonar.css.plugin.rules.SelectorTypeNoUnknown;  import org.sonar.css.plugin.rules.StringNoNewline;  import org.sonar.css.plugin.rules.UnitNoUnknown; @@ -80,6 +81,7 @@ public class CssRules {        NoExtraSemicolons.class,        PropertyNoUnknown.class,        SelectorPseudoClassNoUnknown.class, +      SelectorPseudoElementNoUnknown.class,        SelectorTypeNoUnknown.class,        StringNoNewline.class,        UnitNoUnknown.class diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/SelectorPseudoElementNoUnknown.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/SelectorPseudoElementNoUnknown.java new file mode 100644 index 0000000..06d6e4f --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/SelectorPseudoElementNoUnknown.java @@ -0,0 +1,31 @@ +/* + * SonarCSS + * Copyright (C) 2018-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. + */ +package org.sonar.css.plugin.rules; + +import org.sonar.check.Rule; + +@Rule(key = "S4660") +public class SelectorPseudoElementNoUnknown implements CssRule { + +  @Override +  public String stylelintKey() { +    return "selector-pseudo-element-no-unknown"; +  } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.html new file mode 100644 index 0000000..8c03492 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.html @@ -0,0 +1,15 @@ +<p>The W3C specifications define the valid pseudo-element selectors. Only the official and browser-specific pseudo-element selectors should be used to +get the expected impact in the final rendering.</p> +<h2>Noncompliant Code Example</h2> +<pre> +a::beforre { +... +} +</pre> +<h2>Compliant Solution</h2> +<pre> +a::before { +... +} +</pre> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.json new file mode 100644 index 0000000..ab98e82 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4660.json @@ -0,0 +1,16 @@ +{ +  "title": "Pseudo-element selectors should be valid", +  "type": "BUG", +  "status": "ready", +  "remediation": { +    "func": "Constant\/Issue", +    "constantCost": "1min" +  }, +  "tags": [ +     +  ], +  "defaultSeverity": "Major", +  "ruleSpecification": "RSPEC-4660", +  "sqKey": "S4660", +  "scope": "Main" +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json index 04a30dc..7e9fe85 100644 --- a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json @@ -14,6 +14,7 @@      "S4657",      "S4658",      "S4659", +    "S4660",      "S4663",      "S4666",      "S4667", | 
