https://github.com/nullvoxpopuli/optional-chaining-codemod
there should be more codemods for mundane stuff like this
https://github.com/nullvoxpopuli/optional-chaining-codemod
Last synced: over 1 year ago
JSON representation
there should be more codemods for mundane stuff like this
- Host: GitHub
- URL: https://github.com/nullvoxpopuli/optional-chaining-codemod
- Owner: NullVoxPopuli
- Created: 2019-10-03T01:03:47.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:16:24.000Z (over 2 years ago)
- Last Synced: 2025-03-30T00:31:42.258Z (over 1 year ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# optional-chaining-codemod
Transforms:
```
foo && foo.bar;
foo.bar && foo.bar.baz;
(foo || {}).bar;
((foo || {}).bar || {}).baz;
((foo || {}).bar || {}).baz();
```
to
```
foo?.bar;
foo.bar?.baz;
foo?.bar;
foo?.bar?.baz;
foo?.bar?.baz();
```
## Usage
To run a specific codemod from this project, you would run the following:
```
npx @nullvoxpopuli/optional-chaining-codemod path/of/files/ or/some**/*glob.js
# or
yarn global add @nullvoxpopuli/optional-chaining-codemod
optional-chaining-codemod path/of/files/ or/some**/*glob.js
# or
volta install @nullvoxpopuli/optional-chaining-codemod
optional-chaining-codemod path/of/files/ or/some**/*glob.js
```
## Transforms
* [optional-chaining](transforms/optional-chaining/README.md)
## Contributing
### Installation
* clone the repo
* change into the repo directory
* `yarn`
### Running tests
* `yarn test`
### Update Documentation
* `yarn update-docs`