import-js/eslint-plugin-import

Unexpected behavior when using `no-restricted-paths`

Open

#2,773 opened on Apr 28, 2023

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (1,540 forks)batch import
help wanted

Repository metrics

Stars
 (4,946 stars)
PR merge metrics
 (Avg merge 138d 22h) (3 merged PRs in 30d)

Description

I want a certain directory to only be able to import from one other directory or child directories.

I have the following config:

    "import/no-restricted-paths": ["warn", {
      "zones": [
        {
          "target": "./src/blah/scripts/*",
          "from": "./src/**",
          "except": [
            "**/src/sdk/*",
            "**/src/blah/scripts/**/*"
          ],
          "message": "Scripts must only use the \"sdk\" module."
        }
      ]
    }],

I wouldn't expect to need the ** at the front of the except rules. Am I doing something wrong?

Contributor guide