https://github.com/zhanghai/gnome-shell-extension-es6-class-codemod
A jscodeshift transform that helps migrating GNOME Shell extensions to 3.32
https://github.com/zhanghai/gnome-shell-extension-es6-class-codemod
gnome-shell gnome-shell-extension javascript jscodeshift
Last synced: 15 days ago
JSON representation
A jscodeshift transform that helps migrating GNOME Shell extensions to 3.32
- Host: GitHub
- URL: https://github.com/zhanghai/gnome-shell-extension-es6-class-codemod
- Owner: zhanghai
- Archived: true
- Created: 2019-03-20T11:20:58.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-16T03:54:27.000Z (almost 6 years ago)
- Last Synced: 2024-11-02T21:31:51.824Z (5 months ago)
- Topics: gnome-shell, gnome-shell-extension, javascript, jscodeshift
- Language: JavaScript
- Size: 28.3 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-codemods - gnome-shell-extension-es6-class-codemod - A jscodeshift transform that helps migrating GNOME Shell extensions to 3.32. (Misc / ant-design)
README
# gnome-shell-extension-es6-class-codemod
A [jscodeshift](https://github.com/facebook/jscodeshift/) transform that helps [migrating GNOME Shell extensions to 3.32](https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361).
## What it does
In order to migrate to the new ES6 class based syntax in GNOME Shell 3.32, the following changes will be made by this transform:
- Replace `new Lang.Class()` and `new GObject.Class()` with the ES6 `class` syntax.
- If the old class is a GObject class, wrap the new class with `GObject.registerClass()`.
- Replace `_init()` with `constructor`, if the old class is not a GObject class.
- Replace `this.parent()` with `super.methodName()`, or `super()` if it's instead the `constructor`.
- Add import for `GObject` if any old class was a GObject class, and remove import for `Lang` if it become unused.The transform tries its best to preserve comments and spacing. However in some cases, you might still need to adjust the spacing manually, which is a limitation of the underlying framework.
## Usage
```bash
npm install
# This will modify the files in place.
npx jscodeshift --run-in-band path/to/your/extension
```To see a example, run `npm test`.