Skip to content

A Python script that adds unique IDs to JSX components in a React project. The script searches all relevant files in a specified directory and adds a unique ID to each component that doesn't already have one.

Notifications You must be signed in to change notification settings

farukulutas/ReactJSX-UniqueIDs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

ReactJSX-UniqueIDs

A Python script to automatically add unique IDs to all JSX components in a React project. The script searches through all .js and .jsx files in the specified directory, generates a unique string, and adds it as an ID to any component that doesn't already have one. The modified files are then overwritten with the updated content.

Why was this project created?

Automated tests require target components to have a unique ID in order to function correctly. However, there were no existing packages, code, or tools that addressed this need. As a result, this simple script was created.

Installation

  1. Clone this repository or download the script directly.
  2. Make sure you have Python installed on your machine.
  3. No additional dependencies are required for this script.

Usage

  1. Open the unique_ids.py file in your preferred editor.
  2. Set the path variable to the directory path of your React project.
  3. Run the script.
  4. Check your React project files to see that unique IDs have been added to all JSX components that didn't previously have one.

Note: If any components already have an ID, they will not be modified. However, as a result of the automatic ID assignment, there may be syntax errors that need to be fixed. It is recommended to use a linter such as the ESlint VSCode extension to help identify and fix any syntax errors that may occur due to the automatic addition of IDs.

Contributing

Contributions to this project are always welcome! If you find any bugs or have ideas for new features, please open an issue on this repository.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute this script as needed.

About

A Python script that adds unique IDs to JSX components in a React project. The script searches all relevant files in a specified directory and adds a unique ID to each component that doesn't already have one.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages