-
Notifications
You must be signed in to change notification settings - Fork 2
/
whitespace.js
139 lines (113 loc) · 3.57 KB
/
whitespace.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
"use strict";
module.exports = {
rules: {
// disallow space inside array square brackets
"array-bracket-spacing": "error",
// require space before/after arrow function's arrow
"arrow-spacing": "error",
// require spaces inside of single-line blocks
"block-spacing": "error",
// enforce one true brace style
"brace-style": [
"error",
"stroustrup",
{
// allow opening and closing brace to be on the same line
allowSingleLine: true,
},
],
// enforce spacing after comma (but not before)
"comma-spacing": [
"warn",
{
before: false,
after: true,
},
],
// require commas to be placed at the ends of lines
"comma-style": "error",
// disallow space inside computed property square brackets
"computed-property-spacing": "error",
// specify the placement of dots in multi-line statements
"dot-location": [
"error",
"property",
],
// enforce newline at the end of file, with no multiple empty lines
"eol-last": "error",
// disallow spaces after the function name in function calls
"func-call-spacing": "error",
// specify 2-space indentation
indent: [
"error",
2, // 2 spaces
{
SwitchCase: 1, // indent multipler for "switch" "case" statements
VariableDeclarator: {
var: 2, // indent multiplier for multi-line "var" statements
let: 2, // indent multiplier for multi-line "let" statements
const: 3, // indent multiplier for multi-line "const" statements
},
},
],
// enforces spacing between keys and values in object literal properties
"key-spacing": [
"error",
{
beforeColon: false,
afterColon: true,
},
],
// require a space before and after keywords
"keyword-spacing": "error",
// disallow irregular whitespace outside of strings and comments
"no-irregular-whitespace": "error",
// disallow mixed spaces and tabs for indentation
"no-mixed-spaces-and-tabs": "error",
// disallow use of multiple spaces
"no-multi-spaces": [
"error",
{
ignoreEOLComments: true, // allow multiple spaces before end-of-line comments (like this one!)
}
],
// disallow trailing whitespace at the end of lines
"no-trailing-spaces": "error",
// require a space around curly braces in object literals
"object-curly-spacing": [
"error",
"always",
{
arraysInObjects: false,
objectsInObjects: false
}
],
// require linebreaks to be placed after operators
"operator-linebreak": "error",
// enforce spacing after semicolons
"semi-spacing": "error",
// disallow space before blocks
"space-before-blocks": "error",
// require a space between the function name and left paren in function definitions
"space-before-function-paren": "error",
// disallow spaces inside parentheses
"space-in-parens": "error",
// require spaces around operators
"space-infix-ops": "error",
// disallow spaces before/after unary operators
"space-unary-ops": "error",
// require a space at the start of a comment
"spaced-comment": [
"error",
"always",
{
line: {
exceptions: ["/"], // exceptions for line comments
},
block: {
exceptions: ["*", "!", "-", "=", "+"], // exceptions for block comments
},
},
],
}
};