diff options
| author | Amaury Levé | 2018-06-25 13:41:54 +0200 | 
|---|---|---|
| committer | Elena Vilchik | 2018-06-26 11:16:30 +0200 | 
| commit | 12d9eddb516233de212434b329a35e114c387c5c (patch) | |
| tree | 79b161c5787e98fc1b5bd60c764c59870d737bca /sonar-css-plugin/src | |
| parent | 7a31cb18a718601f31766cf8e02c6ad85f3916f0 (diff) | |
| download | sonar-css-12d9eddb516233de212434b329a35e114c387c5c.tar.bz2 | |
Rule S4654: CSS properties should be valid
Diffstat (limited to 'sonar-css-plugin/src')
5 files changed, 72 insertions, 0 deletions
| 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 689d361..87ff17b 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 @@ -40,6 +40,7 @@ import org.sonar.css.plugin.rules.KeyframeDeclarationNoImportant;  import org.sonar.css.plugin.rules.NoDuplicateAtImportRules;  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.StringNoNewline;  import org.sonar.css.plugin.rules.UnitNoUnknown; @@ -71,6 +72,7 @@ public class CssRules {        NoDuplicateAtImportRules.class,        NoEmptySource.class,        NoExtraSemicolons.class, +      PropertyNoUnknown.class,        StringNoNewline.class,        UnitNoUnknown.class      )); diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/PropertyNoUnknown.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/PropertyNoUnknown.java new file mode 100644 index 0000000..cb4e51d --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/PropertyNoUnknown.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 = "S4654") +public class PropertyNoUnknown implements CssRule { + +  @Override +  public String stylelintKey() { +    return "property-no-unknown"; +  } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.html new file mode 100644 index 0000000..18f759a --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.html @@ -0,0 +1,22 @@ +<p>The W3C specifications define the valid CSS properties. Only the official and browser-specific properties should be used to get the expected impact +in the final rendering.</p> +<p>This rule ignores:</p> +<p>- <code>$sass</code>, <code>@less</code>, and <code>var(--custom-property)</code> variable syntaxes.</p> +<p>- vendor-prefixed properties (e.g., <code>-moz-align-self</code>, <code>-webkit-align-self</code>).</p> +<h2>Noncompliant Code Example</h2> +<pre> +a { +  colour: blue; // Noncompliant: colour is not part of the specifications +} +</pre> +<h2>Compliant Solution</h2> +<pre> +a { +  color: blue; +} +</pre> +<h2>See</h2> +<ul> +  <li> https://github.com/known-css/known-css-properties#source </li> +</ul> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.json new file mode 100644 index 0000000..f466127 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.json @@ -0,0 +1,16 @@ +{ +  "title": "CSS properties should be valid", +  "type": "BUG", +  "status": "ready", +  "remediation": { +    "func": "Constant\/Issue", +    "constantCost": "5min" +  }, +  "tags": [ +     +  ], +  "defaultSeverity": "Blocker", +  "ruleSpecification": "RSPEC-4654", +  "sqKey": "S4654", +  "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 d7ae454..5c03bb6 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 @@ -8,6 +8,7 @@      "S4649",      "S4652",      "S4653", +    "S4654",      "S4655",      "S4656",      "S4658", | 
