-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move Worklets JS core from Reanimated (#6973)
## Summary Currently JS core of Worklets sits in Reanimated package. This PR moves it to Worklets. It's a bit messy but we'll get there eventually. - Added `createCustomError` that creates `WorkletsError` and `ReanimatedError` used in respective packages. - Added ESLint rule `use-worklets-error`, a copypaste of `use-reanimated-error`. - Moved `shareables.ts` to `react-native-worklets`. - Moved `threads.ts` to `react-native-worklets`. - Moved `initializers.ts` to `react-native-worklets` - Moved `runtimes.ts` to `react-native-worklets` - JS version checking in worklets is disabled for the time being, as it would clutter this PR even more. We'll circle back to it once we set version checking between Reanimated and Worklets. ## Test plan CI, run the example app.
- Loading branch information
Showing
73 changed files
with
565 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import { AST_NODE_TYPES } from '@typescript-eslint/utils'; | ||
|
||
const rule: TSESLint.RuleModule<'useWorkletsError', []> = { | ||
create: function (context) { | ||
return { | ||
NewExpression(node: TSESTree.NewExpression) { | ||
// Check if the expression is `new Error` | ||
if ( | ||
node.callee.type === AST_NODE_TYPES.Identifier && | ||
node.callee.name === 'Error' | ||
) { | ||
context.report({ | ||
node, | ||
messageId: 'useWorkletsError', | ||
fix: function (fixer) { | ||
// Replace `Error` with `WorkletsError` | ||
return fixer.replaceText(node.callee, 'WorkletsError'); | ||
}, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
meta: { | ||
docs: { | ||
recommended: 'recommended', | ||
description: | ||
'Warns when `new Error` is used instead of `new WorkletsError`.', | ||
}, | ||
messages: { | ||
useWorkletsError: 'Use `new WorkletsError` instead of `new Error`.', | ||
}, | ||
type: 'suggestion', | ||
schema: [], | ||
fixable: 'code', | ||
}, | ||
defaultOptions: [], | ||
}; | ||
|
||
export default rule; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/eslint-plugin-reanimated/types/useWorkletsError.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/react-native-reanimated/src/ReanimatedModule/js-reanimated/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.