Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linter: import/export with a typescript file only export type #7239

Closed
markEHVN opened this issue Nov 11, 2024 · 3 comments
Closed

linter: import/export with a typescript file only export type #7239

markEHVN opened this issue Nov 11, 2024 · 3 comments
Assignees
Labels
A-linter Area - Linter C-bug Category - Bug

Comments

@markEHVN
Copy link

What version of Oxlint are you using?

0.11.1

What command did you run?

yarn oxlint -c .oxlint.json

What does your .oxlint.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "categories": {
    "correctness": "allow"
  },
  "plugins": ["import"],
  "env": {
    "node": true
  },
  "globals": {},
  "settings": {},
  "rules": {
    "import/export": "error"
  }
}

What happened?

I caught an error when I try use import/export with an typescript only export type. ESLint plugin work well.

You can see source code at here

Screenshot 2024-11-12 at 00 12 25
@markEHVN markEHVN added A-linter Area - Linter C-bug Category - Bug labels Nov 11, 2024
@markEHVN markEHVN changed the title linter: import/export linter: import/export with a typescript file only export type Nov 11, 2024
@pumano
Copy link
Contributor

pumano commented Nov 11, 2024

I try to check it.

UPD: reason is:

if files contains only export type or export interface that marked as no named export. Continue digging...

looks like problem in ( I may be wrong):

fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration) {
if decl.export_kind.is_type() {
return;
}
// ignore all TypeScript syntax as they overload
if decl.is_typescript_syntax() {
return;
}

@Boshen
Copy link
Member

Boshen commented Nov 12, 2024

I try to check it.

UPD: reason is:

if files contains only export type or export interface that marked as no named export. Continue digging...

looks like problem in ( I may be wrong):

fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration) {
if decl.export_kind.is_type() {
return;
}
// ignore all TypeScript syntax as they overload
if decl.is_typescript_syntax() {
return;
}

Thank you for the investigation, this is the problem. We need to add type information the ModuleRecord 😢

@Boshen Boshen self-assigned this Nov 21, 2024
@Boshen
Copy link
Member

Boshen commented Dec 5, 2024

I think the best practice here is to use export type for proper tooling support.

I added support for export type * from 'mod' in #7676

by excluding type export syntax:

if star_export_entry.is_type {
  return;
}

Please forgive me for not checking for types, as tsc already does it, and it really complicates the import plugin.

@Boshen Boshen closed this as completed Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

No branches or pull requests

3 participants