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

Improve error message when there is a JS syntax error #3556

Merged
merged 1 commit into from
Mar 9, 2021
Merged

Conversation

willdurand
Copy link
Member

@willdurand willdurand commented Jan 27, 2021

Fixes #3482


It'll be awesome once it's ready.

Output

❯ ./bin/addons-linter test-addon
Validation Summary:

errors          1
notices         0
warnings        0

ERRORS:

Code              Message                                               Description                                                                                        File    Line   Column
JS_SYNTAX_ERROR   JavaScript syntax error (Parsing as module error:     There is a JavaScript syntax error in your code, which might be related to some experimental       cs.js   1      1
                  Unexpected token = at line: 4 and column: 5)          JavaScript features that aren't an official part of the language specification and therefore not
                  (Parsing as script error: 'import' and 'export' may   supported yet. The validation cannot continue on this file.
                  appear only with 'sourceType: module' at line: 1
                  and column: 1)

@willdurand willdurand requested a review from rpl February 3, 2021 09:22
@rpl
Copy link
Member

rpl commented Feb 4, 2021

@willdurand looked to this again once more and I confirm that I'm ok with the general approach, my +1 on proceeding to complete this PR.

@willdurand
Copy link
Member Author

@rpl so I wasn't very inspired when writing tests but on the other hand, I think coverage is pretty good already. I thought about adding some more tests for the replace() call, etc. but the test setup would be quite complex for little value IMO. WDYT? Mind looking at this patch a bit? It's not urgent.

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand I didn't reviewed all the PR in detail, but I did find a detail (described below) that I'd like to discuss with you (while I'm going to look to the rest of this patch).

tests/unit/scanners/test.javascript.js Outdated Show resolved Hide resolved
@willdurand
Copy link
Member Author

@willdurand I didn't reviewed all the PR in detail, but I did find a detail (described below) that I'd like to discuss with you (while I'm going to look to the rest of this patch).

@rpl thanks. I updated this PR to fix the issue you raised in the previous review. I added a note about reporting a new issue when there is likely a bug in our code. The rest is unchanged. Let me know what you think.

@willdurand willdurand requested a review from rpl February 23, 2021 18:12
@willdurand
Copy link
Member Author

(ugh, forgot to request a review)

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand apologies for letting you wait, there are a couple more changes that I think would be good to apply to this PR (these should be the last ones, I promise ;-))

Let me know if you think that any of those points may use some discussion over a synchronous channel.

src/scanners/javascript.js Outdated Show resolved Hide resolved
tests/unit/rules/javascript/test.no_eval.js Outdated Show resolved Hide resolved
Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand lgtm, thanks for covering the last round of changes requested.

@willdurand willdurand merged commit f8c7a6c into master Mar 9, 2021
@willdurand willdurand deleted the errors branch March 9, 2021 20:41
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

Successfully merging this pull request may close these issues.

Improve error message when linting fails due to the use of unrecognized JavaScript features
3 participants