eslint-plugin-import: TypeError: Cannot read property 'some' of undefined when `ast.comments` is missing on the AST
ExportMap.parse = function (path, content, context) {
// ...
// attempt to collect module doc
ast.comments.some(c => {
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 29 (20 by maintainers)
Commits related to this issue
- #842 Fixes Cannot read property 'some' of undefined — committed to alexgorbatchev/eslint-plugin-import by alexgorbatchev 7 years ago
- #842 Fixes Cannot read property 'some' of undefined — committed to alexgorbatchev/eslint-plugin-import by alexgorbatchev 7 years ago
- #842/#944 changelog note — committed to import-js/eslint-plugin-import by benmosher 7 years ago
- Upgrading eslint-plugin-import to fix https://github.com/benmosher/eslint-plugin-import/issues/842 — committed to thoov/mock-socket by thoov 6 years ago
Would really like to see this published. This error makes the whole experience of linting in editor like VSCode completely broken because plugin exceptions end up as alerts. So any time I save and linter runs, i get exceptions. Had to disable linting for
.tsx
files all together for now.@piecyk The thing is that the
parserOptions
ineslint-plugin-import
(eslint-module-utils
) get extended with theattachComment
option, and not withcomment
option. https://github.com/benmosher/eslint-plugin-import/blob/d92ef4365b55495dbcce8677f5cbfd08d023440a/utils/parse.js#L22-L23You’re saying
typescript-eslint-parser
does not use theattachComment
option, rather it requirescomment
option instead. So there is an incompatibility between different eslint parsers which has to be fixed.babel-eslint
provides both: https://github.com/babel/babel-eslint/blob/37f9242fc6979fdd90e22dd26ef5b1ca7905b486/test/babel-eslint.js#L78-L79 toespree
which documents them as follows:@ljharb Definitely! But I have no filePath where I need it yet to get the file extension from (this https://github.com/benmosher/eslint-plugin-import/issues/839 solves it, but it’s not released yet so I cannot install it as a dependency).