Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
stylelint-config-wordpress
Advanced tools
WordPress shareable config for stylelint.
Configuration rules to ensure your CSS is compliant with the WordPress CSS Coding Standards.
$ npm install stylelint-config-wordpress --save-dev
If you've installed stylelint-config-wordpress
locally within your project, just set your stylelint
config to:
{
"extends": "stylelint-config-wordpress"
}
If you've globally installed stylelint-config-wordpress
using the -g
flag, then you'll need to use the absolute path to stylelint-config-wordpress
in your config:
{
"extends": "/absolute/path/to/stylelint-config-wordpress"
}
In addition to the default preset, there are also specific presets. All presets extend the default one.
{
"extends": [
"stylelint-config-wordpress/scss"
]
}
Simply add a "rules"
key to your config and add your overrides there.
For example, to change the indentation
to four spaces and turn off the number-leading-zero
rule:
{
"extends": "stylelint-config-wordpress",
"rules": {
"indentation": 4,
"number-leading-zero": null
}
}
There are plenty of different methods for structuring a stylesheet. With the CSS in core, it is important to retain a high degree of legibility. This enables subsequent contributors to have a clear understanding of the flow of the document.
Correct:
#selector-1,
#selector-2,
#selector-3 {
background: #fff;
color: #000;
}
#selector-4 {
background: #fff;
color: #000;
}
Incorrect:
#selector-1, #selector-2, #selector-3 {
background: #fff;
color: #000;
}
#selector-1 { background: #fff; color: #000; }
With specificity, comes great responsibility. Broad selectors allow us to be efficient, yet can have adverse consequences if not tested. Location-specific selectors can save us time, but will quickly lead to a cluttered stylesheet. Exercise your best judgement to create selectors that find the right balance between contributing to the overall style and layout of the DOM.
div.container
can simply be stated as .container
Correct:
#comment-form {
margin: 1em 0;
}
input[type="text"] {
line-height: 1.1;
}
Incorrect:
#commentForm { /* Avoid camelcase. */
margin: 0;
}
#comment_form { /* Avoid underscores. */
margin: 0;
}
div#comment_form { /* Avoid over-qualification. */
margin: 0;
}
#c1-xr { /* What is a c1-xr?! Use a better name. */
margin: 0;
}
input[type=text] { /* Should be [type="text"] */
line-height: 110% /* Also doubly incorrect */
}
Similar to selectors, properties that are too specific will hinder the flexibility of the design. Less is more. Make sure you are not repeating styling or introducing fixed dimensions (when a fluid solution is more acceptable).
#fff
instead of #FFFFFF
.Correct:
#selector-1 {
background: #fff;
margin: 0;
margin-left: 20px;
}
Incorrect:
#selector-1 {
background:#FFFFFF;
margin-left: 20PX;
margin: 0;
}
“Group like properties together, especially if you have a lot of them.” — Nacin
Above all else, choose something that is meaningful to you and semantic in some way. Random ordering is chaos, not poetry. In WordPress Core, our choice is logical or grouped ordering, wherein properties are grouped by meaning and ordered specifically within those groups. The properties within groups are also strategically ordered to create transitions between sections, such as background directly before color. The baseline for ordering is:
Things that are not yet used in core itself, such as CSS3 animations, may not have a prescribed place above but likely would fit into one of the above in a logical manner. Just as CSS is evolving, so our standards will evolve with it.
Top/Right/Bottom/Left (TRBL/trouble) should be the order for any relevant properties (e.g. margin), much as the order goes in values. Corner specifiers (e.g. border-radius--) should be top-left, top-right, bottom-right, bottom-left. This is derived from how shorthand values would be ordered.
Example:
#overlay {
position: absolute;
z-index: 1;
padding: 10px;
background: #fff;
color: #777;
}
Another method that is often used, including by the Automattic/WordPress.com Themes Team, is to order properties alphabetically, with or without certain exceptions.
Example:
#overlay {
background: #fff;
color: #777;
padding: 10px;
position: absolute;
z-index: 1;
}
Updated on 2/13/2014, after 27174:
We use Autoprefixer as a pre-commit tool to easily manage necessary browser prefixes, thus making the majority of this section moot. For those interested in following that output without using Grunt, vendor prefixes should go longest (-webkit-) to shortest (unprefixed). All other spacing remains as per the rest of standards.
.sample-output {
-webkit-box-shadow: inset 0 0 1px 1px #eee;
-moz-box-shadow: inset 0 0 1px 1px #eee;
box-shadow: inset 0 0 1px 1px #eee;
}
There are numerous ways to input values for properties. Follow the guidelines below to help us retain a high degree of consistency.
400
instead of normal
, 700
rather than bold
).Correct:
.class { /* Correct usage of quotes */
background-image: url(images/bg.png);
font-family: "Helvetica Neue", sans-serif;
font-weight: 700;
}
.class { /* Correct usage of zero values */
font-family: Georgia, serif;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5),
0 1px 0 #fff;
}
Incorrect:
.class { /* Avoid missing space and semicolon */
background:#fff
}
.class { /* Avoid adding a unit on a zero value */
margin: 0px 0px 20px 0px;
}
.class {
font-family: Times New Roman, serif; /* Quote font names when required */
font-weight: bold; /* Avoid named font weights */
}
Media queries allow us to gracefully degrade the DOM for different screen sizes. If you are adding any, be sure to test above and below the break-point you are targeting.
wp-admin.css
file in core, as it is very large and each section essentially represents a stylesheet of its own. Media queries are therefore added at the bottom of sections as applicable.Correct:
@media all and (max-width: 699px) and (min-width: 520px) {
/* Your selectors */
}
@media screen and (color),
projection and (color) {}
Incorrect:
@media all and (max-width:699px) {
/* Your selectors */
}
@media all and (max-width :699px) {
/* Your selectors */
}
@media all and (max-width 699px) {
/* Your selectors */
}
@media all and (max-width>=699px) {
/* Your selectors */
}
@media all and (max-width >=699px) {
/* Your selectors */
}
@media all and (max-width>= 699px) {
/* Your selectors */
}
@media screen and (color), projection and (color) {}
@media screen and (color) ,
projection and (color) {}
SCRIPT_DEBUG
constant. Long comments should manually break the line length at 80 characters.Correct:
/**
* #.# Section title
*
* Description of section, whether or not it has media queries, etc.
*/
.selector {
float: left;
}
/**
* #.# Another section title
*
* Description of section, whether or not it has media queries, long comments
* should manually break the line length at 80 characters.
*/
.selector {
float: right;
}
/* This is a comment about this selector */
.another-selector {
position: absolute;
top: 0 !important; /* I should explain why this is so !important */
}
/* Long comments should manually break the line length at 80 characters. */
Incorrect:
/**
* #.# Section title
*
* Description of section, whether or not it has media queries, etc.
*/
.selector {
float: left;
}
/**
* #.# Another section title
*
* Description of section, whether or not it has media queries, long comments
* should manually break the line length at 80 characters.
*/
.selector {
float: right;
}
/* This is a comment about this selector */
.another-selector {
position: absolute;
top: 0 !important; /* I should explain why this is so !important */
}
/* Comments shouldn't have a line length greater than 80 characters, they should manually break the line length at 80 characters */
Stylesheets tend to get long in length. Focus slowly gets lost whilst intended goals start repeating and overlapping. Writing smart code from the outset helps us retain the overview whilst remaining flexible throughout change.
.box { margin-top: 37px }
..highlight
on the element as opposed to .highlight a
(where the selector is on the parent)display: block;
on block-level elements).11.0.0
declaration-property-unit-whitelist
rule to allow px
and exclude %
and em
units in line-height
values.at-rule-empty-line-before
rules in SCSS config.FAQs
WordPress shareable config for stylelint
The npm package stylelint-config-wordpress receives a total of 8,393 weekly downloads. As such, stylelint-config-wordpress popularity was classified as popular.
We found that stylelint-config-wordpress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.