Under vite imports of *.vue files do not work without an explicit extension.
- Add a linter rule that will error when a *.vue file is imported without an explicit extension. (example)
- Fix existing imports
bd808 | |
Mar 1 2022, 5:34 PM |
F34973669: Screenshot 2022-03-03 at 12.03.16.png | |
Mar 3 2022, 11:04 AM |
F34972325: Screenshot 2022-03-02 at 11.50.24.png | |
Mar 2 2022, 1:33 PM |
Under vite imports of *.vue files do not work without an explicit extension.
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T288685 Establish active/active multi-dc support for Toolhub | |||
Resolved | bd808 | T115650 Create an authoritative and well promoted catalog of Wikimedia tools | |||
Resolved | bd808 | T271483 Complete and announce initial production deployment of Toolhub | |||
Resolved | sbassett | T273020 Security Readiness Review For Toolhub | |||
Open | None | T288551 Investigate replacing vue-cli with vite and webpack with rollup for Toolhub | |||
Open | None | T302820 Use explict .vue extension for Vue imports |
I haven't tried myself, but I think the upstream config for the rule (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md) implies that it can be tuned by extension.
The config that is working best so far for me is the one resulting in the above behavior:
{ "files": [ "vue/src/**/*.vue" ], "plugins": [ "import" ], "rules": { "import/extensions": [ "error", "ignorePackages", { "vue": "always" } ] }, "settings": { "import/resolver": { "alias": { "map": [ [ "@", "./src" ] ], "extensions": [ ".vue", ".js", ".json" ] } } } }
On the other hand, configuring the rule as "rules": { "import/extensions": [ "error", { "js": "never", "vue": "always" } ]}, results in all vue imports simply being ignored.
"rules": { "import/extensions": [ "error", "always", { "js": "never" } ]} is even more confusing as it complains about missing .js file extensions EXCEPT for the one import that actually has it, but according to the linter, shouldn't: