-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy path.eslintrc.js
More file actions
250 lines (203 loc) · 10.2 KB
/
.eslintrc.js
File metadata and controls
250 lines (203 loc) · 10.2 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// FOAM3 ESLint Configuration
//
// This configuration is designed to align with the FOAM3 Style Guide while being
// practical for the existing codebase. Many style rules are currently disabled
// due to codebase inconsistency, but are documented for future enablement.
//
// Key FOAM3 Style Guide Requirements:
// - 80 character line length (with exceptions for embedded data)
// - Spaces inside parentheses for control flow: if ( condition )
// - Space after ! operator: if ( ! found )
// - Single-line statements under 80 chars don't need braces
// - Vertical alignment encouraged for readability
// - No trailing commas
// - No unnecessary quote marks on object keys
// - CamelCase for models, camelCase for properties
// - Use == and != (not === and !==)
//
// Rules are organized by category with detailed explanations for easy
// configuration management. Change 'off' to 'error' or 'warn' to enable rules.
module.exports = {
env: {
browser: true,
node: true,
es6: true
},
extends: [
'eslint:recommended'
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'script'
},
globals: {
foam: 'readonly',
globalThis: 'writable'
},
rules: {
// =============================================================================
// INDENTATION AND SPACING
// =============================================================================
// FOAM3 uses 2 spaces for both indentation and line continuation (differs from Google)
// Currently disabled due to codebase inconsistency - enable when ready to enforce
'indent': ['off', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
FunctionDeclaration: { parameters: 1, body: 1 },
FunctionExpression: { parameters: 1, body: 1 },
CallExpression: { arguments: 1 },
ArrayExpression: 1,
ObjectExpression: 1
}],
// =============================================================================
// LINE LENGTH
// =============================================================================
// FOAM3 Style Guide: 80 character line length (with exceptions for embedded data)
// Currently set to 100 for leniency - change to 80 when ready to strictly enforce
'max-len': ['warn', {
code: 80, // FOAM3 standard is 80 characters
tabWidth: 2,
ignoreUrls: true,
ignoreStrings: true, // Allow long strings (embedded data exception)
ignoreTemplateLiterals: true, // Allow long templates (embedded data exception)
ignoreRegExpLiterals: true,
ignoreComments: true,
ignorePattern: '^\\s*//.*$' // Ignore comment lines
}],
// =============================================================================
// FOAM3 SPECIFIC SPACING RULES (based on style guide exceptions)
// =============================================================================
// FOAM3 requires spaces inside parentheses for control flow statements
// if ( condition ), for ( ... ), while ( ... ), switch ( ... )
'space-in-parens': ['off', 'always', { // Disabled - conflicts with selective application
exceptions: ['empty']
}],
// FOAM3 requires space after ! operator: if ( ! found )
'space-unary-ops': ['off', { // Disabled - would need custom rule for ! only
words: true,
nonwords: true
}],
// Standard spacing around operators (keep permissive for now)
'space-infix-ops': 'off',
// Standard spacing before blocks
'space-before-blocks': 'off',
// FOAM3 has specific keyword spacing requirements (spaces inside parens)
'keyword-spacing': 'off', // Disabled - conflicts with space-in-parens requirement
// =============================================================================
// OBJECT AND ARRAY FORMATTING
// =============================================================================
// FOAM3 Style Guide: Do not leave trailing unnecessary commas
'comma-dangle': ['error', 'never'], // Enforce no trailing commas
// FOAM3 Style Guide: Do not quote map keys unless necessary
'quote-props': ['error', 'as-needed'], // Only quote when necessary
// Object and array spacing - keep permissive for now
'object-curly-spacing': 'off',
'array-bracket-spacing': 'off',
// =============================================================================
// VARIABLE HANDLING
// =============================================================================
// Disabled for FOAM3 - framework has its own variable scoping patterns
'no-unused-vars': 'off', // FOAM3 models may have properties that appear unused
'no-undef': 'off', // FOAM3 uses global foam namespace and dynamic property access
'no-redeclare': 'off', // FOAM3 patterns may redeclare in different contexts
// =============================================================================
// VERTICAL ALIGNMENT SUPPORT
// =============================================================================
// FOAM3 encourages vertical alignment for readability
// These rules are disabled to allow vertical alignment patterns
'no-multi-spaces': 'off', // Allow multiple spaces for alignment
'key-spacing': 'off', // Allow flexible key spacing for alignment
// =============================================================================
// CODE QUALITY RULES
// =============================================================================
// Critical debugging and development rules
'no-console': 'off', // Allow console in FOAM3 development
'no-debugger': 'error', // Prevent debugger statements in production
'no-alert': 'error', // Prevent alert() usage
// =============================================================================
// SEMICOLONS AND SYNTAX
// =============================================================================
// Enforce semicolons for code correctness
'semi': ['error', 'always'],
'semi-spacing': 'off', // Be permissive about semicolon spacing
// =============================================================================
// QUOTES AND STRINGS
// =============================================================================
// Be permissive about quote style (FOAM3 mixes single and double quotes)
'quotes': 'off',
// =============================================================================
// CONTROL FLOW AND BRACES
// =============================================================================
// FOAM3 Style Guide: One-statement if, while, and for statements that can fit
// on a single line (less than 80 characters) do NOT NEED braces, but braces are allowed
// Examples: if ( ! found ) return false; ✓ (no braces)
// if ( ! found ) { return false; } ✓ (with braces, also fine)
// for ( var i = 0 ; i < a.length ; i++ ) a[i] = ''; ✓ (no braces)
'curly': 'off', // Allow both with and without braces for single-line statements
// Be permissive about brace style
'brace-style': 'off',
// =============================================================================
// FUNCTION FORMATTING
// =============================================================================
// Be permissive about function spacing
'space-before-function-paren': 'off',
// =============================================================================
// COMMA AND VARIABLE DECLARATION RULES
// =============================================================================
// Be permissive about comma spacing and style
'comma-spacing': 'off',
'comma-style': 'off',
// Allow multiple variable declarations (var a, b, c;)
'one-var': 'off',
// =============================================================================
// EQUALITY AND COMPARISON
// =============================================================================
// FOAM3 uses == and != extensively - disable strict equality checking
'eqeqeq': 'off', // Allow == and != (FOAM3 pattern)
// =============================================================================
// BEST PRACTICES
// =============================================================================
// Dot notation - be permissive (FOAM3 uses bracket notation for dynamic props)
'dot-notation': 'off',
// FOAM3 may use eval for dynamic code generation
'no-eval': 'off', // Allow eval in FOAM3 framework code
'no-implied-eval': 'off',
// Enforce good practices where they don't conflict with FOAM3
'no-new-wrappers': 'error', // Prevent new Boolean(), new String(), etc.
'no-throw-literal': 'error', // Require proper Error objects
'no-with': 'error', // Prevent with statements
'no-prototype-builtins': 'off', // FOAM3 may access prototype methods directly
// =============================================================================
// ES6+ FEATURES
// =============================================================================
// FOAM3 is not strictly ES6+ - allow var and traditional patterns
'prefer-const': 'off', // Allow var declarations
'no-var': 'off', // Allow var instead of let/const
// =============================================================================
// WHITESPACE AND FORMATTING
// =============================================================================
// Allow flexible whitespace for FOAM3's vertical alignment style
'no-multiple-empty-lines': ['warn', {
max: 3, // Allow up to 3 consecutive empty lines
maxEOF: 1,
maxBOF: 0
}]
},
overrides: [
{
// =============================================================================
// TEST FILES - RELAXED RULES
// =============================================================================
// Test files often need different formatting and may use console statements
files: ['**/*test*.js', '**/*spec*.js', '**/test/**/*.js'],
rules: {
'max-len': 'off', // Allow longer lines in tests for readability
'no-console': 'off', // Allow console statements in tests
'no-unused-vars': 'off', // Test variables may appear unused
'comma-dangle': 'off' // Be more relaxed about trailing commas in tests
}
}
]
};