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

chore(helpers): deprecate invocations on non-functions for fakeEval #2913

Merged
merged 10 commits into from
Jun 14, 2024

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented May 18, 2024

This PR deprecates the current behavior of fake in preparion to be more consistent with standard JS behavior.

faker.helpers.fake('{{person.first_name()}}'); // 'Jenny'

Would now print a deprecation warning.

In v10 would fail with an exception:

FakerError: Cannot resolve expression 'person.first_name()'

This PR is part of an attempt to solve some of the TODOs in our source code.

@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs breaking change Cannot be merged when next version is not a major release m: helpers Something is referring to the helpers module labels May 18, 2024
@ST-DDT ST-DDT added this to the v9.0 milestone May 18, 2024
@ST-DDT ST-DDT requested review from a team May 18, 2024 15:56
@ST-DDT ST-DDT self-assigned this May 18, 2024
docs/guide/upgrading.md Outdated Show resolved Hide resolved
Copy link

netlify bot commented May 18, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 4180bcf
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/666bde267de6820008e86199
😎 Deploy Preview https://deploy-preview-2913.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented May 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (a5ffca1) to head (4180bcf).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2913      +/-   ##
==========================================
- Coverage   99.95%   99.95%   -0.01%     
==========================================
  Files        2987     2987              
  Lines      216037   216052      +15     
  Branches      601      948     +347     
==========================================
+ Hits       215944   215951       +7     
- Misses         93      101       +8     
Files Coverage Δ
src/modules/helpers/eval.ts 96.77% <100.00%> (+0.20%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Contributor

@matthewmayer matthewmayer left a comment

Choose a reason for hiding this comment

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

I don't really like introducing this change suddenly as it's likely to only be found at runtime.

If we don't want to support this syntax any more I think we could log a warning in v9 and error in v10 instead.

@ST-DDT ST-DDT added the s: needs decision Needs team/maintainer decision label May 19, 2024
@ST-DDT
Copy link
Member Author

ST-DDT commented May 23, 2024

Team Decision

  • We forgot about the deprecation -> deprecate now and "remove" in v10

@ST-DDT ST-DDT added deprecation A deprecation was made in the PR and removed s: needs decision Needs team/maintainer decision breaking change Cannot be merged when next version is not a major release labels May 23, 2024
@ST-DDT ST-DDT marked this pull request as draft May 23, 2024 16:06
@ST-DDT ST-DDT changed the title refactor(helpers)!: fail on invocations on non-functions chore(helpers)!: deprecate invocations on non-functions for fakeEval Jun 12, 2024
@ST-DDT ST-DDT marked this pull request as ready for review June 12, 2024 14:16
@ST-DDT ST-DDT requested review from matthewmayer and a team June 12, 2024 14:16
@ST-DDT
Copy link
Member Author

ST-DDT commented Jun 12, 2024

Fixed - ready for review

@Shinigami92
Copy link
Member

Having a chore! is invalid 🤔 either it did not change runtime behavior or it is a breaking change 👀

@matthewmayer
Copy link
Contributor

I think it's no longer breaking so ! Should be removed but it should get a brief write up at the bottom of the migration guide.

@ST-DDT ST-DDT changed the title chore(helpers)!: deprecate invocations on non-functions for fakeEval chore(helpers): deprecate invocations on non-functions for fakeEval Jun 13, 2024
@ST-DDT
Copy link
Member Author

ST-DDT commented Jun 13, 2024

Example log:

[@faker-js/faker]: Invoking expressions which are not functions is deprecated since v9.0 and will be removed in v10.0.
Please remove the parenthesis or replace the expression with an actual function.
person.first_name()
                 ^

@ST-DDT ST-DDT requested review from xDivisionByZerox and a team June 13, 2024 18:19
Shinigami92
Shinigami92 previously approved these changes Jun 13, 2024
@ST-DDT ST-DDT merged commit 5f77d38 into next Jun 14, 2024
23 checks passed
@ST-DDT ST-DDT deleted the refactor/helpers/fake-eval branch June 14, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs deprecation A deprecation was made in the PR m: helpers Something is referring to the helpers module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants