Skip to content

Commit

Permalink
Add contribution guide, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xsburg committed May 4, 2019
1 parent ff68349 commit 4b14ba7
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 196 deletions.
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing to VSCode Javascript Booster

## Pre-flight checklist

All releases are made using release branches, e.g. `release/0.11.0`.

- Update README.md:
- Add new changelog entry
- Add new code actions into the list
- Check if other changes are needed
- Place all the resources (gifs, etc) into the `resources` dir.
- Copy the README.md => client/README.md (pure copy and replace).
- Copy the new changelog entry into client/CHANGELOG.md
- Initiate new release by running the command (in the root dir): `npm version [patch|minor|major]`
- Merge the release branch into master, delete it and push

## Debugging the extension

- Compile the language server using `npm run compile` in the server/ directory.
- Launch `Launch client (client)`. You can debug the extension code now.
- If needed, launch `Attach to Server (server)` in parallel. Now you can debug both language server and the extension.

## Running tests (dev mode)

Language server:

- run `npm test -- --watch` inside the `server` directory to run the language server tests.
- launch `Server Tests (server)` to debug the tests.

Extension (client):

- run `npm test` inside the `client` directory to run the extension integration tests.
- launch `Extension tests (client)` to debug the tests.

## Useful links

- https://astexplorer.net/ - Explore code as an abstract syntax tree. Select Babylon7 parser to see the right tree. Helps when writing new code actions.
- https://github.com/facebook/jscodeshift - The engine behind this extension: a set of high-level tools to operate an AST.
- https://github.com/benjamn/recast - The library used by jscodeshift to mutate and pretty-print the code.
- https://github.com/benjamn/ast-types - The library under the hood of recast and jscodeshift.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ You can easily load and run your own code actions. -->

Largely inspired by [WebStorm](https://www.jetbrains.com/webstorm) and its variety of code refactorings. The extension uses [Babylon](https://github.com/babel/babel/tree/master/packages/babylon) to parse the code and then manipulates the abstract syntax tree using [jscodeshift](https://github.com/facebook/jscodeshift).

## Contribution

PRs are always welcome. Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for tips on how to build and debug.

## Release Notes

### 0.11.0
Expand Down
125 changes: 69 additions & 56 deletions client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@ All notable changes to the "vscode-javascript-booster" extension will be documen

<!-- Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. -->

### 0.11.0

- Add new range-based code action: `Call await statements in parallel with Promise.All()` (#7):

![Call await statements in parallel with Promise.All()](resources/convert-await-sequence-into-parallel.gif)

- Add new option to adjust formatting for generated code (only needed when a code action generates new code, the formatting of the unaffected code is always preserved). See `javascriptBooster.formattingOptions` and #10.
- Bumped @babel/parser, adds proper Angular support (#13).
- Fixed `Convert to arrow function` refactoring, now works correctly with async functions (#11).
- Fixed `replace if-else with ?:` refactoring, now supports refactoring of pure expressions:

![replace if-else with ?:](resources/replace-if-else-with-ternary_expression-statement.gif)

### 0.10.0

* [VSCode API] Switched to using selection parameter passed into `provideCodeActions()` (Fixes #5)
* `JSX: Expand empty tag` now puts the cursor between the tags when executed.
* `Split string under cursor` now puts selection before the second string when executed.
* `Split string under cursor` no longed triggers outside string quotes.
* `Remove redundant else` now supports the case when `if` branch ends with return statement:
- [VSCode API] Switched to using selection parameter passed into `provideCodeActions()` (Fixes #5)
- `JSX: Expand empty tag` now puts the cursor between the tags when executed.
- `Split string under cursor` now puts selection before the second string when executed.
- `Split string under cursor` no longed triggers outside string quotes.
- `Remove redundant else` now supports the case when `if` branch ends with return statement:
```javascript
if (condition) {
foo();
Expand All @@ -25,7 +38,7 @@ All notable changes to the "vscode-javascript-booster" extension will be documen
}
bar();
```
* `Replace with ternary` can now replace conditional return statements:
- `Replace with ternary` can now replace conditional return statements:
```javascript
if (cond) {
return a;
Expand All @@ -35,7 +48,7 @@ All notable changes to the "vscode-javascript-booster" extension will be documen
// ==>
return cond ? a : b;
```
* Added new action: `Simplify if-else`.
- Added new action: `Simplify if-else`.

```javascript
// Removes unused conditional branches, e.g.:
Expand All @@ -57,7 +70,7 @@ All notable changes to the "vscode-javascript-booster" extension will be documen
return !!cond;
```

* Added new action: `Simplify ?:`.
- Added new action: `Simplify ?:`.

```javascript
let foo = true ? 1 : 0;
Expand All @@ -71,83 +84,83 @@ All notable changes to the "vscode-javascript-booster" extension will be documen

### 0.9.0

* Improved language server performance when available code actions are computed.
* Fixed `Split string literal under the cursor`, now works well with a series of concatenations (`'foo' + 'bar][baz' => 'foo' + 'bar' + 'baz'`) and respects escape sequences.
* Fixed `App parens to arrow function parameter`, renamed into `Wrap parameter with ()` to avoid confusion with `Add braces to arrow function` and now always puts the cursor at the end of the parameter.
* Fixed a number of string actions becoming available when under string literals which cannot be transformed (e.g. inside imports, TS enums etc).
- Improved language server performance when available code actions are computed.
- Fixed `Split string literal under the cursor`, now works well with a series of concatenations (`'foo' + 'bar][baz' => 'foo' + 'bar' + 'baz'`) and respects escape sequences.
- Fixed `App parens to arrow function parameter`, renamed into `Wrap parameter with ()` to avoid confusion with `Add braces to arrow function` and now always puts the cursor at the end of the parameter.
- Fixed a number of string actions becoming available when under string literals which cannot be transformed (e.g. inside imports, TS enums etc).

### 0.8.0

* Extracted all AST-related operations into a Language Server. Massively improves UI responsiveness, particularly when working with large files. 馃敟
* Added new code action: `Split string literal under the cursor`.
* Fixed `Split into declaration and initialization` to work when inside a function/arrow expression.
- Extracted all AST-related operations into a Language Server. Massively improves UI responsiveness, particularly when working with large files. 馃敟
- Added new code action: `Split string literal under the cursor`.
- Fixed `Split into declaration and initialization` to work when inside a function/arrow expression.

### 0.7.0

* Optimized code action performance on large files. Only the transformed fragment of the code is replaced when an action is applied.
* Fixed Extend/Shrink selections fallback commands not working due to missing extension activation points.
- Optimized code action performance on large files. Only the transformed fragment of the code is replaced when an action is applied.
- Fixed Extend/Shrink selections fallback commands not working due to missing extension activation points.

### 0.6.0

* Changed `Split into declaration and initialization` action:
- Changed `Split into declaration and initialization` action:

* It no longer appears in the bulb when the cursor is inside a variable initializer.
* It no longer appears in the bulb when variable declaration is a part of ES6 module export.
- It no longer appears in the bulb when the cursor is inside a variable initializer.
- It no longer appears in the bulb when variable declaration is a part of ES6 module export.

* Changed `Convert to shorthand arrow function` action: it now supports transformation of Expression Statements (without explicit return).
- Changed `Convert to shorthand arrow function` action: it now supports transformation of Expression Statements (without explicit return).

### 0.5.0

* Added new inline code actions.
- Added new inline code actions.

* Add parens to arrow function parameter
* Remove braces from JSX attribute
- Add parens to arrow function parameter
- Remove braces from JSX attribute

* Added support for multiple cursors in smart selection commands.
* Changed `Replace if-else with ?:` action: it now supports if-return-else-return scenario.
* Fixed `Collapse/Expand empty tag` action: it previously didn't work when the element is nested into a JSX attribute.
- Added support for multiple cursors in smart selection commands.
- Changed `Replace if-else with ?:` action: it now supports if-return-else-return scenario.
- Fixed `Collapse/Expand empty tag` action: it previously didn't work when the element is nested into a JSX attribute.

### 0.4.0

* Added new inline code actions.
- Added new inline code actions.

* Flip ?:
* Convert function to arrow function
* Convert const -> let
* JSX: Collapse/Expand empty tag
- Flip ?:
- Convert function to arrow function
- Convert const -> let
- JSX: Collapse/Expand empty tag

* Added support for TypeScript 2.7 (definite assignment assertion modifier in class property definitions) through upgrading to the latest Babylon.
- Added support for TypeScript 2.7 (definite assignment assertion modifier in class property definitions) through upgrading to the latest Babylon.

* Changed `Split into declaration and initialization` action: it can now split const declarations.
- Changed `Split into declaration and initialization` action: it can now split const declarations.

* Fixed #1: Sequence of string literals doesn't convert properly when transforming to template literal.
- Fixed #1: Sequence of string literals doesn't convert properly when transforming to template literal.

* Fixed smart selection extension for collapsed JSX elements.
- Fixed smart selection extension for collapsed JSX elements.

### 0.3.0

* Added new smart selection commands for JavaScript and TypeScript (with behavior very close to those in WebStorm). When used in other languages, the fallback commands defined in settings are used.
- Added new smart selection commands for JavaScript and TypeScript (with behavior very close to those in WebStorm). When used in other languages, the fallback commands defined in settings are used.

* `javascriptBooster.extendSelection`
* `javascriptBooster.shrinkSelection`
- `javascriptBooster.extendSelection`
- `javascriptBooster.shrinkSelection`

* Added a command to run global code actions.
* Added support for external code actions, you can run them from a directory inside your workspace (the directory path is defined is settings, `/codemods` by default).
- Added a command to run global code actions.
- Added support for external code actions, you can run them from a directory inside your workspace (the directory path is defined is settings, `/codemods` by default).

### 0.2.0 (Initial release)

* Added the following inline code actions. The list will keep expanding in later releases.

* Flip if-else
* Remove redundant else
* Replace if-else with ?:
* Convert shorthand arrow function to statement
* Convert to shorthand arrow function
* Replace string with template string
* Replace template string with regular string
* Wrap value with {} (JSX attributes)
* Convert var to let
* Convert var to const
* Split into multiple declarations
* Split into declaration and initialisation
* Merge declaration and initialisation
- Added the following inline code actions. The list will keep expanding in later releases.

- Flip if-else
- Remove redundant else
- Replace if-else with ?:
- Convert shorthand arrow function to statement
- Convert to shorthand arrow function
- Replace string with template string
- Replace template string with regular string
- Wrap value with {} (JSX attributes)
- Convert var to let
- Convert var to const
- Split into multiple declarations
- Split into declaration and initialisation
- Merge declaration and initialisation

0 comments on commit 4b14ba7

Please sign in to comment.