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

fix: prevent adding undefined msgid to messages #915

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

amankkg
Copy link
Contributor

@amankkg amankkg commented Dec 15, 2020

Changes in babel-plugin-extract-messages packages:

  • added reproduction test case where undefined msgid is being generated
  • added a fix for that test case
  • refactored related function a bit

Closes #905

@vercel
Copy link

vercel bot commented Dec 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lingui-js/js-lingui/1jxxxm0hi
✅ Preview: https://js-lingui-git-fix-undefined-msgid-extraction.lingui-js.vercel.app

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #915 (a94060c) into main (38d01ef) will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #915      +/-   ##
==========================================
+ Coverage   83.12%   83.25%   +0.13%     
==========================================
  Files          52       52              
  Lines        1570     1571       +1     
  Branches      425      426       +1     
==========================================
+ Hits         1305     1308       +3     
+ Misses        157      156       -1     
+ Partials      108      107       -1     
Impacted Files Coverage Δ
...ackages/babel-plugin-extract-messages/src/index.ts 82.25% <100.00%> (+0.14%) ⬆️
packages/macro/src/macroJs.ts 91.04% <0.00%> (+1.49%) ⬆️

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 d5f77d1...a94060c. Read the comment docs.

@amankkg
Copy link
Contributor Author

amankkg commented Dec 15, 2020

Here is the diff for added test case fail

 FAIL  packages/babel-plugin-extract-messages/test/index.ts
  ● @lingui/babel-plugin-extract-messages › should extract all messages from JS files (macros)

    expect(received).toMatchSnapshot()

    Snapshot name: `@lingui/babel-plugin-extract-messages should extract all messages from JS files (macros) 1`

    - Snapshot  - 0
    + Received  + 9

    @@ -50,6 +50,15 @@
              js-with-macros.js,
              17,
            ],
          ],
        },
    +   undefined: Object {
    +     extractedComments: Array [],
    +     origin: Array [
    +       Array [
    +         js-with-macros.js,
    +         26,
    +       ],
    +     ],
    +   },
      }

      70 |         fs.readFileSync(path.join(buildDir, `${assertion}.json`)).toString()
      71 |       )
    > 72 |       expect(messages).toMatchSnapshot()
         |                        ^
      73 |     })
      74 |   }
      75 | }

      at Object.<anonymous> (packages/babel-plugin-extract-messages/test/index.ts:72:24)
      at processTicksAndRejections (node:internal/process/task_queues:93:5)

Copy link
Contributor

@tricoder42 tricoder42 left a comment

Choose a reason for hiding this comment

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

Looks good to me! 👍 Thank you

@tricoder42 tricoder42 merged commit 3afacec into lingui:main Dec 15, 2020
@amankkg amankkg deleted the fix-undefined-msgid-extraction branch December 15, 2020 16:56
@semoal
Copy link
Contributor

semoal commented Jan 13, 2021

Released in 3.4.0 🥳

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.

t macro with variable id extracted as message with undefined id
3 participants