Skip to content

prefer-default-export: Cannot read property 'type' of null #1965

@AriPerkkio

Description

@AriPerkkio

Hello, prefer-default-export rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything. https://github.com/AriPerkkio/eslint-remote-tester/actions/runs/417578540

Complete list of dependencies and .eslintrc is available at CI runs logs, steps Run yarn list | grep eslint and Run yarn log --config ./plugin-configs/eslint-config-airbnb.config.js.

eslint-config-airbnb@18.2.1
eslint-plugin-import@2.22.1
extends: ['airbnb', 'airbnb/hooks', 'airbnb/whitespace']

Minimal repro:

const items = ['A', 'B', 'C'];

export const [First,, Third] = items;
Crash reports from real-world examples

Rule: prefer-default-export

  • Message: Cannot read property 'type' of null Occurred while linting <text>:5
  • Path: houfio/dakpan/examples/counter-hoc/src/states/counter.ts
  • Link
import { createDakpan } from 'dakpan';

import { sleep } from '../utils/sleep';

export const [CounterProvider,, withCounter] = createDakpan({
  count: 0
})({
  increment: () => ({ count }) => ({
    count: count + 1
  }),
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:5
    at captureDeclaration (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-import/lib/rules/prefer-default-export.js:22:31)
    at Array.forEach (<anonymous>)
    at captureDeclaration(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-import/lib/rules/prefer-default-export.js:30:9)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-import/lib/rules/prefer-default-export.js:70:13
    at Array.forEach (<anonymous>)
    at ExportNamedDeclaration (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-import/lib/rules/prefer-default-export.js:69:41)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:254:26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions