GSoC22: Refactoring and Code Quality #53
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This is my first GSoC22 contribution to the project. This PR focus on improving the code quality of the project so the maintenance and adding new features to the project be much easier. This PR includes the following:
Bug Fixes
Can't clear filter created on Pie Chart
Before
After
The Pie Chart doesn't load filters on reload
Before
After
Components don't render when resizing
Before
After
Update used packages
updating the packages that use unsafe component lifecycles such as
react-resizable
andreact-grid-layout
Rewrite Most Of The Components To A Functional Style
Updating most of the components to use the new functional style of React and hooks. The functional style is easier to read and it produces less code. It also eliminates the usage of
this
andbind
keywords.Move Config and App Data To A Global State
Using the
Context
API now the config, data, filters and filtered data are accessible globally to all the components in the app, this is useful to avoid props drilling and this will enable us to add the ability for the user to change some of the configurations from the app GUI., for example, the config data can be accessed as followsconst { config, configLoading, configError } = useContext(ConfigContext);
Abstracting The Data Fetching Logic
Creating a custom-created React hook
useFetch
to handle all fetch requests in the app. This hook can be used as followsconst { error, data, isPending } = useFetch(URL);
Adding ESLint To The Project
Adding a static code analyzer is very important as it makes the coding style consistent in all code files and it helps to avoid any potential bug in the code
I configured the ESLint tool with React plugin: https://github.com/jsx-eslint/eslint-plugin-react
With Airbnb code style guide: https://github.com/airbnb/javascript
I fixed all linting issues in the code except the files in the
experimental
folder which I created to contain the files that aren't used currently in the projectRemoving The Build Files From Git Tracking