WiderWider has been implemented to support a novel JavaScript on type formatting approach featuring an expanded layout aimed at enhancing readability. Specifically tailored for JavaScript coders who prefer:
It is acknowledged that some coders may initially find the wider code formatting style unfamiliar, and a few may encounter challenges in grasping its rationale. Nevertheless, embracing this formatting approach will reveal its convenience, leading to potential enjoyment. Additionally, it is worth noting that the optimal viewing experience for wider JavaScript code is attained with the aid of an ultrawide monitor and the Wide Github Chrome/Firefox browser extension. This combination ensures that the resulting code is displayed in the most suitable fashion. The initial release of Wider aims to fulfill the basic requirements set forth by the project's creator. However, in addition to maintenance, future releases will be implemented as the need for new functionalities arises. Please feel free to request additional features that you think would complement the package effectively. To get a general idea about the formatting of the Wider extension in JS and JSON, you can take a look at the extension's own extension.js or package.json files. FeaturesThe features introduced in this package can individually be enabled / disabled through Wider's settings menu. The current functionalities of Wider are as follows;
Simple Ternary is the one that we know best. Entering colon (
Nested Ternary is about narrowing multiple but dependent conditions into a single resolution. Such as in pseudo code
Switching Ternary is similar to the
Even if the comma-first functionality is enabled from the settings, it will only be effective if a space is placed after the left curly brace, left paranthesis or square bracket. Wider then auto-adopts a comma-first layout for object/array structures when a comma is entered at the end of the line. It's important to know that the Auto Closing Brackets option of the VSCode editor should be active, and you should be typing between the brackets. Also, when activated, Wider will attempt to set the Auto Closing Brackets option to
When the comma operator (,) is used for sequencing expressions or to separate function arguments. The comma-first layout scheme enhances the readability of the code especially with ternary based conditionals or with stacked method chains. In function arguments you may still benefit from this functionality if your arguments are long or expressions by themselves. If a space is placed right after the opening left bracket, Wider automatically adopts the comma-first layout mode for expression sequencing. This takes effect when a comma is added at the end of the line. It's important to note that the Auto Closing Brackets option of the VSCode editor should be active and you should be typing between the brackets. Also note that when activated, Wider will attempt to set the Auto Closing Brackets option in the VSCode editor settings to
Starting with version 0.2.0, an experimental feature has been incorporated with the purpose of transforming a selected object or array structure into a broader comma-first layout. It is recommended that the selection closely encompasses the object or array intended for conversion. Should the selection extend to extraneous portions of your code, the algorithm's eagerness for conversion may result in unintended alterations. Also as of current version all comments in the selection are removed. This is a backlog and will be fixed. Prior to implementation, testing and cautious usage is advised to avoid unexpected changes in your codebase.
Wider demonstrates a high proficiency in stacked method chaining, especially in contexts similar to JavaScript (JS) Promises, particularly when used in conjunction with Comma First Expression Sequencing. In the domain of Promises and other concepts centered around method chaining, the imperative nature of stacked method chaining becomes pivotal. It's important to note that Wider's functionality for stacked method chaining doesn't stack properties and is only effective when methods are immediately followed by a period.
Wherever a classical function declaration is on the line, its body gets indented 2 spaces relative to the start of the "function" keyword. This method of indentation isolates the function clearly from the rest of the code, avoiding the need to search for closing curly brackets. The usefulness of Deep Indented Functions is particularly evident when classically defined functions are used as callbacks or within Comma-First Expression Sequencing. RequirementsWider has no dependencies. Extension SettingsBy default, the aforementioned features are enabled, but you have the flexibility to disable them individually through the settings menu, and the changes will take effect immediately.
Known IssuesNothing so far. Feel free to register encountered issues at the project repo. Things to Remember
Release NotesSee the CHANGELOG file for details. LicenseThis project is licensed under the MIT License - see the LICENSE file for details. |