Skip to content

Commit 3f3c91c

Browse files
committed
Add section about using dash-cased for variable names
We want people to use a consistent style for variable names. We believe that simple rules are most likely to be followed, and that consistency is good, so we are settling on dash-cased, which is what we use for everything else, such as classes, mixins, functions, and properties. Along with this change, I am explicitly enabling the NameFormat SCSS-Lint rule which enforces this style. Note that this is enabled in SCSS-Lint by default, so this is functionally no different, but it is good to be explicit about things.
1 parent 0c5513e commit 3f3c91c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.scss-lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ linters:
1818
LeadingZero:
1919
enabled: false
2020

21+
NameFormat:
22+
enabled: true
23+
2124
PropertySortOrder:
2225
enabled: false
2326

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
1. [Sass](#sass)
1919
- [Syntax](#syntax)
2020
- [Ordering](#ordering-of-property-declarations)
21+
- [Variables](#variables)
2122
- [Mixins](#mixins)
2223
- [Extend directive](#extend-directive)
2324
- [Nested selectors](#nested-selectors)
@@ -240,6 +241,10 @@ Use `0` instead of `none` to specify that a style has no border.
240241
}
241242
```
242243

244+
### Variables
245+
246+
Prefer dash-cased variable names (e.g. `$my-variable`) over camelCased or snake_cased variable names. It is acceptable to prefix variable names that are intended to be used only within the same file with an underscore (e.g. `$_my-variable`).
247+
243248
### Mixins
244249

245250
Mixins should be used to DRY up your code, add clarity, or abstract complexity--in much the same way as well-named functions. Mixins that accept no arguments can be useful for this, but note that if you are not compressing your payload (e.g. gzip), this may contribute to unnecessary code duplication in the resulting styles.

0 commit comments

Comments
 (0)