소스 검색

Prettier

master
Dylan Baker 5 년 전
부모
커밋
fdc33c9f8d
3개의 변경된 파일15개의 추가작업 그리고 11개의 파일을 삭제
  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 파일 보기

@@ -38,7 +38,10 @@ export default class Lexer {
38 38
     while (this.position < this.source.length) {
39 39
       const result = this.getToken();
40 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 45
         this.tokens.push(result);
43 46
       }
44 47
 

+ 6
- 5
src/parser.ts 파일 보기

@@ -247,7 +247,11 @@ export default class Parser {
247 247
     const rules: AST.Rule[] = [];
248 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 255
       if (this.currentToken().type === TokenTypes.PROPERTY) {
252 256
         const propertyToken = this.eat(TokenTypes.PROPERTY);
253 257
         if (propertyToken instanceof ParserError) return propertyToken;
@@ -286,10 +290,7 @@ export default class Parser {
286 290
         if (this.nextToken().type === TokenTypes.FUNCTION_NAME)
287 291
           return this.application();
288 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 파일 보기

@@ -264,19 +264,19 @@ test('parses function call', (t) => {
264 264
 
265 265
 test('parses mixin', (t) => {
266 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 270
   t.false(result instanceof ParserError);
269 271
   if (!(result instanceof LexerError) && !(result instanceof ParserError)) {
270 272
     t.deepEqual(result.tree, [
271 273
       new AST.Mixin(
272 274
         literalToken('centered'),
273
-        [
274
-          identifierNode('width'),
275
-        ],
275
+        [identifierNode('width')],
276 276
         [
277 277
           new AST.Rule(
278 278
             new AST.Property(propertyToken('max-width')),
279
-            identifierNode('width'),
279
+            identifierNode('width')
280 280
           ),
281 281
           new AST.Rule(
282 282
             new AST.Property(propertyToken('margin')),

Loading…
취소
저장