Skip to content

Commit f27fa0b

Browse files
committed
chore: add explicit formatting scripts
1 parent e4cf03a commit f27fa0b

9 files changed

Lines changed: 260 additions & 290 deletions

File tree

.github/workflows/lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ jobs:
3333
run: npm ci --ignore-scripts
3434

3535
- name: Run Format Check
36-
run: npm run format:ci
36+
run: |
37+
npm run format:ts:ci
38+
npm run format:src:ci
3739
3840
- name: Run Lint
3941
run: npm run lint:all

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.project
66
node_modules/
77
.rslib/
8+
.clang-format
89
dist/
910
src/build/
1011
bin-*/

package-lock.json

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
"build:watch": "rslib build --watch",
3939
"lint:ts": "tsgo -p tsconfig.json --noEmit",
4040
"prepare": "npm run build:ci",
41+
"format:src": "node -e \"import('@node-3d/addon-tools').then((m) => m.cpclangformat())\" && clang-format -i \"src/cpp/*.cpp\" \"src/cpp/*.hpp\"",
42+
"format:src:ci": "node -e \"import('@node-3d/addon-tools').then((m) => m.cpclangformat())\" && clang-format --dry-run --Werror \"src/cpp/*.cpp\" \"src/cpp/*.hpp\"",
4143
"format:ts": "oxfmt -c ./oxfmt.config.ts --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx}\"",
42-
"format:ci": "oxfmt -c ./oxfmt.config.ts --check --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx}\""
44+
"format:ts:ci": "oxfmt -c ./oxfmt.config.ts --check --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx}\""
4345
},
4446
"engines": {
4547
"node": ">=24.13.0",
@@ -60,7 +62,8 @@
6062
"oxlint": "1.72.0",
6163
"tslib": "2.8.1",
6264
"oxfmt": "0.57.0",
63-
"typescript": "6.0.3"
65+
"typescript": "6.0.3",
66+
"clang-format-node": "3.0.7"
6467
},
6568
"type": "module",
6669
"types": "dist/index.d.ts",

src/cpp/bindings.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@
1111
#endif
1212

1313

14-
#define JS_SF_CONSTANT(name) \
15-
exports.Set(#name, static_cast<double>(name));
14+
#define JS_SF_CONSTANT(name) exports.Set(#name, static_cast<double>(name));
1615

17-
#define JS_SF_NULL(name) \
18-
exports.Set(#name, JS_NULL);
16+
#define JS_SF_NULL(name) exports.Set(#name, JS_NULL);
1917

20-
#define JS_SF_SET_METHOD(name) \
21-
exports.DefineProperty( \
22-
Napi::PropertyDescriptor::Function(env, exports, #name, segfault::name) \
23-
);
18+
#define JS_SF_SET_METHOD(name) \
19+
exports.DefineProperty(Napi::PropertyDescriptor::Function(env, exports, #name, segfault::name));
2420

2521

2622
Napi::Object initModule(Napi::Env env, Napi::Object exports) {
2723
segfault::init();
28-
24+
2925
JS_SF_SET_METHOD(causeSegfault);
3026
JS_SF_SET_METHOD(causeDivisionInt);
3127
JS_SF_SET_METHOD(causeOverflow);
3228
JS_SF_SET_METHOD(causeIllegal);
3329
JS_SF_SET_METHOD(setSignal);
3430
JS_SF_SET_METHOD(setLogPath);
35-
31+
3632
#ifdef _WIN32
3733
JS_SF_CONSTANT(EXCEPTION_ALL);
3834
JS_SF_CONSTANT(EXCEPTION_ACCESS_VIOLATION);
@@ -112,7 +108,7 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
112108
JS_SF_NULL(EXCEPTION_GUARD_PAGE);
113109
JS_SF_NULL(EXCEPTION_INVALID_HANDLE);
114110
JS_SF_NULL(STATUS_STACK_BUFFER_OVERRUN);
115-
111+
116112
JS_SF_CONSTANT(SIGINT);
117113
JS_SF_CONSTANT(SIGILL);
118114
JS_SF_CONSTANT(SIGABRT);
@@ -142,7 +138,7 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
142138
JS_SF_CONSTANT(SIGWINCH);
143139
JS_SF_CONSTANT(SIGSYS);
144140
#endif
145-
141+
146142
return exports;
147143
}
148144

0 commit comments

Comments
 (0)