fluentui-react-native/packages/codemods
UI-Fabric-RN-Bot 4532634515 applying package updates 2024-09-23 18:26:22 +00:00
..
src Update a bunch of dependencies (#3750) 2024-09-23 17:51:46 +00: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-09-23 18:26:22 +00:00
CHANGELOG.md applying package updates 2024-09-23 18:26:22 +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
jest.config.js
just.config.js
package.json applying package updates 2024-09-23 18:26:22 +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.