Skip to content

Commit 9867d7c

Browse files
dimensicursoragent
andauthored
Refactor: TypeScript Migration and Project Modernization (#517)
#313 * Refactor: Improve code quality and fix minor bugs This commit includes several refactoring efforts to improve the overall code quality and address minor bugs. Key changes include: - **Enhanced `removeEvent` function:** Added a null check to prevent errors when `object` is undefined. - **Improved `filter` function:** Corrected logic to properly handle input elements and content-editable elements. - **Refined `dispatch` function:** Addressed an issue with the `filter` function being called incorrectly and ensured proper handling of modifier keys. - **Updated `hotkeys` function:** Improved option parsing and handling of single callback scenarios. - **Addressed `removeKeyEvent` logic:** Corrected the condition for removing event listeners to ensure it functions correctly. - **Updated dependencies:** Several dependencies have been updated to their latest versions, including `@babel/helper-plugin-utils`, `@pmmmwh/react-refresh-webpack-plugin`, `core-js`, `es-abstract`, `get-intrinsic`, and others. These updates bring in bug fixes, performance improvements, and security patches. These changes collectively contribute to a more robust and reliable hotkeys library. Co-authored-by: root <root@dimensi.dev> * feat: Add TypeScript support and ESLint configuration This commit introduces TypeScript support by adding TypeScript-specific ESLint configurations and dependencies. Key changes include: - Updated `.eslintrc` to include TypeScript parser and rules. - Added `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` to `package.json` and `package-lock.json`. - Created a new `index.ts` file to satisfy TypeScript requirements. These changes enhance the project's maintainability and code quality by enforcing TypeScript standards. * Refactor: Enhance code readability and consistency This commit improves the formatting and structure of the `index.ts` file by standardizing quotation marks, aligning multiline imports, and ensuring consistent spacing. Additionally, it refines several function definitions and condition checks for better clarity. These changes contribute to improved maintainability and readability of the codebase. * feat: Add layout independence test HTML file This commit introduces a new HTML file for testing layout independence of hotkeys. The file includes a user interface with styled elements, hotkey definitions, and event logging functionality. It allows users to test hotkeys across different keyboard layouts, ensuring consistent behavior regardless of the active layout. The implementation leverages `event.code` for key detection, enhancing compatibility with various keyboard configurations. * chore: Update project configuration and dependencies This commit includes several updates to the project configuration and dependencies. Key changes are: - Added `dist` directory to `.gitignore` to prevent unnecessary files from being tracked. - Updated import statements in `index.d.ts` and `index.ts` to use consistent double quotes. - Removed outdated dependencies from `package-lock.json` and `package.json`, replacing them with `vite` and related plugins for improved build processes. - Introduced a new `vite.config.ts` for managing the build configuration. - Deleted unused files and scripts related to the previous build system, streamlining the project structure. These changes enhance the project's maintainability and prepare it for future development with Vite. * chore: Remove unused files and migrate to TypeScript This commit deletes several unused files, including configuration and type definition files, and transitions the main application code from JavaScript to TypeScript. Key changes include: - Removed `.kktrc.js`, `index.d.ts`, `index.js`, and other obsolete files. - Introduced new TypeScript files for the main application and updated the entry point to use TypeScript. - Updated styles from LESS to CSS modules for better maintainability. These changes streamline the project structure and enhance type safety across the codebase. * refactor: Standardize quotation marks and improve code formatting in tests This commit updates the `run.test.js` file to use consistent double quotes for string literals and enhances the overall formatting for better readability. Key changes include: - Replaced single quotes with double quotes in all test cases and function definitions. - Improved indentation and spacing for better code clarity. These changes contribute to a more uniform code style and enhance maintainability of the test suite. * chore: Update ESLint configuration and package dependencies This commit enhances the ESLint configuration by adding a rule for JSX file extensions and updates several package dependencies. Key changes include: - Added `react/jsx-filename-extension` rule to `.eslintrc` to allow JSX in `.js`, `.jsx`, `.ts`, and `.tsx` files. - Updated `@types/react` and `@types/react-dom` to the latest versions in `package-lock.json` and `package.json`. - Upgraded `@vitejs/plugin-react` to version 5.1.1 for improved compatibility. These changes improve code quality and ensure the project is using the latest type definitions and plugins. * chore: Update package dependencies and improve code structure This commit updates several development dependencies in `package.json` and `package-lock.json` to their latest versions, including ESLint, TypeScript-related packages, and various plugins. Key changes include: - Upgraded `@babel/eslint-parser`, `@typescript-eslint/eslint-plugin`, and `@typescript-eslint/parser` to version 8.46.4. - Updated `eslint` to version 8.57.1 and related plugins for improved linting capabilities. - Refactored the `unbind` function in `src/index.ts` for better readability by using a conditional statement. - Modified the `onMouseDown` event handler in `website/App.tsx` to improve parameter handling. These updates enhance code quality, maintainability, and ensure compatibility with the latest tools. * chore: Remove deprecated ESLint configuration files and migrate to new ESLint setup This commit deletes the old `.eslintignore` and `.eslintrc` files, transitioning to a new ESLint configuration in `eslint.config.js`. Key changes include: - Removed `.eslintignore` to streamline the ignore patterns directly in the new configuration. - Deleted `.eslintrc` in favor of a more modern ESLint setup using `eslint.config.js`, which integrates TypeScript and React plugins. - Updated `package.json` and `package-lock.json` to reflect the new ESLint dependencies and configurations. These changes enhance the project's linting capabilities and align with current best practices for ESLint configuration. * feat: Extend JSX support for custom 'dark-mode' element This commit adds TypeScript declarations for a new custom JSX element, 'dark-mode', within the React namespace. The declaration includes optional properties for enhanced functionality. These changes improve type safety and enable better integration of the 'dark-mode' component in the project. * remove examples * chore: Update package.json and improve Vite configuration This commit modifies the `package.json` to change the main and module entry points for the hotkeys library, adding an `exports` field for better module resolution. Additionally, the Vite configuration is updated to include an option for inserting a types entry in the dts plugin. Code formatting improvements are made in `src/index.ts` for consistency, including standardizing quotation marks and enhancing readability. * chore: Update .gitignore and README for hotkeys library This commit removes the 'dist' entry from the .gitignore file to ensure distribution files are tracked. Additionally, the README is updated to reflect the correct CDN link for the hotkeys library, changing from 'hotkeys.min.js' to 'hotkeys-js.umd.cjs'. New distribution files for the hotkeys library are also added, including the UMD module and source maps. * refactor: Improve code formatting and readability in utils.ts This commit enhances the formatting of the `utils.ts` file by standardizing the indentation and line breaks for better readability. Key changes include: - Reformatted the `isff` declaration for clarity. - Improved the structure of the `addEvent` and `removeEvent` functions by removing unnecessary type assertions. - Enhanced the `getMods` and `getKeys` functions for consistency in loop formatting. These changes contribute to a cleaner codebase and improve maintainability. * refactor: Standardize quotation marks and improve ESLint configuration This commit updates the ESLint configuration in `eslint.config.js` to use the `defineConfig` function for better compatibility and readability. Additionally, it standardizes quotation marks across multiple files, including `src/index.ts`, `src/utils.ts`, and `website/App.tsx`, enhancing code consistency. New ESLint rules are also added to improve code quality and maintainability. * refactor: Update hotkeys library types and improve code structure This commit introduces several type definitions in `src/types.ts` to enhance type safety and clarity in the hotkeys library. Key changes include: - Added new type definitions for `HotkeysEvent`, `KeyCodeInfo`, and various function types such as `SetScope`, `GetScope`, and `Filter`. - Refactored existing functions in `src/index.ts` to utilize the new type definitions, improving code readability and maintainability. - Updated the `unbind` function to use the new `Unbind` type for better clarity on its parameters. These changes contribute to a more robust and maintainable codebase, ensuring better integration and usage of the hotkeys library. * refactor: Enhance hotkeys library structure and improve type definitions This commit refactors the hotkeys library by renaming functions and variables for better clarity and consistency. Key changes include: - Renamed functions for improved readability, such as changing `P` to `isFirefox` and `j` to `addEventListener`. - Updated the `getMods` function to return an array of modifier key codes more clearly. - Refactored the `unbind` function to enhance its clarity and maintainability. - Improved type definitions in `index.d.ts` to better reflect the library's API. These changes contribute to a more maintainable and user-friendly codebase, ensuring better integration and usage of the hotkeys library. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 7183821 commit 9867d7c

43 files changed

Lines changed: 10955 additions & 28865 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 70 deletions
This file was deleted.

.kktrc.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)