Skip to content

Add support for closing curly braces and closing parenthesis #1

@adlondon

Description

@adlondon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions