- support for Stylelint less than 16.8.2 to use
fix()
callback for autofix (@planetmalone)
- npm published files to exclude READMEs and tests
- support for Stylelint less than 16.0.0 to migrate to ESM
alpha-values
false positives for<number>
ignoreFunctionArguments: []
option tospace
rule
The package name as been unscoped to stylelint-scales
and the scoped package has been deprecated.
You should replace the deprecated package:
npm uninstall @signal-noise/stylelint-scales && npm i -D stylelint-scales
{
- "plugins": ["@signal-noise/stylelint-scales"],
+ "plugins": ["stylelint-scales"],
"rules": {
"scales/alpha-values": [80, 90]
..
}
}
The font-families
rule has been removed so that the pack is for autofixable numeric scales. You should remove the rule from your config:
{
"rules": {
- "scales/font-families": ["sans-serif", "serif"]
..
}
}
font-families
rule
- Unscoped the package name to
stylelint-scales
ignoreFunctionArguments: []
option tofont-sizes
rule
stylelint@14
compatibility
- type error for system keywords in
font-families
- parse error for custom properties in
font-families
The plugin pack can now automatically fix all numeric scales!
A number of breaking changes were needed to make this possible.
A handful of rules were renamed to consistently use plurals:
border-width
toborder-widths
font-family
tofont-families
font-size
tofont-sizes
font-weight
tofont-weights
letter-spacing
toletter-spacings
line-height
toline-heights
word-spacing
toword-spacings
For example, you should change the following:
{
"rules": {
"scales/font-weight": [400, 600]
}
}
To:
{
"rules": {
"scales/font-weights": [400, 600]
}
}
Rules that check values with units now expect an array of objects for their primary option. Each object must specify two arrays:
scale
- a numerical scale of allowed valuesunits
- a list of units to apply the scale to
This replaces the unit
secondary option found on many of the rules.
For example, you should change the following:
{
"rules": {
"scales/font-size": [[1, 2], { "unit": "rem" }]
}
}
To:
{
"rules": {
"scales/font-sizes": [
{
"scale": [1, 2],
"units": ["rem"]
}
]
}
}
This will allow:
a {
font-size: 1rem;
}
You can now specify multiple units per scale, for example:
{
"rules": {
"scales/font-sizes": [
{
"scale": [1, 2],
"units": ["em", "rem"]
}
]
}
}
This will allow:
a {
font-size: 1em;
}
a {
font-size: 1rem;
}
And multiple scales per rule, for example:
{
"rules": {
"scales/font-sizes": [
{
"scale": [1, 2],
"units": ["rem"]
},
{
"scale": [12, 14],
"units": ["px"]
}
]
}
}
This will allow:
a {
font-size: 1rem;
}
a {
font-size: 12px;
}
The plugin pack no longer enforces the specified units. This is particularly useful when working with percentages and viewport units, which may not sit on a scale. You should use the declaration-property-unit-allowed-list rule in stylelint if you wish to enforce specific units.
For example, you should change the following:
{
"rules": {
"scales/font-size": [[1, 2], { "unit": "rem" }]
}
}
To:
{
"rules": {
"declaration-property-unit-allowed-list": {
"/^font$|^font-size$/": ["rem"]
},
"scales/font-sizes": [
{
"scale": [1, 2],
"units": ["rem"]
}
]
}
}
Appropriate regular expressions for the declaration-property-unit-allowed-list rule are documented in each of the rule READMEs.
The rules now, with the exception of font-families
, only accept numeric values. Non-numeric values in your CSS are now ignored.
For example, you should change the following:
{
"rules": {
"scales/font-weight": [400, 600, "bold"]
}
}
To:
{
"rules": {
"scales/font-weights": [400, 600]
}
}
Numeric font weights are appropriate for both non-variable fonts, e.g. 100, 200, 300 and so on, and variable fonts, which range from 1 to 1000.
The rules now check logical properties and gap properties, so more violations may be caught (and automatically fixed).
You no longer need to enclose top-level scale arrays in an array.
For example, you should change the following:
{
"rules": {
"scales/font-weight": [[400, 600]]
}
}
To:
{
"rules": {
"scales/font-weights": [400, 600]
}
}
The color
rule was removed. You should use CSS Variables for colours because, unlike numeric values and font family names, hex values and colour function notation are not human-readable. You can enforce a scale for alpha values using the new alpha-values
rule.
For example, you should change the following:
{
"rules": {
"scales/color": [
[
[0, 0, 0],
[255, 255, 255]
],
{
"alphaScale": [[0.5, 0.75]]
}
]
}
}
To:
{
"rules": {
"scales/alpha-values": [50, 75]
}
}
And write your CSS using CSS Variables for colour, for example:
a {
color: hsl(var(--accent) / 50%);
}
color
rule
- names to be consistently pluralised
- options signature for rules that check values with units
- rules now check logical properties and shorthand gap
alpha-values
rule- autofix to rules that check numeric scales
- per unit scales for rules that check values with units
- support for unenclosed array primary options
- support for Node 8
- unit display in messages for all relevant rules
- support non-numerical font-weights
- false positives for CSS global keywords in font shorthand declarations
border-width
false positives fornone
value
z-indices
ruleborder-width
ruleunit
option on unit dependent scales
- missing
sizes
documentation link
sizes
rulefont-family
ruleletter-spacing
ruleradii
ruleword-spacing
rule
unit
secondary options fromscales/font-size
andscales/space
scales/font-size
andscales/space
now check all font-relative and absolute length valuesscales/space
now checks themargin
,padding
andgrip-gap
longhand and shorthand properties, and no longer checks thebox-shadow
andborder
ones
- rationale in
README.md
- plugin name in example in
README.md
- documentation links in
package.json
- initial release