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

[Plugin] [2/9] Convert throws to asserts #4211

Merged
merged 16 commits into from
Apr 3, 2023

Conversation

tjzel
Copy link
Contributor

@tjzel tjzel commented Mar 13, 2023

Summary

Change custom error throws on undefined objects to generic assert for better clarity. Direct follow up to #4210.

Test plan

Nothing to test really.

@tjzel tjzel changed the title [Plugin] Move throws to asserts. [Plugin] [2/9] Move throws to asserts. Mar 14, 2023
plugin/package.json Outdated Show resolved Hide resolved
plugin/src/asserts.ts Outdated Show resolved Hide resolved
plugin/src/makeWorklet.ts Outdated Show resolved Hide resolved
@@ -370,7 +372,7 @@ export function makeWorklet(
functionName,
transformed.map
);
if (!funString) throw new Error("'funString' is not defined\n");
assertIsDefined(funString);
Copy link
Member

Choose a reason for hiding this comment

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

In which case funString is not defined? Is it possible to use TypeScript to ensure that it's defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to hardcode it since d.ts from Babel says:
Screenshot 2023-03-30 at 10 38 52
So I'd rather leave it as is for now.

tjzel and others added 2 commits March 30, 2023 10:35
Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
plugin/.eslintrc.js Outdated Show resolved Hide resolved
@@ -15,7 +16,7 @@
"bundle": "yarn esbuild ./lib/plugin.js --bundle --external:@babel --external:convert-source-map --external:fs --external:'../../package.json' --log-level=warning --platform=node --sourcemap=linked --outfile=build/plugin.js",
"format": "yarn prettier --write --list-different **/*.ts",
"watch": "yarn tsc-watch --onSuccess \"yarn bundle\"",
"lint": "yarn eslint --max-warnings=0 --ext .ts . && yarn prettier --check **/*.ts",
"lint": "yarn eslint --max-warnings=0 --ext .ts .",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"lint": "yarn eslint --max-warnings=0 --ext .ts .",
"lint": "eslint --max-warnings=0 --ext .ts .",

Honestly I don't like using --ext .ts here. Instead, we can remove this flag and skip lib and build folders using ignorePatterns: ['lib/', 'build/'], in .eslintrc.js.

@tjzel tjzel changed the title [Plugin] [2/9] Move throws to asserts. [Plugin] [2/9] Convert throws to asserts Apr 3, 2023
@tjzel tjzel added this pull request to the merge queue Apr 3, 2023
Merged via the queue into main with commit ee62b04 Apr 3, 2023
@tjzel tjzel deleted the @tjzel/plugins-move-throws-to-asserts branch April 3, 2023 07:31
tjzel added a commit that referenced this pull request Apr 3, 2023
## Summary

Slight naming refactor for functions' names to be more self-explanatory.
Direct follow up to #4211.

## Test plan

No testing required since it's name change only (maybe check if it
compiles).

---------

Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
## Summary

Change custom error throws on undefined objects to generic assert for
better clarity. Direct follow up to software-mansion#4210.

## Test plan

Nothing to test really.

---------

Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
## Summary

Slight naming refactor for functions' names to be more self-explanatory.
Direct follow up to software-mansion#4211.

## Test plan

No testing required since it's name change only (maybe check if it
compiles).

---------

Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
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.

None yet

2 participants