eslint-plugin-import
eslint-plugin-import copied to clipboard
Defining internal-regex and import/external-module-folders together yields unexpected errors
In our monorepo we store our internal packages under ./packages
So we tried a config like this:
rules: {
'import/order': 'warn',
},
settings: {
'import/internal-regex': '^internal-', // This makes importing monorepo packages get treated as though they were 'relative-parent-imports'
'import/external-module-folders': ['node_modules', 'packages'],
}
But that makes a non-relative import throw this unexpected error
import { foo } from 'internal-utils';
^--- // Relative imports from parent directories are not allowed.
We were able to workaround this with the following configuration in the meantime:
rules: {
'import/order': [
'error',
{
pathGroups: [
{
pattern: 'internal-*',
group: 'external',
position: 'after',
},
],
pathGroupsExcludedImportTypes: [],
},
],
},
settings: {
// 'import/internal-regex': '^internal-', // Disable this line
'import/external-module-folders': ['node_modules', 'packages'],
}