Open boneskull opened 1 month ago
You can currently get this without a fixer by using:
'jsdoc/no-restricted-syntax': ['warn', {
contexts: [
{
comment: 'JsdocBlock:has(JsdocTag:has(JsdocTypeImport))',
context: 'any',
message: 'Use @import tag over import() statements',
},
],
}]
Motivation
I have a codebase littered with inline type-level imports (e.g.,
@type {import('foo').bar}
). I'd like to be able to put a halt to this madness and use import tags instead. I would especially like this to be a fixable rule.Current behavior
It's the wild west out there
Desired behavior
A rule which could raise an error if an inline type import was detected. Default behavior of this rule, when enabled, would be to always prefer import tags over inline imports.
Highly desired, but not required for a first pass:
Optionally:
foo
are an exception to the configured behavior)Alternatives considered
While TS itself supports JSDoc,
typescript-eslint
does not and will not support JSDoc.I thought about writing a codemod but that seems too complicated.
I am unsure how feasible this is or how difficult an implementation would be, so I apologize in advance if it's ridiculous.