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

import/order: Allow distinct grouping among same group types only for specific patterns #2708

Open
ZaeemKhaliq opened this issue Feb 7, 2023 · 0 comments

Comments

@ZaeemKhaliq
Copy link

I have following config: -

pathGroups: [
   {
     pattern: 'react**',
     group: 'external',
     position: 'before',
   },
   {
     pattern: 'gatsby**',
     group: 'external',
     position: 'before',
   },
   {
     pattern: '@chakra-ui/**',
     group: 'external',
     position: 'after',
   },
   {
     pattern: '@emotion/**',
     group: 'external',
     position: 'after',
   },
 ],

If distinctGroup is false, I get this: -

import React, { useState, useEffect } from 'react';
import { Link as GatsbyLink } from 'gatsby';
import { CloseIcon, ChevronDownIcon, ArrowBackIcon, ChevronRightIcon } from '@chakra-ui/icons';
import styled from '@emotion/styled';

If distinctGroup is true, I get this: -

import React, { useState, useEffect } from 'react';

import { Link as GatsbyLink } from 'gatsby';

import { CloseIcon, ChevronDownIcon, ArrowBackIcon, ChevronRightIcon } from '@chakra-ui/icons';

import styled from '@emotion/styled';

What I want to achieve: -

import React, { useState, useEffect } from 'react';
import { Link as GatsbyLink } from 'gatsby';

import { CloseIcon, ChevronDownIcon, ArrowBackIcon, ChevronRightIcon } from '@chakra-ui/icons';
import styled from '@emotion/styled';

Basically, I want to group style related libraries together, however all should belong to same external group.
Maybe an option like this can be included: -

pathGroups: [
   {
     pattern: 'react**',
     group: 'external',
     position: 'before',
   },
   {
     pattern: 'gatsby**',
     group: 'external',
     position: 'before',
   },
   {
     pattern: '@chakra-ui/**',
     group: 'external',
     position: 'after',
     isDistinct: true,  // This flag would indicate breaking into separate group for this and subsequent patterns for the same group type.
   },
   {
     pattern: '@emotion/**',
     group: 'external',
     position: 'after',
   },
 ],

Or anything else.
TIA for any help.

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

No branches or pull requests

1 participant