Skip to content

"RangeError: Maximum call stack size exceeded" when file includes itself #210

Closed

Description

.eslintrc:

{
    "parserOptions": {
        "sourceType": "module",
    },
    "plugins": [
        "import"
    ],
    "rules": {
        "import/named": 2,
    }
}

import/named seems to be required for this to fail. Without that rule, eslint exits without error (as in the file passes the check)

Let's create a file that requires itself with the following code inside of it:

export { test } from './test.js'

...and name it test.js:

$ eslint --version
    v2.3.0

$ echo "export { test } from './test.js';" > test.js

$ eslint test.js
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at Array.forEach (native)
    at test/node_modules/eslint-plugin-import/lib/core/getExports.js:243:26
    at test/node_modules/eslint-plugin-import/lib/core/getExports.js:258:13
    at Array.forEach (native)
    at Function.parse (test/node_modules/eslint-plugin-import/lib/core/getExports.js:187:16)
    at Function._for (test/node_modules/eslint-plugin-import/lib/core/getExports.js:139:29)
    at ExportMap.resolveReExport (test/node_modules/eslint-plugin-import/lib/core/getExports.js:74:27)
    at test/node_modules/eslint-plugin-import/lib/core/getExports.js:241:41
    at test/node_modules/eslint-plugin-import/lib/core/getExports.js:258:13
    at Array.forEach (native)

Obviously it's a mistake that the file includes itself, but this plugin should warn, not crash, in that case.

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions