On a similar note as the question ESLint - Only Allow Absolute Import Paths Not Relative
How can eslint made to error on absolute imports? Specifically interested in the context of TypeScript.
On a similar note as the question ESLint - Only Allow Absolute Import Paths Not Relative
How can eslint made to error on absolute imports? Specifically interested in the context of TypeScript.
You could try to use the rule @typescript-eslint/no-restricted-imports to disallow absolute imports (anything that does not start with ./ or ../).
{
rules: {
"no-restricted-imports": "off",
"@typescript-eslint/no-restricted-imports": [
"error",
{
"patterns": ["!./*", "!../*"]
}
]
}
}
@typescript-eslint/no-restricted-imports extends eslint/no-restricted-imports.
The reason why we disable eslint/no-restricted-imports is because it can report incorrect errors.
More information here.