Atom-beautify: beautifying a jsx file results in missing code 0.29.13

Created on 1 Dec 2016  路  4Comments  路  Source: Glavin001/atom-beautify

Atom 1.12.6

Description

The results of beautification are not what I expect.

Input Before Beautification

This is what the code looked like before:

import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    TouchableHighlight,
    Navigator
} from 'react-native';
import {styles} from './src/style'

const routes = [
    {
        title: 'Kishar Nine',
        index: 0
    }, {
        title: 'Counter',
        index: 1
    }
];

export default class kisharNine extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
          <Navigator
        initialRoute={{ title: 'My Initial Scene', index: 0 }}
        renderScene={(route, navigator) =>
          <MyScene
            title={route.title}

            // Function to call when a new scene should be displayed           
            onForward={ () => {    
              const nextIndex = route.index + 1;
              navigator.push({
                title: 'Scene ' + nextIndex,
                index: nextIndex,
              });
            }}

            // Function to call to go back to the previous scene
            onBack={() => {
              if (route.index > 0) {
                navigator.pop();
              }
            }}
          />
        }
      />
        );
    }
}

AppRegistry.registerComponent('kisharNine', () => kisharNine);

Expected Output

The beautified code should have looked like this:

I expect all my code to be there. What happened to onBack!?

Actual Output

The beautified code actually looked like this:

import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    TouchableHighlight,
    Navigator
} from 'react-native';
import {styles} from './src/style'

const routes = [
    {
        title: 'Kishar Nine',
        index: 0
    }, {
        title: 'Counter',
        index: 1
    }
];

export default class kisharNine extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <Navigator initialRoute={{
                title: 'My Initial Scene',
                index: 0
            }} renderScene={(route, navigator) => <MyScen title={route.title}>}/>
        );
    }
}

AppRegistry.registerComponent('kisharNine', () => kisharNine);

Steps to Reproduce

  1. Add code to Atom editor in file index.ios.js
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/anonymous/66ce808c1baff47968e203dd35d574d9/d2d88afa498597304feb57ca1d1fdcc3104bd989

Checklist

I have:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • [x] Generated debugging information and added link for debug.md Gist to this issue
third-party-bug

Most helpful comment

Problem is a failure of Pretty Diff's markup parser to accept JavaScript line comments as markup attributes. I will have a solution soon.

All 4 comments

Pretty Diff defect verified at http://prettydiff.com

Problem is a failure of Pretty Diff's markup parser to accept JavaScript line comments as markup attributes. I will have a solution soon.

Thanks, that actually helped. I took out the comments and it formatted fine.

Closing as a Pretty Diff bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkermani144 picture mkermani144  路  4Comments

PolGuixe picture PolGuixe  路  3Comments

physcocode picture physcocode  路  3Comments

edwardm picture edwardm  路  5Comments

callmeyesh picture callmeyesh  路  3Comments