import-js/eslint-plugin-import

Unexpected behavior when using `no-restricted-paths`

Open

#2,773 opened on Apr 28, 2023

 (3 comments) (0 reactions) (0 assignees)JavaScript (1,548 forks)batch import
help wanted

Repository metrics

Stars
 (5,940 stars)
PR merge metrics
 (PR metrics pending)

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