https://github.com/ngarbezza/js-refactorings-collection
A collection of simple refactorings for Javascript
https://github.com/ngarbezza/js-refactorings-collection
Last synced: 11 days ago
JSON representation
A collection of simple refactorings for Javascript
- Host: GitHub
- URL: https://github.com/ngarbezza/js-refactorings-collection
- Owner: ngarbezza
- License: mit
- Created: 2021-02-19T10:34:09.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-11-27T11:59:03.000Z (7 months ago)
- Last Synced: 2025-11-30T04:52:33.595Z (7 months ago)
- Language: JavaScript
- Size: 269 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Javascript Refactorings Collection
A collection of simple refactorings for Javascript. It uses [Acorn](https://github.com/acornjs/acorn) for parsing the JS code.
## Why
Implementing refactorings is not that hard as it seems. We as developers should write our own tools if we don't have them available in our programming environments.
## Refactorings list
### Remove unnecessary conditional
Input:
```javascript
if (a > b) {
return true;
} else {
return false;
}
```
Output:
```javascript
return a > b;
```
Usage:
```javascript
const RemoveUnnecessaryConditional = require('lib/remove_unnecessary_conditional');
const originalCode = 'if (a > b) { return true } else { return false }';
const refactoring = new RemoveUnnecessaryConditional(originalCode);
const refactoredCode = refactoring.apply();
// refactoredCode: 'return a > b'
```
## Next Steps
- [ ] release NPM package
- [ ] VSCode integration
- [ ] Continue adding refactorings