Gathering detailed insights and metrics for stylelint-require-units
Gathering detailed insights and metrics for stylelint-require-units
Gathering detailed insights and metrics for stylelint-require-units
Gathering detailed insights and metrics for stylelint-require-units
A customizable stylelint plugin that lints for unit missing units
npm install stylelint-require-units
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (93.1%)
TypeScript (6.9%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Stars
16 Commits
1 Forks
1 Watchers
2 Branches
2 Contributors
Updated on Mar 13, 2023
Latest Version
2.0.0
Package Id
stylelint-require-units@2.0.0
Unpacked Size
24.32 kB
Size
5.28 kB
File Count
12
NPM Version
8.19.2
Node Version
16.18.0
Published on
Feb 20, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A customizable stylelint rule to require units for certain css properties.
By default the properties that are checked for units are:
border, border-bottom, border-bottom-left-radius, border-bottom-right-radius, border-bottom-width, border-image-outset, border-image-width, border-left, border-left-width, border-radius, border-right, border-right-width, border-spacing, border-top, border-top-left-radius, border-top-right-radius, border-top-width, border-width, bottom, box-shadow, column-rule-width, column-width, columns, font-size, grid-auto-columns, grid-auto-rows, grid-column-gap, grid-gap, grid-row-gap, grid-template, height, left, letter-spacing, line-height, margin, margin-bottom, margin-left, margin-right, margin-top, max-height, max-width, min-height, min-width, object-position, outline, outline-offset, outline-width, padding, padding-bottom, padding-left, padding-right, padding-top, perspective, perspective-origin, right, text-indent, text-shadow, top, transform, transform-origin, width, word-spacing
It will only check when numbers, or in the case of styled components, variables are used.
Functions are skipped by default, but there is an option to specify functions that are desired to be checked.
stylelint
(if you have not done so yet):1yarn add stylelint --dev
or
1npm install stylelint --save-dev
stylelint-require-units
:1yarn add stylelint-require-units -dev
or
1npm install stylelint-require-units -save-dev
.stylelintrc
config file (if you have not done so yet), add matterialize/stylelint-require-units
to the plugins array with the desired options as shown below.NOTE: true
is required to activate the plugin
1{ 2 "plugins": ["stylelint-require-units"], 3 "rules": { 4 "matterialize/stylelint-require-units": true 5 } 6}
All of the options below need to be keys in the second element object of the array with the first element of the array being true
.
By default the type of units are not checked by this plugin, just that the units exist. This option is added because styled components units are not linted when variables are used before a unit. This is an extra check to ensure variables are followed by units.
1{ 2 "plugins": ["stylelint-require-units"], 3 "rules": { 4 "matterialize/stylelint-require-units": [true, { 5 "checkUnknownUnits": true 6 }] 7 } 8}
By default 0 is not required to have units. If you have a stylist preference to include units for 0 this flag can be set to throw an error if 0 does not have units.
1{ 2 "plugins": ["stylelint-require-units"], 3 "rules": { 4 "matterialize/stylelint-require-units": [true, { 5 "forceZeroToRequireUnits": true 6 }] 7 } 8}
If you only want to check certain properties then you can use allowedProperties
and only those properties listed in the array will be checked.
NOTE: This can not be used with disallowedProperties
. It is either or.
1{ 2 "plugins": ["stylelint-require-units"], 3 "rules": { 4 "matterialize/stylelint-require-units": [true, { 5 "allowedProperties": ["width", "border"] 6 }] 7 } 8}
If you only want to check all default properties, but want to remove one or more properties from the default list, then you can use disallowedProperties
and only those properties listed in the default array will not be checked.
1{ 2 "plugins": ["stylelint-require-units"], 3 "rules": { 4 "matterialize/stylelint-require-units": [true, { 5 "disallowedProperties": ["width", "border"] 6 }] 7 } 8}
NOTE: This can not be used with allowedProperties
. It is either or.
If you want to check specific functions and you pass the function name(s) in the checkedFunctions
array.
1{ 2 "plugins": ["stylelint-require-units"], 3 "matterialize/stylelint-require-units": [true, { 4 "checkedFunctions": ["myCustomFunction1", "myCustomFunction2"] 5 }] 6}
New properties are added periodically and in order to future proof or provide extended properties that are not here, add these properties to additionalProperties
.
NOTE: These properties are additional to allowedProperties
or disallowedProperties
.
1{ 2 "plugins": ["stylelint-require-units"], 3 "matterialize/stylelint-require-units": [true, { 4 "additionalProperties": ["newProperty1", "newProperty2"] 5 }] 6}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
6 existing vulnerabilities detected
Details
Reason
Found 3/13 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More