Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'directory' of null when not passing a config object #42

Closed

Comments

@srmagura
Copy link

Other import-resolver plugins (e.g. webpack) allow you to use the default configuration by writing

settings: {
    'import/resolver': 'webpack'
}

in .eslintrc.

If you try this syntax with eslint-import-resolver-typescript, you get

  1:1   error    Resolve error: TypeError: Cannot read property 'directory' of null
    at initMappers (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-import-resolver-typescript\lib\cjs.js:102:38)
    at Object.resolve (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-import-resolver-typescript\lib\cjs.js:34:5)
    at v2 (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-module-utils\resolve.js:117:23)
    at withResolver (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-module-utils\resolve.js:122:16)
    at fullResolve (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-module-utils\resolve.js:139:22)
    at relative (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-module-utils\resolve.js:84:10)
    at resolve (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-module-utils\resolve.js:220:12)
    at isExternalRootModule (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-plugin-import\lib\rules\extensions.js:133:82)
    at checkFileExtension (C:\Projects\CareServices\CDS2\Source\node_modules\eslint-plugin-import\lib\rules\extensions.js:153:11)
    at listeners.(anonymous function).forEach.listener (C:\Projects\CareServices\CDS2\Source\node_modules\eslint\lib\linter\safe-emitter.js:45:58)

The error is being thrown on line 142 of index.ts where we try to access options.directory without checking options for null.

Ideally, we would use the default config if options == null.

I will plan to submit a PR for this sometime in the next month. If someone else can get to it faster than that, go for it.

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