Registry / devops / react-file-formatter

react-file-formatter

JSON →
library1.1.12jsnpmunverified

A CLI tool (v1.1.12, npm, available as a global or npx command) for formatting and standardizing React code files. It reorders hooks, functions, and return statements based on a user-defined JSON config, integrates Prettier for consistent formatting, and supports JSX, TSX, JS, TS files. Differentiates itself by focusing on React-specific code organization (e.g., hook ordering) rather than generic formatting alone. Low maintenance frequency; no recent updates.

npm install react-file-formatter
INSTALL
IMPORT
SIG · REACT-FILE-FORMATT
R
react-file-formatter
devopsjavascriptv1.1.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI usage
npx react-file-formatter --format-all
npm i react-file-formatter -g && react-file-formatter --format-all
npx is recommended to avoid global install; global install also works.

Formats all React files in directories defined in .reactfileformaterrc.json content property.

npx react-file-formatter --format-all
Debug
Known issues
gotchaConfiguration file .reactfileformaterrc.json must have a non-empty 'content' array, otherwise no files are processed.
fix
Ensure .reactfileformaterrc.json in root contains 'content' with paths like ['./src'].
affects: >=1.0.0
breakingThe 'order' array in config is case-sensitive: 'ArrowFunctionExpression' not 'arrowfunctionexpression'.
fix
Use exact string values: 'useContext', 'useState', 'useRef', 'useMutation', 'function', 'ArrowFunctionExpression', 'useEffect', 'return'.
affects: >=1.0.0
gotchaTool modifies files in-place; no undo. Run version control commit before formatting.
fix
Commit or backup files before running react-file-formatter.
affects: >=1.0.0
gotchaPrettier config in .reactfileformaterrc.json overrides any local .prettierrc; merging not supported.
fix
Define all Prettier settings inside the 'prettier' key of config file, or omit to use defaults.
affects: >=1.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '.reactfileformaterrc.json'
Missing configuration file in the project root. The tool requires .reactfileformaterrc.json.
fix
Create .reactfileformaterrc.json in the project root with at least: { "content": ["./src"], "order": [] }
No files found in the given directory path.
The 'content' array in config does not point to existing directories or contains invalid paths.
fix
Update 'content' with correct relative paths from project root, e.g., "./src/components".
SyntaxError: Unexpected token ... in JSON at position...
Invalid JSON in .reactfileformaterrc.json file.
fix
Validate JSON (e.g., using jsonlint) and ensure there are no trailing commas, unquoted keys, etc.
Upgrade
Version history
1.1.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
react-file-formatter — npm install react-file-formatter · libregistry