Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fa02a6d

Browse files
committed
Updating Sass guidelines
1 parent 513fd25 commit fa02a6d

File tree

1 file changed

+40
-58
lines changed

1 file changed

+40
-58
lines changed

_pages/css.md

+40-58
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ subnav:
4040
---
4141

4242
The purpose of the CSS coding styleguide is to create consistent CSS or
43-
preprocessor CSS code across TTS. The styleguide should be treated as a guide
43+
preprocessor CSS code (such as [Sass]) in your projects. The styleguide should be treated as a guide
4444
— rules can be modified according to project needs.
4545

4646
# Architecture
@@ -360,54 +360,26 @@ the difference will often be negligible once the output file has been gzipped.
360360
[placeholders]: http://thesassway.com/intermediate/understanding-placeholder-selectors
361361

362362
# Linting
363-
The styleguide provides a method of linting [Sass] code to ensure it conforms
364-
to the rules in the styleguide. This linting tool will go through all Sass code
365-
and issue warnings wherever the code differs from the styleguide. We've created
366-
a specific [`.scss-lint.yml` file][scss-lint yaml] that's configured to work
367-
with the css coding styleguide. There are two ways to set up linting:
368-
369-
* locally with ruby
370-
* locally with node
371-
372-
## Locally with ruby
373-
1. Add the [`.scss-lint.yml` file][scss-lint yaml] to the base of your
374-
repository.
375-
2. Install the [scss-lint] gem with `gem install scss_lint`
376-
3. Run scss-lint: `scss-lint app/assets/stylesheets/`
377-
378-
## Locally with node (experimental!)
379-
1. Run `npm install --save-dev @18f/stylelint-rules` to download the package and save it to your package.json
380-
2. The package provides both a gulp task and a cli interface. Detailed usage instructions can be found in the [README](https://github.com/18F/stylelint-rules)
381-
382-
## Shortcomings
383-
384-
### scss-lint
385-
386-
The scss-lint tool currently lacks the functionality to check these rules in
387-
the CSS coding styleguide:
388-
389-
- Does not limit line width to 80 characters
390-
- Does not check for numeric calculations in parentheses
391-
- Does not sort properties in quite the order we want (defaults to
392-
alphabetical)
393-
394-
### stylelint
395-
396-
This tool is still being evaluated, so not every rule in our current styleguide
397-
is supported by stylelint. scss-lint is purpose built for SCSS and is therefore
398-
a bit more feature rich. The following rules are currently not supported:
399-
400-
- PropertySpelling
401-
- UnecessaryParentReference
402-
403-
That being said, if you want to avoid a dependency on ruby in your project and
404-
still benefit from reliable SCSS linting, please test out this tool!
363+
Using a linter will ensure that [Sass] code conforms to some consistent rules. A linting tool like
364+
(Stylelint)[https://stylelint.io/] can issue warnings wherever your code differs from established rules.
365+
366+
## Setting up Stylelint locally
367+
1. Run `npm install --save-dev stylelint stylelint-config-standard` to download the package and save it to your package.json
368+
2. Create a .stylelintrc.json configuration file in the root of your project with the following content:
369+
```json
370+
{
371+
"extends": "stylelint-config-standard"
372+
}
373+
```
374+
3. Run Stylelint on all the CSS files in your project:
375+
`npx stylelint "**/*.css"`
405376

377+
This utilizes stylelint's standard rules configuration for css linting.
378+
If your project needs different rules or defaults, or you'd like to extend linting to other types of
379+
files, you can utilize custom syntaxes or write your own.
406380

407-
[Sass]: http://sass-lang.com/
408-
[scss-lint]: https://github.com/brigade/scss-lint
409-
[scss-lint yaml]: https://raw.githubusercontent.com/18F/frontend/18f-pages-staging/.scss-lint.yml
410-
[stylelint-rules]: https://github.com/18F/stylelint-rules
381+
Stylelint has a [user guide](https://stylelint.io/user-guide/get-started) that will give you more
382+
details about how to configure and extend your linting rules.
411383

412384
# Naming
413385
- HTML elements should be in lowercase.
@@ -607,21 +579,29 @@ Don't attach styles to classes with a `test-` flag. These classes are reserved f
607579
[mindbemding]: http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
608580

609581
# Preprocessors
610-
The most supported CSS preprocessor at TTS is [Sass](http://sass-lang.com/)
611-
(SCSS). Using this pre-processor means you'll get supported resources such as
612-
frameworks, libraries, tutorials, and a comprehensive styleguide as support.
613-
614-
In addition, TTS uses a [`.scss-lint.yml`
615-
file](https://raw.githubusercontent.com/18F/frontend/18f-pages-staging/.scss-lint.yml)
616-
to keep our CSS code compliant with our own styleguide.
582+
The most supported CSS preprocessor at TTS is [Sass]. Using this pre-processor means you'll
583+
get supported resources such as frameworks, libraries, tutorials, and a comprehensive styleguide
584+
as support.
617585

618586
_That being said, any preprocessor is allowed as long as it's a sound project
619587
and has community support._
620588

621-
The recommended way to compile your Sass code is through
622-
[node-sass](https://www.npmjs.com/package/node-sass), rather than Ruby Sass.
623-
This allows eliminating the Ruby dependency for projects that don't already
624-
require it and is the fastest method of compiling Sass.
589+
[Dart Sass](https://sass-lang.com/dart-sass) is the primary implementation of Sass and is
590+
recommended for use in your projects.
591+
592+
## Command line installation
593+
594+
### With npm
595+
596+
* run: `npm install -g sass`
597+
598+
### With homebrew
599+
600+
* run `brew install sass/sass/sass`
601+
602+
### Other installations
603+
604+
You can read about other installation methods on [their website](https://sass-lang.com/install).
625605

626606
# Specificity
627607
- IDs should be reserved for JavaScript. Don’t use IDs for styles.
@@ -918,3 +898,5 @@ color: $secondary;
918898
$small: new-breakpoint(min-width 0 max-width 40em 6);
919899
$medium: new-breakpoint(min-width 0 max-width 60em 6);
920900
```
901+
902+
[Sass]: http://sass-lang.com

0 commit comments

Comments
 (0)