import-js/eslint-plugin-import

No restricted path for two paths only work partially

Open

#1,284 opened on Feb 11, 2019

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

Repository metrics

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

Description

Usging Eslint with the no-restricted-paths pluging. This usually works nice, but right now I have rather peculiar behaviour.

I do not want to be able to import desktop components into mobile. And I do not want to import mobile components into desktop.

So I created these rules:

{
    "target": "./src/react/desktop",
    "from": "./src/react/mobile"
},
{
    "target": "./src/react/mobile",
    "from": "./src/react/desktop"
}

Then I tested this, importing a mobile component into a desktop component:

import ColorPalette from '../../mobile/design/components/ColorPalette';

And importing a desktop component into my mobile:

import {Button} from '../../../../desktop/Button';

Then running ESLint to see if I got errors.

There is where I discovered that it does work for desktop, where I get an error for importing the mobile ColorPalette.

However I did not get an error for importing the desktop item Button.

I also tried other files, and different variations of the import. Per example:

import {IconButton} from '../../../../desktop/IconButton';
import {IconButton} from '../../../../desktop/IconButton/IconButton';
import IconButton from '../../../../desktop/IconButton';
import IconButton from '../../../../desktop/IconButton/IconButton';

none of them triggered the error.

I also checked the spelling in the imports as well as the spelling in the config file. All point to the correct files and directories.

What could be the cause of this behaviour?

Contributor guide