Skip to content

Commit 9e1b636

Browse files
chore: switch to oxfmt (#1913)
1 parent 8acf559 commit 9e1b636

113 files changed

Lines changed: 649 additions & 266 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
- name: Lint
2828
run: yarn lint
2929

30-
- name: Prettier
31-
run: yarn prettier
30+
- name: Format
31+
run: yarn format:check
3232

3333
typecheck:
3434
runs-on: ubuntu-latest

.oxfmtrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"sortImports": {
7+
"groups": [
8+
"side_effect",
9+
["builtin", "external", "internal", "subpath", "unknown"],
10+
["parent", "sibling", "index"]
11+
]
12+
},
13+
"sortPackageJson": false,
14+
"ignorePatterns": ["node_modules/", ".yarn", "codemods/**/tests/fixtures/**"]
15+
}

.prettierignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- `yarn test:ci`
99
- `yarn typecheck`
1010
- `yarn lint`
11-
- `yarn prettier`
11+
- `yarn format:check`
1212
- `yarn build`
1313
- `yarn validate`
1414
- Task-specific guidance:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ Our pre-commit hooks verify that your commit message matches this format when co
3232

3333
### Linting and tests
3434

35-
We use TypeScript for type checking, `eslint` with `prettier` for linting and formatting the code, and `jest` for testing. Our pre-commit hooks verify that the linter and tests pass when committing. You can also run the following commands manually:
35+
We use TypeScript for type checking, `eslint` and `oxfmt` for linting and formatting the code, and `jest` for testing. Our pre-commit hooks verify that the linter and tests pass when committing. You can also run the following commands manually:
3636

3737
- `yarn typecheck`: run TypeScript compiler on all files.
38-
- `yarn lint`: run eslint and prettier.
38+
- `yarn lint`: run eslint.
3939
- `yarn test`: run tests.
4040

4141
### Sending a pull request

agents/build-and-validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
- Run tests in CI mode: `yarn test:ci`
88
- Type check: `yarn typecheck`
99
- Lint source files: `yarn lint`
10-
- Check formatting: `yarn prettier`
10+
- Check formatting: `yarn format:check`
1111
- Validate the main package: `yarn validate`
1212
- Build the package: `yarn build`
1313

1414
## Command notes
1515

1616
- `yarn lint` runs ESLint on `src`.
17-
- `yarn validate` runs typecheck, tests, lint, and Prettier checks for the main package.
17+
- `yarn validate` runs typecheck, tests, lint, and oxfmt checks for the main package.
1818
- `yarn build` cleans `dist/`, transpiles source with Babel, and emits TypeScript declarations.
1919

2020
## Repo layout

agents/code-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
- ESLint uses `@callstack/eslint-config` together with `typescript-eslint`.
66
- Important enforced rules include `no-console` and consistent type imports.
7-
- Prettier is the formatter.
7+
- oxfmt is the formatter.
88
- Formatting defaults include single quotes and trailing commas.
99

1010
## Imports
1111

12-
- Keep imports sorted with `eslint-plugin-simple-import-sort`.
12+
- Keep imports sorted with `oxfmt`.

codemods/v14-async-functions/scripts/codemod.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { Edit, SgNode } from '@codemod.com/jssg-types/main';
12
import type { Transform } from 'codemod:ast-grep';
23
import type TSX from 'codemod:ast-grep/langs/tsx';
3-
import type { Edit, SgNode } from '@codemod.com/jssg-types/main';
44

55
const FUNCTIONS_TO_MAKE_ASYNC = new Set(['render', 'renderHook', 'act', 'fireEvent']);
66
const FIRE_EVENT_METHODS_TO_MAKE_ASYNC = new Set(['press', 'changeText', 'scroll']);
@@ -241,10 +241,16 @@ function extractImportedFunctionNames(
241241
edits: Edit[],
242242
): {
243243
importedFunctions: Set<string>;
244-
specifiersToRemove: Array<{ specifier: SgNode<TSX>; importStmt: SgNode<TSX> }>;
244+
specifiersToRemove: Array<{
245+
specifier: SgNode<TSX>;
246+
importStmt: SgNode<TSX>;
247+
}>;
245248
} {
246249
const importedFunctions = new Set<string>();
247-
const specifiersToRemove: Array<{ specifier: SgNode<TSX>; importStmt: SgNode<TSX> }> = [];
250+
const specifiersToRemove: Array<{
251+
specifier: SgNode<TSX>;
252+
importStmt: SgNode<TSX>;
253+
}> = [];
248254

249255
for (const importStmt of rntlImports) {
250256
const importClause = importStmt.find({
@@ -332,7 +338,10 @@ function extractImportedFunctionNames(
332338
* @param edits - Array to collect edit operations
333339
*/
334340
function removeDuplicateImportSpecifiers(
335-
specifiersToRemove: Array<{ specifier: SgNode<TSX>; importStmt: SgNode<TSX> }>,
341+
specifiersToRemove: Array<{
342+
specifier: SgNode<TSX>;
343+
importStmt: SgNode<TSX>;
344+
}>,
336345
rootNode: SgNode<TSX>,
337346
edits: Edit[],
338347
): void {
@@ -464,11 +473,17 @@ function findFireEventMethodCalls(
464473
for (const [asyncName, syncName] of ASYNC_FUNCTIONS_TO_RENAME.entries()) {
465474
if (syncName === 'fireEvent') {
466475
const wasImported = rntlImports.some((importStmt) => {
467-
const importClause = importStmt.find({ rule: { kind: 'import_clause' } });
476+
const importClause = importStmt.find({
477+
rule: { kind: 'import_clause' },
478+
});
468479
if (!importClause) return false;
469-
const namedImports = importClause.find({ rule: { kind: 'named_imports' } });
480+
const namedImports = importClause.find({
481+
rule: { kind: 'named_imports' },
482+
});
470483
if (!namedImports) return false;
471-
const specifiers = namedImports.findAll({ rule: { kind: 'import_specifier' } });
484+
const specifiers = namedImports.findAll({
485+
rule: { kind: 'import_specifier' },
486+
});
472487
return specifiers.some((spec) => {
473488
const identifier = spec.find({ rule: { kind: 'identifier' } });
474489
return identifier && identifier.text() === asyncName;

docs/api/queries.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ expect(
400400

401401
// Include hidden elements
402402
expect(
403-
screen.getByText('Hidden from accessibility', { includeHiddenElements: true }),
403+
screen.getByText('Hidden from accessibility', {
404+
includeHiddenElements: true,
405+
}),
404406
).toBeOnTheScreen();
405407
```
406408

docs/api/screen.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ You can also transform prop values so that they are more readable (e.g., flatten
121121
import { StyleSheet } from 'react-native';
122122

123123
screen.debug({
124-
mapProps: ({ style, ...props }) => ({ style: StyleSheet.flatten(style), ...props }),
124+
mapProps: ({ style, ...props }) => ({
125+
style: StyleSheet.flatten(style),
126+
...props,
127+
}),
125128
});
126129
```
127130

0 commit comments

Comments
 (0)