Skip to content

import/enforce-node-protocol-usage broken #3173

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

Closed
jirimoravcik opened this issue Mar 28, 2025 · 4 comments
Closed

import/enforce-node-protocol-usage broken #3173

jirimoravcik opened this issue Mar 28, 2025 · 4 comments

Comments

@jirimoravcik
Copy link

The rule import/enforce-node-protocol-usage is not working with code containing the export keyword.

How to reproduce:

  1. Install @jirimoravcik/eslint-plugin-import with version 2.32.0-beta.0 as the rule was merged after 2.31.0 was released.
  2. Do 'import/enforce-node-protocol-usage': ['error', 'always'], in your eslint config
  3. Create a TS file with the following content:
export class Thing {
    constructor(public readonly name: string) {
        // Do nothing.
    }

    public sayHello(): void {
        console.log(`Hello, ${this.name}!`);
    }
}
  1. Try to lint it
  2. You'll get an error:
TypeError: Cannot read properties of null (reading 'type')
Rule: "import-fixed/enforce-node-protocol-usage"
at checkAndReport (/Users/jirimoravcik/.../node_modules/@jirimoravcik/eslint-plugin-import/lib/rules/enforce-node-protocol-usage.js:47:11)

I fixed by doing an early return in jirimoravcik@272d471, but I'm not sure if that's the proper solution.

Thanks for looking into it.

@ljharb
Copy link
Member

ljharb commented Apr 10, 2025

I'm confused, why are you installing @jirimoravcik/eslint-plugin-import? that's not this repo, and we can't support anything not installed from eslint-plugin-import on npm.

That said, I can reproduce it, and I've fixed it in the next version.

@ljharb
Copy link
Member

ljharb commented Apr 10, 2025

Fixed in da5f6ec

@ljharb ljharb closed this as completed Apr 10, 2025
@JounQin
Copy link
Collaborator

JounQin commented Apr 10, 2025

I'm confused, why are you installing @jirimoravcik/eslint-plugin-import? that's not this repo

I believe that's because the latest codes has not been released.

@ljharb
Copy link
Member

ljharb commented Apr 10, 2025

Sure - but that also means a) don't use it yet, and b) install from this repo, not a fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants