Skip to content

Add Prettier to keep things consistent #115

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

Merged
merged 5 commits into from
Jul 26, 2025
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
node-version: lts/jod
- run: npm ci
- run: npm run lint
- run: npm run prettier:check
Comment on lines 28 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- run: npm run lint
- run: npm run prettier:check
- run: node --run lint
- run: node --run prettier:check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I plan to do a separate PR to update npm run across the repo 👍 Especially when calling other scripts within scripts.

unit-tests:
strategy:
fail-fast: false
Expand Down
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignore artifacts
dist
build
Pods
target
.cxx

# Ignore hermes
packages/host/hermes
packages/node-addon-examples/examples
packages/node-tests/node
packages/node-tests/tests
packages/node-tests/*.generated.js
4 changes: 2 additions & 2 deletions apps/test-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { suites as nodeAddonExamplesSuites } from "@react-native-node-api/node-a
function describeIf(
condition: boolean,
title: string,
fn: (this: Mocha.Suite) => void
fn: (this: Mocha.Suite) => void,
) {
return condition ? describe(title, fn) : describe.skip(title, fn);
}
Expand All @@ -31,7 +31,7 @@ function loadTests({
}: Context) {
describeIf(nodeAddonExamples, "Node Addon Examples", () => {
for (const [suiteName, examples] of Object.entries(
nodeAddonExamplesSuites
nodeAddonExamplesSuites,
)) {
describe(suiteName, () => {
for (const [exampleName, requireExample] of Object.entries(examples)) {
Expand Down
4 changes: 2 additions & 2 deletions apps/test-app/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
presets: ["module:@react-native/babel-preset"],
// plugins: [['module:react-native-node-api/babel-plugin', { stripPathSuffix: true }]],
plugins: ['module:react-native-node-api/babel-plugin'],
plugins: ["module:react-native-node-api/babel-plugin"],
};
3 changes: 1 addition & 2 deletions apps/test-app/react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const project = (() => {
try {
const { configureProjects } = require("react-native-test-app");
Expand All @@ -25,4 +24,4 @@ const project = (() => {

module.exports = {
...(project ? { project } : undefined),
};
};
2 changes: 1 addition & 1 deletion docs/HOW-IT-WORKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The generated code looks something like this:

```javascript
module.exports = require("react-native-node-api").requireNodeAddon(
"calculator-lib--prebuild"
"calculator-lib--prebuild",
);
```

Expand Down
23 changes: 13 additions & 10 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@

import { globalIgnores } from "eslint/config";
import globals from "globals";
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier/flat";

export default tseslint.config(
globalIgnores([".nx/**"]),
globalIgnores(["**/dist/**"]),
globalIgnores(["apps/test-app/ios/**"]),
globalIgnores(["packages/host/hermes/**"]),
globalIgnores(["packages/node-addon-examples/examples/**"]),
globalIgnores(["packages/ferric-example/ferric_example.d.ts"]),
globalIgnores([
"**/dist/**",
"apps/test-app/ios/**",
"packages/host/hermes/**",
"packages/node-addon-examples/examples/**",
"packages/ferric-example/ferric_example.d.ts",
]),
eslint.configs.recommended,
tseslint.configs.recommended,
eslintConfigPrettier,
{
files: [
"apps/test-app/*.js",
"packages/node-addon-examples/*.js",
"packages/host/babel-plugin.js",
"packages/host/react-native.config.js"
"packages/host/react-native.config.js",
],
languageOptions: {
parserOptions: {
Expand All @@ -38,7 +41,7 @@ export default tseslint.config(
files: [
"packages/gyp-to-cmake/bin/*.js",
"packages/host/bin/*.mjs",
"packages/host/scripts/*.mjs"
"packages/host/scripts/*.mjs",
],
languageOptions: {
globals: {
Expand Down
Loading
Loading