Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make template token objects adhere token object structure #343

Merged
merged 3 commits into from Jul 10, 2017

Commits on Jun 21, 2017

  1. Make template token objects adhere token object structure

    While fixing an issue in `eslint-plugin-react`
    (jsx-eslint/eslint-plugin-react#1061),
    I noticed that template tokens differ from other tokens. A typical token
    looks like this:
    
    ```
    Token {
      type: 'String',
      value: '"bar"',
      start: 44,
      end: 49,
      loc:
       SourceLocation {
         start: Position { line: 4, column: 11 },
         end: Position { line: 4, column: 16 } },
      range: [ 44, 49 ] }
    ```
    
    A template token looks like this:
    
    ```
    { type: 'Template',
      value: '`bar`',
      loc:
       { start: Position { line: 4, column: 11 },
         end: Position { line: 4, column: 16 } },
      range: [ 44, 49 ] }
    ```
    
    I've not be able to figure out why templates are plain JavaScript
    objects and not of the class type `Token` (aside from the fact that the
    template tokens are constructed differently in the token translator.
    
    This fix copies the `range` values into `start` and `end` properties on
    the template tokens to make them adhere to the same structure as other
    token objects.
    
    Fixes eslint#319
    iancmyers committed Jun 21, 2017
    Copy the full SHA
    fd4c2ac View commit details
    Browse the repository at this point in the history
  2. Make template token objects adhere token object structure

    While fixing an issue in `eslint-plugin-react`
    (jsx-eslint/eslint-plugin-react#1061),
    I noticed that template tokens differ from other tokens. A typical token
    looks like this:
    
    ```
    Token {
      type: 'String',
      value: '"bar"',
      start: 44,
      end: 49,
      loc:
       SourceLocation {
         start: Position { line: 4, column: 11 },
         end: Position { line: 4, column: 16 } },
      range: [ 44, 49 ] }
    ```
    
    A template token looks like this:
    
    ```
    { type: 'Template',
      value: '`bar`',
      loc:
       { start: Position { line: 4, column: 11 },
         end: Position { line: 4, column: 16 } },
      range: [ 44, 49 ] }
    ```
    
    I've not be able to figure out why templates are plain JavaScript
    objects and not of the class type `Token` (aside from the fact that the
    template tokens are constructed differently in the token translator.
    
    This fix copies the `range` values into `start` and `end` properties on
    the template tokens to make them adhere to the same structure as other
    token objects.
    
    Fixes eslint#319
    iancmyers committed Jun 21, 2017
    Copy the full SHA
    289a848 View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2017

  1. Copy the full SHA
    438acc1 View commit details
    Browse the repository at this point in the history