aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--its/plugin/projects/issues-project/src/file1.css4
-rw-r--r--its/plugin/projects/issues-project/src/file2.less4
-rw-r--r--its/plugin/projects/issues-project/src/file3.scss4
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssRules.java2
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/PropertyNoUnknown.java31
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.html22
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4654.json16
-rw-r--r--sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/Sonar_way_profile.json1
8 files changed, 81 insertions, 3 deletions
diff --git a/its/plugin/projects/issues-project/src/file1.css b/its/plugin/projects/issues-project/src/file1.css
index 8d5bacb..68e9107 100644
--- a/its/plugin/projects/issues-project/src/file1.css
+++ b/its/plugin/projects/issues-project/src/file1.css
@@ -2,7 +2,7 @@
@import "a.css"; /* S1128 | no-duplicate-at-import-rules */
.class1 {
-background-color: #ffw; /* S4647 | color-no-invalid-hex */
+ background-color: #ffw; /* S4647 | color-no-invalid-hex */
width: 100pixels; /* S4653 | unit-no-unknown */
/* */ /* S4663 | comment-no-empty */
content: "first
@@ -11,12 +11,14 @@ background-color: #ffw; /* S4647 | color-n
color: orange; /* S4656 | declaration-block-no-duplicate-properties */
font: 1em/1.3 Times; /* S4649 | font-family-no-missing-generic-family-keyword */
font-family: serif, serif; /* S4648 | font-family-no-duplicate-names */
+ heigth: 100%; /* S4654 | property-no-unknown */
}
a {
color: pink;; /* S1116 | no-extra-semicolons */
}
+
@keyframes important1 {
from {
margin-top: 50px;
diff --git a/its/plugin/projects/issues-project/src/file2.less b/its/plugin/projects/issues-project/src/file2.less
index 072a687..f6718d5 100644
--- a/its/plugin/projects/issues-project/src/file2.less
+++ b/its/plugin/projects/issues-project/src/file2.less
@@ -2,7 +2,7 @@
@import "a.css"; /* S1128 | no-duplicate-at-import-rules | Doesn't raise for LESS */
.class1 {
-background-color: #ffw; /* S4647 | color-no-invalid-hex */
+ background-color: #ffw; /* S4647 | color-no-invalid-hex */
width: 100pixels; /* S4653 | unit-no-unknown */
/* */ /* S4663 | comment-no-empty */
content: "first
@@ -11,12 +11,14 @@ background-color: #ffw; /* S4647 | color-n
color: orange; /* S4656 | declaration-block-no-duplicate-properties */
font: 1em/1.3 Times; /* S4649 | font-family-no-missing-generic-family-keyword */
font-family: serif, serif; /* S4648 | font-family-no-duplicate-names */
+ heigth: 100%; /* S4654 | property-no-unknown */
}
a {
color: pink;; /* S1116 | no-extra-semicolons */
}
+
@keyframes important1 {
from {
margin-top: 50px;
diff --git a/its/plugin/projects/issues-project/src/file3.scss b/its/plugin/projects/issues-project/src/file3.scss
index 8d5bacb..68e9107 100644
--- a/its/plugin/projects/issues-project/src/file3.scss
+++ b/its/plugin/projects/issues-project/src/file3.scss
@@ -2,7 +2,7 @@
@import "a.css"; /* S1128 | no-duplicate-at-import-rules */
.class1 {
-background-color: #ffw; /* S4647 | color-no-invalid-hex */
+ background-color: #ffw; /* S4647 | color-no-invalid-hex */
width: 100pixels; /* S4653 | unit-no-unknown */
/* */ /* S4663 | comment-no-empty */
content: "first
@@ -11,12 +11,14 @@ background-color: #ffw; /* S4647 | color-n
color: orange; /* S4656 | declaration-block-no-duplicate-properties */
font: 1em/1.3 Times; /* S4649 | font-family-no-missing-generic-family-keyword */
font-family: serif, serif; /* S4648 | font-family-no-duplicate-names */
+ heigth: 100%; /* S4654 | property-no-unknown */
}
a {
color: pink;; /* S1116 | no-extra-semicolons */
}
+
@keyframes important1 {
from {
margin-top: 50px;
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",