@@ -46,12 +46,17 @@ class TimelineParserLint extends TimelineParser {
46
46
private ignoreSyncOrder = false ;
47
47
// Capture lint errors separately from TimelineParser's errors so we can do a separate unit test
48
48
public lintErrors : LintError [ ] = [ ] ;
49
+ // TEMPORARY: To control scpe of linting & file changes; will remove in future PR
50
+ public _CURR_FILE = '' ;
51
+ private _EXPAC_FILTER = [ '05-shb' , '06-ew' ] ;
49
52
50
53
constructor (
51
54
text : string ,
52
55
triggers : LooseTimelineTrigger [ ] ,
56
+ filename : string , // TEMPORARY: Remove when all files are linted
53
57
) {
54
58
super ( text , [ ] , triggers ) ; // calls TimelineParser's parse() method
59
+ this . _CURR_FILE = filename ; // TEMPORARY: Remove when all files are linted
55
60
this . lintTimelineFile ( text ) ;
56
61
}
57
62
@@ -185,17 +190,22 @@ class TimelineParserLint extends TimelineParser {
185
190
return ;
186
191
187
192
// From this point, we should expect [time] [name] [type] [NetRegex]
188
- // So just check keyword ordering (everything after), and 'window' format .
193
+ // So just check keyword ordering & values (everything after).
189
194
const keywords = lineParts . slice ( 4 ) ;
190
195
if ( keywords . length === 0 )
191
196
return ;
192
197
193
- const keywordList = keywords . filter ( ( _ , i ) => i % 2 === 0 ) ;
194
- for ( let i = 0 ; i < keywordList . length - 1 ; i ++ ) {
195
- const thisKeyword = keywordList [ i ] ;
198
+ // Assume that every keyword comes in a [keyword] [param] format
199
+ // If we ever implement a keyword with no (or multiple) parameters, update this logic
200
+ for ( let i = 0 ; i < keywords . length ; i += 2 ) {
201
+ const thisKeyword = keywords [ i ] ;
196
202
if ( thisKeyword === undefined )
197
203
throw new UnreachableCode ( ) ;
198
204
205
+ // TEMPORARY: Remove when all files are linted
206
+ if ( ! this . _EXPAC_FILTER . some ( ( e ) => this . _CURR_FILE . includes ( e ) ) )
207
+ return ;
208
+
199
209
if ( ! syncKewordsOrder . includes ( thisKeyword ) ) {
200
210
this . lintErrors . push ( {
201
211
lineNumber : lineNumber ,
@@ -205,29 +215,42 @@ class TimelineParserLint extends TimelineParser {
205
215
return ;
206
216
}
207
217
218
+ const keywordParam = keywords [ i + 1 ] ;
219
+ if ( keywordParam === undefined ) {
220
+ this . lintErrors . push ( {
221
+ lineNumber : lineNumber ,
222
+ line : origLine ,
223
+ error : `Missing parameter for "${ thisKeyword } " keyword` ,
224
+ } ) ;
225
+ return ;
226
+ }
227
+
228
+ if (
229
+ ! isNaN ( parseFloat ( keywordParam ) ) &&
230
+ keywordParam . endsWith ( '.0' )
231
+ ) {
232
+ this . lintErrors . push ( {
233
+ lineNumber : lineNumber ,
234
+ line : origLine ,
235
+ error : `Unnecessary float "${ keywordParam } " - use an integer instead.` ,
236
+ } ) ;
237
+ // don't return; continue processing the line
238
+ }
239
+
208
240
// check that `window` is in a [number],[number] format
209
- if ( thisKeyword === 'window' ) {
210
- const windowKwIdx = keywords . indexOf ( 'window' ) ;
211
- const windowArgs = keywords [ windowKwIdx + 1 ] ;
212
- if ( windowArgs === undefined ) {
213
- this . lintErrors . push ( {
214
- lineNumber : lineNumber ,
215
- line : origLine ,
216
- error : `Missing parameter for 'window' keyword` ,
217
- } ) ;
218
- return ;
219
- }
220
- if ( ! / ^ \d + ( \. \d ) ? , \d + ( \. \d ) ? $ / . test ( windowArgs ) ) {
221
- this . lintErrors . push ( {
222
- lineNumber : lineNumber ,
223
- line : origLine ,
224
- error : `Invalid 'window' parameter "${ windowArgs } ": must be in [#],[#] format.` ,
225
- } ) ;
226
- // don't return; continue processing the line
227
- }
241
+ if (
242
+ thisKeyword === 'window' &&
243
+ ! / ^ \d + ( \. \d ) ? , \d + ( \. \d ) ? $ / . test ( keywordParam )
244
+ ) {
245
+ this . lintErrors . push ( {
246
+ lineNumber : lineNumber ,
247
+ line : origLine ,
248
+ error : `Invalid 'window' parameter "${ keywordParam } ": must be in [#],[#] format.` ,
249
+ } ) ;
250
+ // don't return; continue processing the line
228
251
}
229
252
230
- const nextKeyword = keywordList [ i + 1 ] ;
253
+ const nextKeyword = keywords [ i + 2 ] ;
231
254
if ( nextKeyword === undefined )
232
255
break ;
233
256
@@ -396,6 +419,7 @@ const testTimelineFiles = (timelineFiles: string[]): void => {
396
419
timeline = new TimelineParserLint (
397
420
timelineText ,
398
421
triggerSet . timelineTriggers ?? [ ] ,
422
+ timelineFile , // TEMPORARY: Remove when all files are linted
399
423
) ;
400
424
} ) ;
401
425
// This test loads an individual raidboss timeline and makes sure
0 commit comments