diff options
Diffstat (limited to 'sonar-css-plugin')
5 files changed, 80 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 a44da11..ab2a720 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 @@ -38,6 +38,7 @@ import org.sonar.css.plugin.rules.DeclarationBlockNoDuplicateProperties;  import org.sonar.css.plugin.rules.DeclarationBlockNoShorthandPropertyOverrides;  import org.sonar.css.plugin.rules.FontFamilyNoDuplicateNames;  import org.sonar.css.plugin.rules.FontFamilyNoMissingGenericFamilyKeyword; +import org.sonar.css.plugin.rules.FunctionLinearGradientNoNonstandardDirection;  import org.sonar.css.plugin.rules.KeyframeDeclarationNoImportant;  import org.sonar.css.plugin.rules.MediaFeatureNameNoUnknown;  import org.sonar.css.plugin.rules.NoDuplicateAtImportRules; @@ -78,6 +79,7 @@ public class CssRules {        DeclarationBlockNoShorthandPropertyOverrides.class,        FontFamilyNoDuplicateNames.class,        FontFamilyNoMissingGenericFamilyKeyword.class, +      FunctionLinearGradientNoNonstandardDirection.class,        KeyframeDeclarationNoImportant.class,        MediaFeatureNameNoUnknown.class,        NoDuplicateAtImportRules.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FunctionLinearGradientNoNonstandardDirection.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FunctionLinearGradientNoNonstandardDirection.java new file mode 100644 index 0000000..1f52b0f --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/FunctionLinearGradientNoNonstandardDirection.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 = "S4651") +public class FunctionLinearGradientNoNonstandardDirection implements CssRule { + +  @Override +  public String stylelintKey() { +    return "function-linear-gradient-no-nonstandard-direction"; +  } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.html new file mode 100644 index 0000000..20d64bb --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.html @@ -0,0 +1,30 @@ +<p><code>linear-gradient</code> was standardized with CSS3. Before that, it was possible to use different non-standard values to define the gradient's +direction. Because these values are not standard, they are not supported in all browsers and therefore they should no longer be used in order to get +the expected gradient in the latest browser versions that support CSS3.</p> +<p>This rule raises an issue when the first parameter of a <code>linear-gradient</code> is not a valid <code><side-or-corner></code> or +<code>angle</code>.</p> +<h2>Noncompliant Code Example</h2> +<pre> +.foo { +  background: linear-gradient(top, #fff, #000); +} + +.bar { +  background: linear-gradient(45, #fff, #000); +} +</pre> +<h2>Compliant Solution</h2> +<pre> +.foo { +  background: linear-gradient(to top, #fff, #000); +} + +.bar { +  background: linear-gradient(45deg, #fff, #000); +} +</pre> +<h2>See</h2> +<ul> +  <li> <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient#Syntax">MDN Specification</a> - linear gradient </li> +</ul> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.json new file mode 100644 index 0000000..a383afd --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4651.json @@ -0,0 +1,16 @@ +{ +  "title": "\"linear-gradient\" directions should be valid", +  "type": "BUG", +  "status": "ready", +  "remediation": { +    "func": "Constant\/Issue", +    "constantCost": "1min" +  }, +  "tags": [ +     +  ], +  "defaultSeverity": "Critical", +  "ruleSpecification": "RSPEC-4651", +  "sqKey": "S4651", +  "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 823c793..4fe2a7a 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 @@ -6,6 +6,7 @@      "S4647",      "S4648",      "S4649", +    "S4651",      "S4652",      "S4653",      "S4654", | 
