Skip to content

[no-restricted-imports] 2 pattern rules with different globs and allowTypeImports break validation #4895

@elado

Description

@elado
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/<rule>": ["error", {
	    "patterns": [
	      {
	        "group": [
	          "import1/private/*"
	        ],
	        "message": "usage of import1 private modules not allowed.",
	        "allowTypeImports": true
	      },
	      {
	        "group": [
	          "import2/private/*"
	        ],
	        "message": "usage of import2 private modules not allowed.",
	        "allowTypeImports": true
	      }
	    ]
	  }]
  }
}
import type {foo} from 'import1/private/bar'; 
import type {foo} from 'import2/private/bar';

Expected Result

Both type imports should be valid.

Actual Result

Both imports fail lint.

Additional Info

If only one allowTypeImports pattern rule exists, it works. Once I enable two rules, both break.

A failing test case for no-restricted-imports.test.ts:

    {
      code: `
        import type {foo} from 'import1/private/foo';
        import type {bar} from 'import2/private/bar';
      `,
      options: [
        {
          patterns: [
            {
              group: ['import1/private/*'],
              message: 'usage of import1 private modules not allowed.',
              allowTypeImports: true,
            },
            {
              group: ['import2/private/*'],
              message: 'usage of import2 private modules not allowed.',
              allowTypeImports: true,
            },
          ],
        },
      ],
    },

Versions

package version
@typescript-eslint/eslint-plugin 5.22.0
@typescript-eslint/parser 5.22.0
TypeScript X.Y.Z
ESLint X.Y.Z
node X.Y.Z

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy