Skip to content

Commit 3899710

Browse files
committed
Add rule re: switch colon spacing
1 parent b32b3b3 commit 3899710

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

etc/eslint/rules/style.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,50 @@ rules[ 'spaced-comment' ] = [ 'error', 'always', {
17661766
}
17671767
}];
17681768

1769+
/**
1770+
* Require a space after, but not before, `switch` colons.
1771+
*
1772+
* @name switch-colon-spacing
1773+
* @memberof rules
1774+
* @type {Array}
1775+
* @see [switch-colon-spacing]{@link http://eslint.org/docs/rules/switch-colon-spacing}
1776+
*
1777+
* @example
1778+
* // Bad...
1779+
* switch ( x ) {
1780+
* case 1 : break;
1781+
* }
1782+
*
1783+
* @example
1784+
* // Bad...
1785+
* switch ( x ) {
1786+
* case 1 :break;
1787+
* }
1788+
*
1789+
* @example
1790+
* // Bad...
1791+
* switch ( x ) {
1792+
* case 1:break;
1793+
* }
1794+
*
1795+
* @example
1796+
* // Okay...
1797+
* switch ( x ) {
1798+
* case 1: break;
1799+
* }
1800+
*
1801+
* @example
1802+
* // Good...
1803+
* switch ( x ) {
1804+
* case 1:
1805+
* break;
1806+
* }
1807+
*/
1808+
rules[ 'switch-colon-spacing' ] = [ 'error', {
1809+
'before': false,
1810+
'after': true
1811+
}];
1812+
17691813
/**
17701814
* Do not require a Unicode byte order mark (BOM), as we assume UTF-8.
17711815
*

0 commit comments

Comments
 (0)