Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 91241ec

Browse files
author
Marlow Payne
authored
Merge pull request #132 from mobify/add-comment-spacing
✨ Add eslint rule to enforce comment whitespacing
2 parents 2a2f2f0 + 4879a88 commit 91241ec

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

β€ŽCHANGELOGβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# To be released
22
- Re-organized and cleaned up markdown linting files
33
- Switched to using `no-duplicate-headings-in-section` (instead of `no-duplicate-headings`)
4-
4+
- Add `spaced-comment` rule enforcement to ES5 and legacy (ESLint 1.x or lower) linting [#132](https://github.com/mobify/mobify-code-style/pull/132)
55
2.7.0
66
- Remove `variable-for-property` rule from sass-lint
77
- Adds markdown linting via `lint-md` script
88
- Add ESLint and Atom Text integration how-to doc
9-
109
2.6.0
1110
- Remove `variable-for-property` rule from sass-lint [#126](https://github.com/mobify/mobify-code-style/pull/126)
1211
- Add the eslint jsx-a11y plugin through a new `mobify-es6-react-a11y` configuration [#129](https://github.com/mobify/mobify-code-style/pull/129)
13-
1412
2.5.3
1513
- Fix #123 by using react/jsx-wrap-multilines rule
1614
- Migrate CSSComb documentation from Confluence to code style repo

β€Žes5/README.mdβ€Ž

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,24 @@ if (condition) {
4242

4343
In general, always favour comment placement that leads to less indenting.
4444

45-
4645
Don't commit commented out sections of code back into the repository. Just delete the code. That's what git's history is for!
4746

4847
If a piece of code is very temporarily being removed, and will be reinserted shortly, you might decide to do this anyway. Please leave a detailed comment explaining exactly why. Sorta like those post-its we leave on boxes in the fridge with our name and date so that we know when to chuck 'em out!
4948

49+
Comments should have whitespace beginning the comment:
50+
51+
````javascript
52+
//This is a bad comment πŸ‘Ž
53+
54+
// This is a good comment πŸ‘
55+
56+
/*This is
57+
*a bad multi-
58+
*line comment πŸ‘Ž */
59+
60+
/* This is a good
61+
* multi-line comment πŸ‘ */
62+
````
5063

5164
##Use single quotes
5265

β€Žes5/mobify-es5.ymlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ rules:
4646
- never
4747
space-infix-ops: error
4848
space-unary-ops: error
49+
spaced-comment: error
4950
no-undef: error
5051
eol-last: warn
5152
quotes:

β€Žjavascript/.eslintrcβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
// Disallow spacing around non-word unary operators: -, +, --, ++, !, !!
8585
"space-unary-ops": [2, { "words": true, "nonwords": false }],
8686

87+
// Enforce whitespace after the start of a comment (// or /*)
88+
"spaced-comment": 2,
89+
8790
// Disallow undeclared variables (unless mentioned in /*global ...*/ comment)
8891
"no-undef": 2,
8992

β€Žjavascript/README.mdβ€Ž

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,24 @@ if (condition) {
4545

4646
In general, always favour comment placement that leads to less indenting.
4747

48-
4948
Don't commit commented out sections of code back into the repository. Just delete the code. That's what git's history is for!
5049

5150
If a piece of code is very temporarily being removed, and will be reinserted shortly, you might decide to do this anyway. Please leave a detailed comment explaining exactly why. Sorta like those post-its we leave on boxes in the fridge with our name and date so that we know when to chuck 'em out!
5251

52+
Comments should have whitespace beginning the comment:
53+
54+
````javascript
55+
//This is a bad comment πŸ‘Ž
56+
57+
// This is a good comment πŸ‘
58+
59+
/*This is
60+
*a bad multi-
61+
*line comment πŸ‘Ž */
62+
63+
/* This is a good
64+
* multi-line comment πŸ‘ */
65+
````
5366

5467
##Use single quotes
5568

0 commit comments

Comments
Β (0)