Skip to content

[Fix] Ignore hashbang and BOM while parsing #2431

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

Merged
merged 2 commits into from
Jul 12, 2022

Conversation

silverwind
Copy link
Contributor

ESLint does this outside their espree parser, so we need to do it as well. Just like ESLint, the code will convert hashbang to comments and strip off the BOM completely before handing the content to the parser.

Fixes: #1369

ESLint does this outside their espree parser, so we need to do it as
well. Just like ESLint, the code will convert hashbang to comments and
strip off the BOM completely before handing the content to the parser.
@codecov
Copy link

codecov bot commented Apr 11, 2022

Codecov Report

Merging #2431 (14d15a7) into main (ce037f4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 14d15a7 differs from pull request most recent head 53a9d5d. Consider uploading reports for the commit 53a9d5d to get more accurate results

@@           Coverage Diff           @@
##             main    #2431   +/-   ##
=======================================
  Coverage   95.18%   95.19%           
=======================================
  Files          66       66           
  Lines        2783     2787    +4     
  Branches      935      936    +1     
=======================================
+ Hits         2649     2653    +4     
  Misses        134      134           
Impacted Files Coverage Δ
utils/parse.js 98.27% <100.00%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce037f4...53a9d5d. Read the comment docs.

@silverwind silverwind changed the title Ignore ignore hashbang and BOM while parsing [Fix] Ignore hashbang and BOM while parsing Apr 11, 2022
@silverwind silverwind force-pushed the hashbang-bom branch 2 times, most recently from 646e864 to d0367fa Compare April 11, 2022 23:03
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Looks great!

@silverwind
Copy link
Contributor Author

Rebased and split up into 4 separate tests (all variants of bom,hashbang and one test without any of them).

@ljharb ljharb merged commit 53a9d5d into import-js:main Jul 12, 2022
@silverwind silverwind deleted the hashbang-bom branch July 12, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug package: utils eslint-module-utils package
Development

Successfully merging this pull request may close these issues.

no-unused-modules does not work with shebangs
2 participants