lint: Disallow utils index imports

This keeps leading to issues due to circular imports.
Import from specific files instead, index just reexports
This commit is contained in:
Vendicated 2022-11-07 23:34:14 +01:00
parent 955573d31b
commit f7d9be9140
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
22 changed files with 217 additions and 30 deletions

View file

@ -2,7 +2,12 @@
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["dist", "browser"],
"plugins": ["header", "simple-import-sort", "unused-imports"],
"plugins": [
"@typescript-eslint",
"header",
"simple-import-sort",
"unused-imports"
],
"rules": {
// Since it's only been a month and Vencord has already been stolen
// by random skids who rebranded it to "AlphaCord" and erased all license
@ -88,6 +93,46 @@
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"unused-imports/no-unused-imports": "error"
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/no-restricted-imports": [
"error",
{
"paths": [
// shrug, couldn't find a better way since the pattern one doesn't work:
// ["utils", "!utils/*"]
{
"name": "./utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
},
{
"name": "../utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
},
{
"name": "../../utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
},
{
"name": "../../../utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
},
{
"name": "../../../../utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
},
{
"name": "../../../../../utils",
"message": "Do not import from index. This might cause issues. Import from the specific file instead.",
"allowTypeImports": true
}
]
}
]
}
}