-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
I want to disallow using namespaces as a rule, but some third-party libraries don't use default exports. The specific one that we use quite a bit in our application is yup. Even if we use TypeScript's allowSyntheticDefaultImports
rule, we still have to import the library using import * as yup from 'yup';
.
I'd like to be able to do something like the following:
rules: {
// ...
'import/no-namespace': ['warn', {allow: ['yup', 'some-lib', '@scoped/lib']}],
// ...
},
With the above config, the following would be considered correct:
import * as yup from 'yup';
import * as validation from 'yup';
import * as lib from 'some-lib';
And the following would be considered incorrect:
import * as nope from 'not-allowed';
// even though this contains the string "some-lib", it should not be valid; I think the allow list should be exact matches only
import * as stillNope from '@scoped/some-lib';
I came across pull request #1679 from earlier this year, but it appears it was closed without being merged.
Metadata
Metadata
Assignees
Labels
No labels