You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enable "import/no-duplicates": "error" (note we don't need prefer-inline because we don't use inline)
The reasoning is that we want import type to be like its own kind of statement that we know always gets dropped in the output Javascript, and in addition, if we were to have a rule where import {type foo} => import type {foo} only when there are no non-type imports in the statement, it would feel a bit inconsistent that it doesn't happen when there are non-type imports. The proposed rule is simpler: types always get imported in their own statement, and never have side effects
Each step should be its own PR, and they should be in the above order. Note that 1) must come before 2) because without 2), 1) should have no side effects, and then the effects of 2) should become more clear once 1) is in
The presence of this lint rule will obviously not affect auto-import behaviour since eslint doesn't change the tsconfig. The auto-import behaviour probably isn't too big of an issue anyway since we all have eslint autofix on save, I believe.
We want to proceed in the following steps, each in its own PR, in the following exact order:
"@typescript-eslint/consistent-type-imports": "error"
--verbatimModuleSyntax
TS flag"import/consistent-type-specifier-style": ["error", "prefer-top-level"]
"import/no-duplicates": "error"
(note we don't needprefer-inline
because we don't use inline)The reasoning is that we want
import type
to be like its own kind of statement that we know always gets dropped in the output Javascript, and in addition, if we were to have a rule whereimport {type foo}
=>import type {foo}
only when there are no non-type imports in the statement, it would feel a bit inconsistent that it doesn't happen when there are non-type imports. The proposed rule is simpler: types always get imported in their own statement, and never have side effectsEach step should be its own PR, and they should be in the above order. Note that 1) must come before 2) because without 2), 1) should have no side effects, and then the effects of 2) should become more clear once 1) is in
Note that we don't need
no-import-type-side-effects
lint rule because 2 and 3 won't allow us to have inlinetype
anywhereBefore merging each PR, we want to test the following cases:
For each of the above cases, we want to test:
Originally posted by @pokey in #1832 (comment)
The text was updated successfully, but these errors were encountered: