├── .gitignore ├── .vscodeignore ├── LICENSE ├── README.md ├── images └── js-refactor-icon.png ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | temp.js 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # VSIX files 12 | *.vsix 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directory 30 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 31 | node_modules 32 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | docs/ 3 | typings/ 4 | test/ 5 | .gitignore 6 | .eslintrc 7 | build-docs.js 8 | jsconfig.json 9 | vsc-extension-quickstart.md 10 | modules/ 11 | extension.js 12 | container.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Chris Stead 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JS Refactor :: JS CodeFormer # 2 | 3 | JS Refactor has been retired. This project is now an extension installer for its replacement, JS CodeFormer. If you install this extension, you will get that one. 4 | 5 | You can install JS CodeFormer directly: 6 | 7 | https://marketplace.visualstudio.com/items?itemName=cmstead.js-codeformer 8 | 9 | ## The Good News/Bad News Situation ## 10 | 11 | The good news, this project will install JS CodeFormer for you, and you will get nearly the same hotkeys you've developed muscle memory for. The bad news, this is not the old project. 12 | 13 | More good news: JS CodeFormer is a significant improvement in a number of ways: 14 | 15 | - **It's faster** -- a LOT faster. In just about every way. 16 | - **It has a broader language footprint** -- JSR at its best supported standard JavaScript and some TypeScript if it wasn't too fancy. JS CodeFormer can parse and interpret a large number of languages and framework-specific file formats, including JS/TS embedded in HTML and HTML-like files. 17 | - **It's designed for stability and maintenance** -- The source code is well tested, and designed for quick easy fixes, which has already borne fruit. 18 | - **The old JSR bugs are gone** -- I combed through the old issues and either verified they were gone, or fixed them if they were a design oversight. 19 | 20 | ## The Highlights ## 21 | 22 | ### Language Support ### 23 | 24 | Languages: 25 | 26 | - JavaScript 27 | - TypeScript 28 | - HTML (Embedded Javascript) 29 | 30 | Frameworks: 31 | 32 | - Angular 33 | - React 34 | - Vue 35 | 36 | Framework-specific formats: 37 | 38 | - JSX 39 | - TSX 40 | - Vue Single-file components 41 | - Full Vue support requires the Vetur extension: https://marketplace.visualstudio.com/items?itemName=octref.vetur 42 | 43 | Experimental framework support: 44 | 45 | - Svelte -- requires the Svelte extension to work 46 | - https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode 47 | 48 | ### Refactorings ### 49 | 50 | - Extract Method/Function 51 | - Windows: `ctrl+shift+j, m` 52 | - Mac: `cmd+shift+j, m` 53 | - Extract to Parameter 54 | - Windows: `ctrl+shift+j, p` 55 | - Mac: `cmd+shift+j, p` 56 | - Extract Variable 57 | - Windows: `ctrl+shift+j, v` 58 | - Mac: `cmd+shift+j, v` 59 | - Inline Variable 60 | - Windows: `ctrl+shift+j, i` 61 | - Mac: `cmd+shift+j, i` 62 | - Rename (important for non js/ts files) 63 | - Windows: `ctrl+shift+j, r` 64 | - Mac: `cmd+shift+j, r` 65 | 66 | ### Conversions ### 67 | 68 | - Change Variable Type 69 | - Convert Expression to Template Literal 70 | - Convert Function to Arrow Function 71 | - Convert Function to Function Expression 72 | - Convert Function Property to Method 73 | - Convert Function Variable to Function Declaration 74 | - Toggle Property Declaration Type 75 | 76 | ### Other Actions ### 77 | 78 | - Surround with (open options list) 79 | - Windows: `ctrl+shift+j, w` 80 | - Mac: `cmd+shift+j, w` 81 | - Introduce variable 82 | - Introduce function 83 | - Lift and name function expression 84 | 85 | ## Why (The Life Story) ## 86 | 87 | JS Refactor was created at a time when VS Code was new and the refactoring landscape in the editor was limited. It was initially designed to simply be a refactoring extension. As time went along, it grew, and extended beyond being a simple refactoring tool. 88 | 89 | Meanwhile the codebase was increasingly difficult to maintain. It was the first extension I authored for VS Code, and, even with significant work to improve the codebase, the problems were built too deeply into the core. 90 | 91 | Eventually JS Refactor broke and I didn't have the energy to deal with the fallout anymore. I stopped most work for almost 2 full years. Once I resurfaced, I realized the only way out was to replace the original and build a system around certain principles which would lead to software which would work reliably, and could be maintained at a sustainable pace. 92 | 93 | I started work on JS CodeFormer. Now that JS CodeFormer is in a stable initial state, it is time to give JS Refactor an honorable send-off. Instead of leaving a project to languish, it made more sense to send people where they can get something arguably better. This led me to the state of the software you see today. 94 | 95 | Thank you to everyone who joined me on the initial journey. I hope you all will come and join me as we build better software together! 96 | -------------------------------------------------------------------------------- /images/js-refactor-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmstead/js-refactor/b26540dd8e896681ebb4b7796c508a43374fc89b/images/js-refactor-icon.png -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsrefactor", 3 | "version": "3.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "jsrefactor", 9 | "version": "3.0.0", 10 | "engines": { 11 | "vscode": "^0.12.0" 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsrefactor", 3 | "displayName": "JS Refactor :: JS CodeFormer", 4 | "description": "Automated refactoring tools to smooth your development workflow", 5 | "version": "3.0.1", 6 | "publisher": "cmstead", 7 | "repository": { 8 | "url": "https://github.com/cmstead/js-refactor.git", 9 | "type": "git" 10 | }, 11 | "author": { 12 | "name": "Chris Stead" 13 | }, 14 | "engines": { 15 | "vscode": "^0.12.0" 16 | }, 17 | "categories": [ 18 | "Programming Languages", 19 | "Snippets", 20 | "Formatters", 21 | "Other" 22 | ], 23 | "keywords": [ 24 | "refactor", 25 | "refactoring", 26 | "javascript", 27 | "react", 28 | "vue", 29 | "typescript", 30 | "automation" 31 | ], 32 | "scripts": { 33 | "test": "npm run behavior-tests && npm run unit-tests & npm run integration-tests", 34 | "behavior-tests": "node ./node_modules/mocha/bin/mocha ./test/_behavior/commands/**/*.test.js ./test/_behavior/**/*.test.js", 35 | "integration-tests": "node ./node_modules/mocha/bin/mocha ./test/integration/**/*.test.js", 36 | "unit-tests": "node ./node_modules/mocha/bin/mocha ./test/unit/**/*.test.js", 37 | "commit": "node ./node_modules/nanocommit/", 38 | "build": "tfx extension create --manifest-globs vss-integration.json", 39 | "build-docs": "node build-docs", 40 | "publish": "vsce publish" 41 | }, 42 | "extensionPack": [ 43 | "cmstead.js-codeformer" 44 | ], 45 | "contributes": { 46 | "languages": [ 47 | { 48 | "id": "html" 49 | }, 50 | { 51 | "id": "javascript" 52 | }, 53 | { 54 | "id": "javascriptreact" 55 | }, 56 | { 57 | "id": "typescript" 58 | }, 59 | { 60 | "id": "typescriptreact" 61 | }, 62 | { 63 | "id": "vue" 64 | } 65 | ] 66 | }, 67 | "links": { 68 | "getstarted": { 69 | "uri": "https://github.com/cmstead/js-codeformer#readme" 70 | }, 71 | "support": { 72 | "uri": "https://github.com/cmstead/js-codeformer/issues" 73 | } 74 | }, 75 | "icon": "images/js-refactor-icon.png", 76 | "galleryBanner": { 77 | "color": "#ffffee" 78 | }, 79 | "public": true 80 | } --------------------------------------------------------------------------------