I’m getting the following errors in SonarCloud:
Unexpected unknown unit "px;"
For the line:
margin-left: 4px;
or
Unexpected unknown unit "rem;"
For the line:
font-size: 1.2rem;
I have 57 errors in one only file with the same kind of error but associated to different units :
- “px;”
- “em;”
- “rem;”
- “;”
This is failing on this rule:
Units should be valid
The W3C specifications define the `units` that can be used with lengths. A unit that is not part of the list of supported ones is likely to be a typo and will be seen as a UI bug by the user.
This rule raises an issue each time a unit is not officially supported.
The error does not appear on all lines.
Css styles are defined in a file named base.html used on a polymerJs project and under <custom-style>
or <dom-module>
tags.
These errors always happen on a line defined under 2 css “parents”.
Example :
<dom-module id="my-mixins-style">
<template>
<style>
:host {
--my-input-border: {
border-radius: 1px;
};
}
</style>
</template>
</dom-module>
But when we have only 1 “parent”, no error is returned by Sonar on the same file.
Example :
<dom-module id="my-mixins-style">
<template>
<style>
:host {
border-radius: 1px;
}
</style>
</template>
</dom-module>
If it’s related to custom-syle used by polymerJs, the documentation validate to write it like this. See documentation : custom-style – API Reference - Polymer Project (polymer-project.org)
Is there anyway to remove these false positive ?
Information :
- SonarQube
- Community Edition
- Version 9.9.1 (build 69595)