Browse Source

Prettier

master
Dylan Baker 5 years ago
parent
commit
fdc33c9f8d
3 changed files with 15 additions and 11 deletions
  1. 4
    1
      src/lexer.ts
  2. 6
    5
      src/parser.ts
  3. 5
    5
      src/tests/parser.test.ts

+ 4
- 1
src/lexer.ts View File

38
     while (this.position < this.source.length) {
38
     while (this.position < this.source.length) {
39
       const result = this.getToken();
39
       const result = this.getToken();
40
       if (!(result instanceof Token)) return result;
40
       if (!(result instanceof Token)) return result;
41
-      if (result.type !== TokenTypes.WHITESPACE && result.type !== TokenTypes.COMMENT) {
41
+      if (
42
+        result.type !== TokenTypes.WHITESPACE &&
43
+        result.type !== TokenTypes.COMMENT
44
+      ) {
42
         this.tokens.push(result);
45
         this.tokens.push(result);
43
       }
46
       }
44
 
47
 

+ 6
- 5
src/parser.ts View File

247
     const rules: AST.Rule[] = [];
247
     const rules: AST.Rule[] = [];
248
     const children: AST.RuleSet[] = [];
248
     const children: AST.RuleSet[] = [];
249
 
249
 
250
-    while ([TokenTypes.PROPERTY, TokenTypes.LPAREN].includes(this.currentToken().type)) {
250
+    while (
251
+      [TokenTypes.PROPERTY, TokenTypes.LPAREN].includes(
252
+        this.currentToken().type
253
+      )
254
+    ) {
251
       if (this.currentToken().type === TokenTypes.PROPERTY) {
255
       if (this.currentToken().type === TokenTypes.PROPERTY) {
252
         const propertyToken = this.eat(TokenTypes.PROPERTY);
256
         const propertyToken = this.eat(TokenTypes.PROPERTY);
253
         if (propertyToken instanceof ParserError) return propertyToken;
257
         if (propertyToken instanceof ParserError) return propertyToken;
286
         if (this.nextToken().type === TokenTypes.FUNCTION_NAME)
290
         if (this.nextToken().type === TokenTypes.FUNCTION_NAME)
287
           return this.application();
291
           return this.application();
288
       default:
292
       default:
289
-        return this.error(
290
-          `Unexpected ${type}`,
291
-          this.currentToken()
292
-        );
293
+        return this.error(`Unexpected ${type}`, this.currentToken());
293
     }
294
     }
294
   }
295
   }
295
 
296
 

+ 5
- 5
src/tests/parser.test.ts View File

264
 
264
 
265
 test('parses mixin', (t) => {
265
 test('parses mixin', (t) => {
266
   t.plan(2);
266
   t.plan(2);
267
-  const result = parse('(@mixin centered ($width) :max-width $width :margin auto)');
267
+  const result = parse(
268
+    '(@mixin centered ($width) :max-width $width :margin auto)'
269
+  );
268
   t.false(result instanceof ParserError);
270
   t.false(result instanceof ParserError);
269
   if (!(result instanceof LexerError) && !(result instanceof ParserError)) {
271
   if (!(result instanceof LexerError) && !(result instanceof ParserError)) {
270
     t.deepEqual(result.tree, [
272
     t.deepEqual(result.tree, [
271
       new AST.Mixin(
273
       new AST.Mixin(
272
         literalToken('centered'),
274
         literalToken('centered'),
273
-        [
274
-          identifierNode('width'),
275
-        ],
275
+        [identifierNode('width')],
276
         [
276
         [
277
           new AST.Rule(
277
           new AST.Rule(
278
             new AST.Property(propertyToken('max-width')),
278
             new AST.Property(propertyToken('max-width')),
279
-            identifierNode('width'),
279
+            identifierNode('width')
280
           ),
280
           ),
281
           new AST.Rule(
281
           new AST.Rule(
282
             new AST.Property(propertyToken('margin')),
282
             new AST.Property(propertyToken('margin')),

Loading…
Cancel
Save