Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Ordered imports grouping #4134

Merged
merged 9 commits into from
Jan 29, 2019
Merged

Commits on Jan 15, 2019

  1. Extend orderd-import rule with support for custom grouping.

    - Add configuration to support defining custom groups
      and ordering
    - Set a default grouping that replications the previous
      functionality of grouped-imports
    abierbaum committed Jan 15, 2019
    Configuration menu
    Copy the full SHA
    bb9beab View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e442835 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    12c633d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    67ac042 View commit details
    Browse the repository at this point in the history
  5. Rerun latest prettier.

    abierbaum committed Jan 15, 2019
    Configuration menu
    Copy the full SHA
    5bf1056 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2019

  1. Add comments and adjust internal variable naming.

    - added comments in an attempt to describe to others how the code
      is working.
    - update variable names to be a bit more clear about what is being
      tracked within the code.
    abierbaum committed Jan 16, 2019
    Configuration menu
    Copy the full SHA
    e68c575 View commit details
    Browse the repository at this point in the history
  2. Update orderedImports for standalone groups and source-order any

    This change updates the refactored "group" based orderedImports
    code to handle the cases fixed in the following previous PRs:
    
    - palantir#4374: fixed grouping for import-sources-order
    - palantir#3733: check all imports of same type are grouped
    
    As part of this we removed the concept of ImportType as this
    is now covered by the defined groups for sorting.
    
    Moved the check for ensuring groups are not standing alone
    into the code checkBlocksGroup() code where other group checks
    are done.
    
    Ex:
    ```
    import './baa';
    import './baz';
    
    import './caa';  // this should fail
    ```
    
    Also had to update several other test cases to include the failure
    notice about import groups needing to be together.
    abierbaum committed Jan 16, 2019
    Configuration menu
    Copy the full SHA
    d293ec8 View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2019

  1. Updates from review: grouping message, match name

    - Change the message shown when items are not grouped as expected
    
    The new message is more clear and understandable
    
    - Use a better default group name
    
    If a group has a regex and no name, the default name is now:
    
    /regex/
    
    This makes it more clear in the output that it is a regex and
    helps to keep the boundaries of the regex string more clear.
    abierbaum committed Jan 26, 2019
    Configuration menu
    Copy the full SHA
    1b65471 View commit details
    Browse the repository at this point in the history
  2. Remove check for grouping imports together by group.

    This check is already handled by the check for groups needing to be sorted.
    
    The idea is that once the first block of imports is found that has
    an import that is out of order, then all future blocks also have
    blocks out of order.  So instead of flagging all blocks we just flag
    the first block that is causing the issue and provide a fix that will
    fix all blocks.
    
    This makes the case for manually fixing the import ordering much more
    clear because people can solve one item at a time.  The automattic
    fixing is also more clear because we don't end up with multiple
    failures that have the same fix.
    abierbaum committed Jan 26, 2019
    Configuration menu
    Copy the full SHA
    82027be View commit details
    Browse the repository at this point in the history