We use the following rules when linting files:
Bad:
.selector {border: 0; padding: 0;}
Good:
.selector {
border: 0;
padding: 0;
}
Bad:
.selector {
color: #005eb8;
}
Good:
.selector {
color: $colour_nhsuk-blue;
}
Bad:
$white: #FFF;
Good:
$white: #ffffff;
Bad:
.selector {
border: none;
}
Good:
.selector {
border: 0;
}
Bad:
#content {
...
}
Good:
.nhsuk-wrapper {
...
}
Bad:
p {
margin: 0;
em {
...
}
}
a {
...
}
Good:
p {
margin: 0;
em {
...
}
}
a {
...
}
Bad:
.nhsuk-breadcrumb {
...
&__item {
...
}
}
Good:
.nhsuk-breadcrumb {
...
}
.nhsuk-breadcrumb__item {
...
}
Bad:
@extend %contain-floats;
Good:
@include clearfix;
Bad:
margin: 1px 2px 3px 2px;
Good:
margin: 1px 2px 3px;
The basenames of @import
ed SCSS partials should not begin with an underscore and should not include the filename extension
Bad:
@import '_foo.scss';
@import '_bar/foo.scss';
Good:
@import 'foo';
@import 'bar/foo';
Bad:
.foo {
content:'bar';
}
Good:
.foo {
content: 'bar';
}
Operators should be formatted with a single space on both sides of an infix operator. These include +, -, *, /, %, ==, !=, >, >=, <,
and <=
Bad:
.selector {
margin: 5px+15px;
}
$foo: 1;
$bar: 3;
.selector {
margin: $foo+$bar+'px';
}
$foo: 1+1;
$bar: 2-1;
@if $foo==$bar {
$baz: 1;
}
@if ($foo!=$bar) {
$baz: 1;
}
Good:
.selector {
margin: 5px + 15px;
}
$foo: 1;
$bar: 3;
.selector {
margin: $foo + $bar + 'px';
}
$foo: 1 + 1;
$bar: 2 - 1;
@if $foo == $bar {
$baz: 1;
}
@if ($foo != $bar) {
$baz: 1;
}
Bad:
@function foo( $bar, $baz ) {
@return $bar + $baz;
}
Good:
@function foo($bar, $baz) {
@return $bar + $baz;
}
Functions, mixins, variables, and placeholders should be declared with all lowercase letters and hyphens instead of underscores
Bad:
@mixin FONT_STACK() {
font-family: $nhsuk-font-stack;
}
Good:
@mixin font-stack() {
font-family: $nhsuk-font-stack;
}
Bad:
.selector {
margin: 0px;
}
Good:
.selector {
margin: 0;
}
Bad:
.selector {
margin: 0
}
$my-example-var: value
Good:
.selector {
margin: 0;
}
$my-example-var: value;
Bad:
.selector {
font-size: 0.50em;
}
Good:
.selector {
font-size: 0.5em;
}
More write up on supported rules.
Next: Testing