fluentui-react-native/packages/codemods
UI-Fabric-RN-Bot 44e315b97a applying package updates 2024-04-11 18:08:46 +00:00
..
src Update to React Native 0.71 (#2754) 2023-06-05 11:49:06 -07:00
.eslintignore [Tree shaking] Fix import and update ESlint rules (#2851) 2023-06-12 22:47:24 +05:30
.eslintrc.js Add missing eslint configs to various packages that were missing a config (#2583) 2023-02-01 16:51:57 -08:00
CHANGELOG.json applying package updates 2024-03-15 16:26:25 +00:00
CHANGELOG.md applying package updates 2024-03-15 16:26:25 +00:00
README.md Add cli to run transforms using the codemods package (#2189) 2023-01-03 17:39:23 -08:00
babel.config.js jscodeshift transforms for migrating Button from v0 to v1 (#1663) 2022-09-22 11:32:17 -07:00
jest.config.js jscodeshift transforms for migrating Button from v0 to v1 (#1663) 2022-09-22 11:32:17 -07:00
just.config.js jscodeshift transforms for migrating Button from v0 to v1 (#1663) 2022-09-22 11:32:17 -07:00
package.json applying package updates 2024-04-11 18:08:46 +00:00
transform.js Add cli to run transforms using the codemods package (#2189) 2023-01-03 17:39:23 -08:00
tsconfig.json Add cli to run transforms using the codemods package (#2189) 2023-01-03 17:39:23 -08:00

README.md

@fluentui-react-native/transforms

This package supplies transforms that help with refactoring FURN code. The transforms are passed into jscodeshift to transform code.

Usage

  1. Install jscodeshift using the instructions here
  2. Run the transforms using the following command:
npx -p @fluentui-react-native/codemods transform -t <transform_name> --path <path_to_files_to_transform>

For example

npx -p @fluentui-react-native/codemods transform -t button-v0-to-v1 --path .\apps\fluent-tester\src\TestComponents\Button\deprecated\ButtonFocusTest.tsx

Tests

Test files are named in the format <transform>-test.ts. The "defineTest" from jscodeshift is used to run the test. Each test has an input and output file under the __testfixtures__ folder. The input is an example of code before the transform is run, and the output is what the code should look like after running the transform. Using this, we can ensure that the codemod works the way we intend to.

One caveat is that the codemod doesn't quite respect Prettier settings and doesn't seem to correctly format the output. So the output files are ignored by Prettier.