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

Add support for closing curly braces and closing parenthesis #1

Open
adlondon opened this issue Apr 18, 2018 · 0 comments
Open

Add support for closing curly braces and closing parenthesis #1

adlondon opened this issue Apr 18, 2018 · 0 comments

Comments

@adlondon
Copy link

adlondon commented Apr 18, 2018

Thanks for the great package, really useful for organizing larger files. I had an issue when sorting functions and const declarations, where any line with more than a single character gets sorted with the rest of its siblings.

Example:

export const createAddTrainersError = error => ({
  type: ADD_TRAINERS_ERROR,
  payload: error
});

function _updateUser(user) {
  return {
    type: UPDATE_USER,
    payload: user
  };
}

export const toggleModal = () => (dispatch) => {
  dispatch({
    type: ADD_TRAINER_TOGGLE_MODAL
  });
};

will be reformatted to:

export const createAddTrainersError = error => ({
  type: ADD_TRAINERS_ERROR,
  payload: error
export const toggleModal = () => (dispatch) => {
  dispatch({
    type: ADD_TRAINER_TOGGLE_MODAL
  });

function _updateUser(user) {
  return {
    type: UPDATE_USER,
    payload: user
  };
}

});
};

My somewhat messy solution was to change line 95 in the getTextBlocks function to:

if (line.trim().length === 1 || line[0] === '}' || line[0] === ')') {

Not sure what the most elegant way to handle something like this is. Happy to submit a PR if you are open to it or look into adding a keybinding that allows for this sort of thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant