Skip to content

no-absolute-path: TypeError: Cannot read property 'indexOf' of undefined #1616

Closed
@garyking

Description

@garyking

With this rule: 'import/no-absolute-path': 'error'

Type this code:

import eslint from e

The following error occurs:

[Error - 6:13:04 PM] ESLint stack trace:
[Error - 6:13:04 PM] TypeError: Cannot read property 'indexOf' of undefined
Occurred while linting test.ts:1
    at isAbsolute (node_modules/eslint-plugin-import/lib/core/importType.js:50:15)
    at reportIfAbsolute (node_modules/eslint-plugin-import/lib/rules/no-absolute-path.js:26:38)
    at checkSourceValue (node_modules/eslint-module-utils/moduleVisitor.js:29:5)
    at checkSource (node_modules/eslint-module-utils/moduleVisitor.js:34:5)
    at node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (node_modules/eslint/lib/linter/node-event-generator.js:297:14)

Should be an easy fix? I know that the error is probably because the from source should be quoted, but still, it shouldn't throw an error like that.

Activity

self-assigned this
on Feb 1, 2020
ljharb

ljharb commented on Feb 2, 2020

@ljharb
Member

Looks like this is actually a bug in the typescript parser, which shouldn’t parse this to begin with. Would you mind filing an issue with them?

skjnldsv

skjnldsv commented on Feb 24, 2020

@skjnldsv

Hey! Is this part of any new release?

ljharb

ljharb commented on Feb 24, 2020

@ljharb
Member

@skjnldsv yes, if you click on the closing commit, you can see that it's in v2.20.1.

added a commit that references this issue on Aug 30, 2024
4665ec5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @ljharb@garyking@skjnldsv

      Issue actions

        `no-absolute-path`: `TypeError: Cannot read property 'indexOf' of undefined` · Issue #1616 · import-js/eslint-plugin-import