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

message.source can be null #29

Closed
Julian opened this issue Feb 6, 2018 · 10 comments
Closed

message.source can be null #29

Julian opened this issue Feb 6, 2018 · 10 comments

Comments

@Julian
Copy link

Julian commented Feb 6, 2018

Apologies if this is in the wrong place, I'm not a JS dev.

I think there's an assumption that message.source is undefined or an object with a length, but that doesn't appear to be the case. I was getting the below traceback, which, after inserting a console.log, showed me that message was the object at the top:

great@ build /Users/Julian/Development/Great/frontend
node build/build.js "--output-path=/Users/Julian/Development/Great/frontend/great/static/"

⠸ building for production...{ filePath: 'src/main.js',
ruleId: null,
fatal: true,
severity: 2,
source: null,
message: 'Parsing error: Cannot find module 'babel-eslint'' }
Hash: de4abf6558c690e13510
Version: webpack 3.10.0
Time: 1054ms
Asset Size Chunks Chunk Names
static/js/app.ac5f7a1782f171a9b60d.js 699 bytes 0 [emitted] app
static/js/manifest.98e4b6563f239cfa083a.js 1.46 kB 1 [emitted] manifest
static/js/app.ac5f7a1782f171a9b60d.js.map 1.07 kB 0 [emitted] app
static/js/manifest.98e4b6563f239cfa083a.js.map 14.2 kB 1 [emitted] manifest
index.html 352 bytes [emitted]

ERROR in ./src/main.js
Module build failed: TypeError: Cannot read property 'length' of null
at /Users/Julian/Development/Great/frontend/node_modules/eslint-friendly-formatter/index.js:185:74
at Array.reduce ()
at Object.module.exports [as formatter] (/Users/Julian/Development/Great/frontend/node_modules/eslint-friendly-formatter/index.js:160:17)
at printLinterOutput (/Users/Julian/Development/Great/frontend/node_modules/eslint-loader/index.js:79:29)
at Object.module.exports (/Users/Julian/Development/Great/frontend/node_modules/eslint-loader/index.js:213:3)

Build failed with errors.


where `source` is `null`, not `undefined`.
@royriojas
Copy link
Owner

hi @Julian can you provide a bit more context? not really clear from this output what was the command you were trying to execute. Can you provide a github repo with a minimum repro case?

@Julian
Copy link
Author

Julian commented Feb 6, 2018

Hey @royriojas will assemble one, thanks for the response!

@Julian
Copy link
Author

Julian commented Feb 6, 2018

@royriojas done: https://github.com/Julian/some-repo + npm run build

(Which I got by running vue init webpack some-repo and then just deleting babel-eslint from the package.json and running npm install)

@royriojas
Copy link
Owner

Thanks @Julian, will give it a try later today.

@blacksun1
Copy link

Hey, I was able to reproduce the same bug by giving eslint the flag --report-unused-disable-directives and having one or more non-required disable comments.

@bponomarenko
Copy link

@royriojas I was able to reproduce this issue in the same way as @blacksun1. When there is at least one unused // eslint-disable comment in the code and --report-unused-disable-directives is present, message.source is set to null.

@peteralt
Copy link

peteralt commented Apr 2, 2018

So what is the recommended solution for this issue? I'm suddenly running into this and don't really know how to fix it.

@peteralt
Copy link

peteralt commented Apr 2, 2018

Following up on my request, I've been able to get the project working with this:
In the .eslintrc.js file, I changed

parserOptions: { parser: 'babel-eslint' },

to
parserOptions: { // parser: 'babel-eslint' },

Which seems to do the trick.

solebared added a commit to solebared/eslint-friendly-formatter that referenced this issue Apr 6, 2018
Addresses issue royriojas#29. Message source can be null when a Parsing error is
encountered.
@royriojas
Copy link
Owner

It is really weird as I was not able to reproduce the issue locally. But @exbinary has made a fix for this and will just publish a new version since tests pass with his change. Hope this helps to alleviate this issue.

@royriojas
Copy link
Owner

closing as we've published v4.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants