Skip to content

Glob Pattern Help #2900

Open
Open

Description

I am having significant issues getting the import order to accept my glob patterns for my internal import paths. I have the following 10 scenarios for what my imports look like when coming from libraries (im using NX tooling for my monorepo)

@lob/client-glist-menu-feature
@lob/client-glist-menu-data-access
@lob/client-glist-menu-ui
@lob/client-glist-menu-util
@lob/client-glist-menu-data
@lob/shared-feature-menu
@lob/shared-data-access-menu
@lob/shared-ui-menu
@lob/shared-util-menu
@lob/shared-data-menu

my import/order rules look like so:

"import/order": [
          1,
          {
            "groups": ["external", "builtin", "internal", "sibling", "parent", "index"],
            "pathGroups": [
              {
                "pattern": "**/*-feature-**",
                "group": "internal"
              },
              {
                "pattern": "**/*-data-access-*",
                "group": "internal"
              },
              {
                "pattern": "**/*-ui-*",
                "group": "internal"
              },
              {
                "pattern": "**/*-util-*",
                "group": "internal"
              },
              {
                "pattern": "**/*-data-!(access)*",
                "group": "internal"
              },
              {
                "pattern": "**/*-feature",
                "group": "internal"
              },
              {
                "pattern": "**/*-data-access",
                "group": "internal"
              },
              {
                "pattern": "**/*-ui",
                "group": "internal"
              },
              {
                "pattern": "**/*-util",
                "group": "internal"
              },
              {
                "pattern": "**/*-data",
                "group": "internal"
              }
            ],
            "newlines-between": "always",
            "alphabetize": {
              "order": "asc",
              "caseInsensitive": true
            }
          }
        ]

i have even used a Quokka scratchpad using the minimatch library to confirm that these minimatch patterns should seemingly be matching against my paths but the only thing thats actually happening in my files is the alphabetizing. For example this file's imports:

import { GlistFacadeService } from '@lob/client-glist-glists-data-access';
import { favoritedRecipeText, Recipe, unfavoritedRecipeText } from '@lob/client-glist-recipes-data';
import { RecipeFacadeService } from '@lob/client-glist-recipes-data-access';
import { ArrayUtils } from '@lob/client-shared-helpers-util';
import { ConfirmActionComponent } from '@lob/client-shared-user-actions-ui';
import { Ingredient } from '@lob/shared-ingredients-data';

I would expect to look like:

import { GlistFacadeService } from '@lob/client-glist-glists-data-access';
import { RecipeFacadeService } from '@lob/client-glist-recipes-data-access';
import { ConfirmActionComponent } from '@lob/client-shared-user-actions-ui';
import { favoritedRecipeText, Recipe, unfavoritedRecipeText } from '@lob/client-glist-recipes-data';
import { ArrayUtils } from '@lob/client-shared-helpers-util';
import { Ingredient } from '@lob/shared-ingredients-data';

I know eslint is set up correctly and running since the alphabetizing is working. Anyone have any suggestions as to why this is not working? Thank you!

Oddly enough i did previously have this set up correctly and it was working fine when i was using / instead of - in the import paths, but in an attempt to make my package.json names be valid i have changed all but the first / into -. my old (working) rules with my old import paths are below:

@lob/client/glist/menu/feature
@lob/client/glist/menu/data/access
@lob/client/glist/menu/ui
@lob/client/glist/menu/util
@lob/client/glist/menu/data
@lob/shared/feature/menu
@lob/shared/data/access/menu
@lob/shared/ui/menu
@lob/shared/util/menu
@lob/shared/data/menu

"import/order": [
          1,
          {
            "groups": ["external", "builtin", "internal", "sibling", "parent", "index"],
            "pathGroups": [
              {
                "pattern": "**/data",
                "group": "internal"
              },
              {
                "pattern": "**/data/**",
                "group": "internal"
              },
              {
                "pattern": "**/data-access",
                "group": "internal"
              },
              {
                "pattern": "**/data-access/**",
                "group": "internal"
              },
              {
                "pattern": "**/ui",
                "group": "internal"
              },
              {
                "pattern": "**/ui/**",
                "group": "internal"
              },
              {
                "pattern": "**/feature",
                "group": "internal"
              },
              {
                "pattern": "**/feature/**",
                "group": "internal"
              },
              {
                "pattern": "**/util",
                "group": "internal"
              },
              {
                "pattern": "**/util/**",
                "group": "internal"
              }
            ],
            "newlines-between": "always",
            "alphabetize": {
              "order": "asc",
              "caseInsensitive": true
            }
          }
        ]

something with the minimatch has stopped working when replacing the / with -

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions