Skip to content

Commit 88f9aae

Browse files
committed
Fix linting issues
1 parent 88757de commit 88f9aae

4 files changed

Lines changed: 95 additions & 3349 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"typescript": "^2.9.2"
1818
},
1919
"devDependencies": {
20-
"tslint": "^5.11.0",
20+
"tslint": "^5.12.1",
2121
"yarpm": "^0.2.1"
2222
}
2323
}

src/ReservedWords.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TokenType from './TokenType'
22

3-
const ReservedWords:{ [index: string] : TokenType } = {
3+
const ReservedWords: { [index: string]: TokenType } = {
44
and: TokenType.AND,
55
class: TokenType.CLASS,
66
else: TokenType.ELSE,
@@ -19,5 +19,4 @@ const ReservedWords:{ [index: string] : TokenType } = {
1919
while: TokenType.WHILE,
2020
}
2121

22-
2322
export default ReservedWords

src/Scanner.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import Lox from './Lox'
2+
import ReservedWords from './ReservedWords'
23
import Token from './Token'
34
import TokenType from './TokenType'
4-
import ReservedWords from './ReservedWords'
55

66
export default class Scanner {
77
/** Publicly available list of tokens, generated on construction of the class. */
88
public tokens: Token[] = []
99

1010
/** Source program stream to parse into tokens. */
1111
private source: string
12-
12+
1313
/** Start location of the current token in `this.source`. */
1414
private start = 0
1515

16-
/** Location in `this.stream` currently being examined. */
16+
/** Location in `this.stream` currently being examined. */
1717
private current = 0
1818

1919
/** Current line in `this.source`. Advanced each time `\n` is encountered. */
@@ -43,7 +43,7 @@ export default class Scanner {
4343
private isAlpha = (c: string) => (
4444
(c >= 'a' && c <= 'z') ||
4545
(c >= 'A' && c <= 'Z') ||
46-
c == '_'
46+
c === '_'
4747
)
4848

4949
/** Check if a character is alpha, numeric, or an underscore. */
@@ -132,7 +132,7 @@ export default class Scanner {
132132
/**
133133
* Checks if the next character in the stream is a specific character. If it is, advance the stream
134134
* by one character.
135-
* @param expected - A character to match next in the stream.
135+
* @param expected - A character to match next in the stream.
136136
* @returns true if the next character is expected, false otherwise.
137137
*/
138138
private match(expected: string): boolean {
@@ -181,11 +181,11 @@ export default class Scanner {
181181
}
182182

183183
/** Parse an identifier from the current position and add it to `this.tokens`. */
184-
private identifier() {
185-
while (this.isAlphaNumeric(this.peek())) this.advance();
184+
private identifier() {
185+
while (this.isAlphaNumeric(this.peek())) this.advance()
186186

187187
const { source, start, current } = this
188188
const text: string = source.substring(start, current)
189-
this.addToken(ReservedWords[text] || TokenType.IDENTIFIER);
190-
}
189+
this.addToken(ReservedWords[text] || TokenType.IDENTIFIER)
190+
}
191191
}

0 commit comments

Comments
 (0)