import-js/eslint-plugin-import

No restricted path for two paths only work partially

開放

#1,284 建立於 2019年2月11日

 (3 則留言) (1 個反應) (0 位負責人)JavaScript (1,549 個分叉)batch import
bughelp wanted

倉庫指標

星標
 (5,940 顆星)
PR 合併指標
 (平均合併 138天 22小時) (30 天內合併 3 個 PR)

描述

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?

貢獻者指南