Skip to content

Commit

Permalink
chore: Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlee2 committed Apr 23, 2024
1 parent d2ec2c8 commit 8491f8d
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,68 @@

# ember-codemod-remove-inject-as-service

_Codemod to [PROVIDE A SHORT DESCRIPTION.]_
_Codemod to remove `inject as service`_<sup>1</sup>

1. [Features](#features)
1. [Usage](#usage)
- [Arguments](#arguments)
- [Limitations](#limitations)
1. [Compatibility](#compatibility)
1. [Contributing](#contributing)
1. [License](#license)

<sup>1. `@ember/service` has provided `service` since [Ember 4.1](https://blog.emberjs.com/ember-4-1-released/). `inject`, which became an alias to `service`, is [planned to be deprecated in v6](https://rfcs.emberjs.com/id/1001-deprecate-named-inject).</sup>


## Features

The codemod helps you standardize how you inject services:

- Replace `inject` with `service`<sup>1</sup>
- Replace `!` with `declare` in TS files<sup>2</sup>
- Remove `private` and `readonly` keywords in TS files<sup>2</sup>

It preserves your code whenever possible.

<sup>1. Replaces `inject as ...` and `service as ...`, too.</sup>

<sup>2. Matches [the style shown in the Ember Guides](https://guides.emberjs.com/v5.8.0/typescript/core-concepts/services/#toc_using-services).</sup>


## Usage

Step 1. Quickly migrate.

```sh
cd <path/to/your/project>
npx ember-codemod-remove-inject-as-service <arguments>
```

Step 2. Fix formatting issues.

- Optional: Do a find-and-replace-all, if you want to place `@service()` and `declare` on the same line when possible.

- Find: `@service\((.+)\)(\n|\s)+declare`
- Replace: `@service($1) declare`

- Optional: Do a find-and-replace-all, if you want to place `@service` and `declare` on the same line when possible.

- Find: `@service(\n|\s)+declare`
- Replace: `@service declare`

- Run `lint:js:fix` (i.e. autofix from `eslint` and `prettier`).



### Arguments

[PROVIDE REQUIRED AND OPTIONAL ARGUMENTS.]
You must pass `--type` to indicate what type of project you have.

```sh
npx ember-codemod-remove-inject-as-service --type app
npx ember-codemod-remove-inject-as-service --type v1-addon
npx ember-codemod-remove-inject-as-service --type v2-addon
```

<details>

Expand Down

0 comments on commit 8491f8d

Please sign in to comment.