-
Notifications
You must be signed in to change notification settings - Fork 602
Phase 2: ES6 Code Quality Enhancements + Modern Tooling #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Convert var → const/let across 13 core library files - Apply template literals for string concatenation - Modernize variable scoping in loops and functions - Add ES6_REFACTORING_PLAN.md documenting progress and next steps - Maintain backward compatibility with Node.js 4.x+ Core files refactored: - lib/WebSocketConnection.js (extensive class conversion) - lib/WebSocketClient.js, lib/WebSocketServer.js - lib/WebSocketFrame.js, lib/WebSocketRequest.js - lib/W3CWebSocket.js, lib/Deprecation.js - lib/utils.js, lib/websocket.js, lib/browser.js - example/whiteboard/whiteboard.js 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Replace JSHint with ESLint for modern JavaScript linting - Remove gulp and use npm scripts for build tasks - Standardize codebase to 2-space indentation - Update package.json with new linting commands - Add comprehensive ESLint configuration for ES6+ support - Auto-format all files to consistent style - All tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @theturtle32, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request represents 'Phase 2' of a larger ES6 refactoring effort. It significantly modernizes the codebase by adopting various ES6 language features for improved readability and maintainability. Concurrently, it updates the development workflow by replacing JSHint and Gulp with ESLint and npm scripts, standardizing code formatting across all files. A key structural change includes converting the WebSocketConnection to use ES6 class syntax.
Highlights
- Tooling Modernization: Replaced the old JSHint/Gulp setup with modern ESLint and npm scripts for linting and development tasks. New commands
npm run lint,npm run lint:fix, andnpm run checkare available. - ES6 Code Quality: Applied various ES6 features across the codebase, including
const/letfor variable declarations, template literals for string formatting, arrow functions for callbacks, destructuring, default parameters, and object literal enhancements. - Code Formatting Standard: Standardized the entire codebase to use consistent 2-space indentation, enforced by the new ESLint configuration.
- WebSocketConnection Class Conversion: Refactored the core
WebSocketConnectionfrom a prototype-based constructor to modern ES6 class syntax. - Refactoring Plan Document: Added a new markdown document (
ES6_REFACTORING_PLAN.md) outlining the multi-phase plan for ES6 adoption, detailing completed and remaining work.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully modernizes the codebase by migrating from JSHint/gulp to ESLint/npm scripts and applying various ES6 features like const/let, arrow functions, template literals, and destructuring. The changes align well with the stated goals of Phase 2 refactoring. Several instances of var can be replaced with const or let for improved clarity and scope management, particularly in test scripts. Additionally, some traditional function expressions in callbacks within test scripts could be converted to arrow functions for consistency with other refactored code. The documentation in CLAUDE.md should be updated to reflect the new linting command and indentation style.
| - Run autobahn tests: `cd test/autobahn && ./run-wstest.sh` | ||
|
|
||
| ## Coding Style | ||
| - Use tabs for indentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| function createCloseEvent(code, reason) { | ||
| var event = new yaeti.Event('close'); | ||
| var event = new yaeti.Event('close'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| var output = bufferAllocUnsafe(this.length + headerLength + (this.mask ? 4 : 0)); | ||
| var output = bufferAllocUnsafe(this.length + headerLength + (this.mask ? 4 : 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var args = { /* defaults */ | ||
| secure: false, | ||
| port: '9000', | ||
| host: 'localhost' | ||
| secure: false, | ||
| port: '9000', | ||
| host: 'localhost' | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable args is not reassigned. It should be declared with const instead of var.
| var args = { /* defaults */ | |
| secure: false, | |
| port: '9000', | |
| host: 'localhost' | |
| secure: false, | |
| port: '9000', | |
| host: 'localhost' | |
| }; | |
| const args = { /* defaults */ | |
| secure: false, | |
| port: '9000', | |
| host: 'localhost' | |
| }; |
| }; | ||
|
|
||
| /* Parse command line options */ | ||
| var pattern = /^--(.*?)(?:=(.*))?$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var wsServer = new WebSocketServer({ | ||
| httpServer: server, | ||
| autoAcceptConnections: true, | ||
| maxReceivedFrameSize: 64*1024*1024, // 64MiB | ||
| maxReceivedMessageSize: 64*1024*1024, // 64MiB | ||
| fragmentOutgoingMessages: false, | ||
| keepalive: false, | ||
| disableNagleAlgorithm: false | ||
| httpServer: server, | ||
| autoAcceptConnections: true, | ||
| maxReceivedFrameSize: 64*1024*1024, // 64MiB | ||
| maxReceivedMessageSize: 64*1024*1024, // 64MiB | ||
| fragmentOutgoingMessages: false, | ||
| keepalive: false, | ||
| disableNagleAlgorithm: false | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable wsServer is not reassigned. It should be declared with const instead of var.
const wsServer = new WebSocketServer({
httpServer: server,
autoAcceptConnections: true,
maxReceivedFrameSize: 64*1024*1024, // 64MiB
maxReceivedMessageSize: 64*1024*1024, // 64MiB
fragmentOutgoingMessages: false,
keepalive: false,
disableNagleAlgorithm: false
});| var client = new WebSocketClient({ | ||
| tlsOptions: { | ||
| rejectUnauthorized: false | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cert: fs.readFileSync( 'certificate.pem' ) | ||
| }; | ||
|
|
||
| var server = https.createServer( config ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var wsServer = new WebSocketServer({ | ||
| httpServer: server, | ||
| autoAcceptConnections: false | ||
| httpServer: server, | ||
| autoAcceptConnections: false | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable wsServer is not reassigned. It should be declared with const instead of var.
| var wsServer = new WebSocketServer({ | |
| httpServer: server, | |
| autoAcceptConnections: false | |
| httpServer: server, | |
| autoAcceptConnections: false | |
| }); | |
| const wsServer = new WebSocketServer({ | |
| httpServer: server, | |
| autoAcceptConnections: false | |
| }); |
| console.log('Closed. (' + reasonCode + ') ' + description + | ||
| activeCount++; | ||
| console.log('Opened from: %j\n---activeCount---: %d', request.remoteAddresses, activeCount); | ||
| var connection = request.accept(null, request.origin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Code Quality Improvements
Tooling Modernization
npm run lint,npm run lint:fix, andnpm run checkTest Results
✅ All existing tests continue to pass
✅ No breaking changes to public API
✅ Maintains Node.js 4.x+ compatibility
🤖 Generated with Claude Code