Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to make ESLint error when import is any of package, except given imports

$
0
0

I have the following ESLint rule. This disallows MyImport1 and MyImport2 of being imported from my-package.

"no-restricted-imports": ["warn", {"paths": [    {"name": "my-package","importNames": ["MyImport1", "MyImport2"],"message": "Only MyImport1 and MyImport2 are allowed to use from this package."    }    ],}],

Now I would like to achieve the exact opposite. If I import any other import than these from this package, I would like to throw an error.

import { MyImport89 } from 'my-package'; // Show error: This is not MyImport1 or MyImport2

Would this be possible?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>