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

feat: add linting to react-native-worklets #6825

Open
wants to merge 2 commits into
base: @tjzel/worklets/node-module-with-rea-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/reanimated-static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ on:
workflow_dispatch:

jobs:
check:
reanimated-static-checks:
if: github.repository == 'software-mansion/react-native-reanimated'
env:
PACKAGE_PATH: packages/react-native-reanimated
runs-on: ubuntu-latest
concurrency:
group: static-root-${{ github.ref }}
cancel-in-progress: true
steps:
# Setup VM
- name: checkout
uses: actions/checkout@v4
- name: Use Node.js
Expand All @@ -29,27 +32,29 @@ jobs:
- name: Clear annotations
run: .github/workflows/helper/clear-annotations.sh

# Setup repo
- name: Install monorepo node dependencies
run: yarn install --immutable
- name: Build Reanimated for TypeScript types
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn build

# Checks
- name: Check TypeScript types
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn type:check
- name: Lint JavaScript
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn lint:js
- name: Find unused code
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn find-unused-code:js
- name: Find circular dependencies
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn circular-dependency-check
- name: Check use strict
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn use-strict-check
- name: Run jest unit tests
working-directory: packages/react-native-reanimated
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn test
51 changes: 51 additions & 0 deletions .github/workflows/worklets-static-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Worklets static checks
env:
YARN_ENABLE_HARDENED_MODE: 0
on:
pull_request:
merge_group:
branches:
- main
push:
branches:
- main
workflow_call:
workflow_dispatch:

jobs:
worklets-static-checks:
if: github.repository == 'software-mansion/react-native-reanimated'
env:
PACKAGE_PATH: packages/react-native-worklets
runs-on: ubuntu-latest
concurrency:
group: worklets-static-checks-${{ github.ref }}
cancel-in-progress: true
steps:
# Setup VM
- name: checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: 'yarn'
- name: Clear annotations
run: .github/workflows/helper/clear-annotations.sh

# Setup repo
- name: Install monorepo node dependencies
run: yarn install --immutable
- name: Build Worklets for TypeScript types
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn build

# Checks
- name: Check TypeScript types
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn type-check
- name: Lint JavaScript
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn lint
- name: Find circular dependencies
working-directory: ${{ env.PACKAGE_PATH }}
run: yarn circular-dependency-check
2 changes: 1 addition & 1 deletion packages/react-native-reanimated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"type:check:tests:common": "./scripts/test-ts.sh __typetests__/common",
"build": "yarn build:plugin && bob build",
"build:plugin": "cd plugin && yarn build",
"circular-dependency-check": "yarn madge --extensions js,ts,tsx --circular src lib",
"circular-dependency-check": "yarn madge --extensions js,jsx,ts,tsx --circular src lib",
"use-strict-check": "node ./scripts/validate-use-strict.js",
"prepack": "cp ../../README.md ./README.md",
"postpack": "rm ./README.md"
Expand Down
19 changes: 8 additions & 11 deletions packages/react-native-worklets/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ project(Worklets)
cmake_minimum_required(VERSION 3.8)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE INTERNAL "")

set(CMAKE_CXX_STANDARD 20)

Expand All @@ -17,14 +14,13 @@ add_compile_options(${folly_FLAGS})
string(
APPEND
CMAKE_CXX_FLAGS
" -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}"
)
" -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} \
-DREANIMATED_VERSION=${REANIMATED_VERSION} \
-DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}")

string(
APPEND
CMAKE_CXX_FLAGS
" -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror"
)
string(APPEND CMAKE_CXX_FLAGS
" -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all \
-std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")

if(${IS_NEW_ARCHITECTURE_ENABLED})
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
Expand Down Expand Up @@ -57,4 +53,5 @@ set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")

add_subdirectory("${ANDROID_CPP_DIR}/worklets")
# TODO: Uncomment me when worklets get some sources
# add_subdirectory("${ANDROID_CPP_DIR}/worklets")
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ elseif(${JS_RUNTIME} STREQUAL "jsc")
elseif(${JS_RUNTIME} STREQUAL "v8") # TODO: Refactor this when adding support
# for newest V8
target_include_directories(worklets PRIVATE "${JS_RUNTIME_DIR}/src")
file(
GLOB
V8_SO_DIR
"${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/*/jni/${ANDROID_ABI}"
)
file(GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/\
library_jni/*/jni/${ANDROID_ABI}")
find_library(
V8EXECUTOR_LIB v8executor
PATHS ${V8_SO_DIR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@ReactModule(name = DummyWorkletsModule.NAME)
public class DummyWorkletsModule extends
NativeSulphateWorkletsSpec {
NativeDummyWorkletsSpec {

public DummyWorkletsModule(ReactApplicationContext reactContext) {
super(reactContext);
Expand Down
10 changes: 9 additions & 1 deletion packages/react-native-worklets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"version": "0.0.1",
"description": "🚀",
"scripts": {
"build": "bob build"
"build": "bob build",
"format": "yarn format:js",
"format:js": "prettier --write --list-different src",
"lint": "yarn lint:js",
"lint:js": "eslint --ext '.js,.ts,.tsx' src && yarn prettier --check src",
"type-check": "yarn tsc --noEmit",
"circular-dependency-check": "yarn madge --extensions js,jsx,ts,tsx --circular src lib"
},
"repository": {
"type": "git",
Expand All @@ -26,7 +32,9 @@
"@react-native/eslint-config": "^0.73.1",
"@types/jest": "^29.5.5",
"@types/react": "^18.2.44",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"eslint": "^8.57.0",
"madge": "^5.0.1",
"prettier": "^3.3.3",
"react": "18.3.1",
"react-native": "^0.76.1",
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18305,7 +18305,9 @@ __metadata:
"@react-native/eslint-config": "npm:^0.73.1"
"@types/jest": "npm:^29.5.5"
"@types/react": "npm:^18.2.44"
"@typescript-eslint/eslint-plugin": "npm:^6.19.0"
eslint: "npm:^8.57.0"
madge: "npm:^5.0.1"
prettier: "npm:^3.3.3"
react: "npm:18.3.1"
react-native: "npm:^0.76.1"
Expand Down
Loading