diff options
Diffstat (limited to 'sonar-css-plugin')
5 files changed, 65 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 5248ff0..b2f3560 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 @@ -39,6 +39,7 @@ 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.KeyframeDeclarationNoImportant; +import org.sonar.css.plugin.rules.MediaFeatureNameNoUnknown;  import org.sonar.css.plugin.rules.NoDuplicateAtImportRules;  import org.sonar.css.plugin.rules.NoDuplicateSelectors;  import org.sonar.css.plugin.rules.NoEmptySource; @@ -77,6 +78,7 @@ public class CssRules {        FontFamilyNoDuplicateNames.class,        FontFamilyNoMissingGenericFamilyKeyword.class,        KeyframeDeclarationNoImportant.class, +      MediaFeatureNameNoUnknown.class,        NoDuplicateAtImportRules.class,        NoDuplicateSelectors.class,        NoEmptySource.class, diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/MediaFeatureNameNoUnknown.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/MediaFeatureNameNoUnknown.java new file mode 100644 index 0000000..88cedcd --- /dev/null +++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/rules/MediaFeatureNameNoUnknown.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 = "S4661") +public class MediaFeatureNameNoUnknown implements CssRule { + +  @Override +  public String stylelintKey() { +    return "media-feature-name-no-unknown"; +  } +} diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.html b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.html new file mode 100644 index 0000000..1c94ee3 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.html @@ -0,0 +1,15 @@ +<p>The W3C specifications define the valid media features. Only the official and browser-specific media features should be used to get the expected +impact in the final rendering.</p> +<h2>Noncompliant Code Example</h2> +<pre> +@media screen and (unknown: 1000px) { .. } +</pre> +<h2>Compliant Solution</h2> +<pre> +@media screen and (width: 1000px) { .. } +</pre> +<h2>See</h2> +<ul> +  <li> https://www.w3schools.com/cssref/css3_pr_mediaquery.asp </li> +</ul> + diff --git a/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.json b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.json new file mode 100644 index 0000000..d850955 --- /dev/null +++ b/sonar-css-plugin/src/main/resources/org/sonar/l10n/css/rules/css/S4661.json @@ -0,0 +1,16 @@ +{ +  "title": "Media features should be valid", +  "type": "BUG", +  "status": "ready", +  "remediation": { +    "func": "Constant\/Issue", +    "constantCost": "1min" +  }, +  "tags": [ +     +  ], +  "defaultSeverity": "Major", +  "ruleSpecification": "RSPEC-4661", +  "sqKey": "S4661", +  "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 73fa72d..bc74edf 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 @@ -15,6 +15,7 @@      "S4658",      "S4659",      "S4660", +    "S4661",      "S4662",      "S4663",      "S4666", | 
