No restricted path for two paths only work partially
#1,284 建立於 2019年2月11日
描述
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?