Skip to content

Exception on invalid argument to require. #213

@coreyfarrell

Description

@coreyfarrell

Issuehunt badges

The following code causes xo to crash:

const something = require(true);

Obviously this is not a valid thing to do, but it should cause eslint to report an error instead of throwing an exception. This is something I found with a test which verifies that my babel plugin does not blow up if a non-string is passed to require. For now I've had to add the test fixture files to xo.ignores in my package.json.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean
    at assertPath (path.js:39:11)
    at Object.resolve (path.js:1085:7)
    at isTestFile (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint-plugin-ava/rules/no-import-test-files.js:9:36)
    at /usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint-plugin-ava/rules/no-import-test-files.js:26:31
    at CallExpression (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint-plugin-ava/rules/no-import-test-files.js:65:5)
    at listeners.(anonymous function).forEach.listener (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/usr/src/npm/babel-plugin-template-html-minifier/node_modules/eslint/lib/util/node-event-generator.js:280:22)
IssueHunt Summary

gmartigny gmartigny has been rewarded.

Sponsors (Total: $20.00)

Tips

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