Visitar URL original
`import/enforce-node-protocol-usage` broken · Issue #3173 · import-js/eslint-plugin-import · GitHub
Skip to content

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

Closed

Description

@jirimoravcik

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.

Activity

  1. ljharb commented on Apr 10, 2025

    @ljharb
    Member

    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.

  2. ljharb commented on Apr 10, 2025

    @ljharb
    Member

    Fixed in da5f6ec

  3. JounQin commented on Apr 10, 2025

    @JounQin
    Collaborator

    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.

  4. ljharb commented on Apr 10, 2025

    @ljharb
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions