https://github.com/voxpelli/linemod
Comment driven line modifications
https://github.com/voxpelli/linemod
cli code-modification codemod comments converter
Last synced: 4 months ago
JSON representation
Comment driven line modifications
- Host: GitHub
- URL: https://github.com/voxpelli/linemod
- Owner: voxpelli
- License: mit
- Created: 2021-01-25T18:22:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T10:36:45.000Z (over 1 year ago)
- Last Synced: 2024-05-01T12:23:56.238Z (over 1 year ago)
- Topics: cli, code-modification, codemod, comments, converter
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Linemod
[](https://www.npmjs.com/package/linemod)
[](https://www.npmjs.com/package/linemod)
[](https://github.com/neostandard/neostandard)
[](https://mastodon.social/@voxpelli)
CLI companion for [linemod-core](https://github.com/voxpelli/linemod-core/), a comment driven line modification tool.
## Usage
### As npm script
```json
"scripts": {
"test": "linemod -e new index.js lib/utils.js"
}
```
### Command line
```bash
npm install -g linemod
```
Then run it at on your files that has modifications:
```bash
linemod -e new index.js lib/utils.js
```
If your command line supports globbing, then you can do:
```bash
linemod -e new *.js lib/**/*.js
```
### Programmatic use
Use [linemod-core](https://github.com/voxpelli/linemod-core) directly.
## Flags
* `--extension` / `-e` – **required** – the file extension used on the output files.
### Additional command line flags
* `--help` / `-h` – prints all available flags
* `--strict` / `-s` – treats warnings as errors
* `--verbose` / `-v` – prints warnings and notices
## Available modifications
All [`linemod-core` modifications](https://github.com/voxpelli/linemod-core/#available-modifications) are supported. Linemods are added at the end of the line they are supposed to apply to.
### `linemod-add:`
Prefixes the line with whatever is specified after the keyword:
```javascript
// linemod-add: import escape from 'stringify-entities';
```
Becomes:
```javascript
import escape from 'stringify-entities';
```
### `linemod-prefix-with:`
Prefixes the line with whatever is specified after the keyword:
```javascript
const exportedMethod = () => {}; // linemod-prefix-with: export
```
Becomes:
```javascript
export const exportedMethod = () => {};
```
### `linemod-replace-with:`
Replaces the line with whatever is specified after the keyword:
```javascript
const escape = require('stringify-entities'); // linemod-replace-with: import escape from 'stringify-entities';
```
Becomes:
```javascript
import escape from 'stringify-entities';
```
### `linemod-remove`
Simply removes the entire line.
Quite useful when combined with `linemod-prefix-with`:
```javascript
const exportedMethod = () => {}; // linemod-prefix-with: export
module.exports = { exportedMethod }; // linemod-remove
```
Becomes:
```javascript
export const exportedMethod = () => {};
```