Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

linemod

voxpelli67MIT2.0.1

Comment driven line modifications

readme

Linemod

npm version npm downloads neostandard javascript style Follow @voxpelli@mastodon.social

CLI companion for linemod-core, a comment driven line modification tool.

Usage

As npm script

"scripts": {
  "test": "linemod -e new index.js lib/utils.js"
}

Command line

npm install -g linemod

Then run it at on your files that has modifications:

linemod -e new index.js lib/utils.js

If your command line supports globbing, then you can do:

linemod -e new *.js lib/**/*.js

Programmatic use

Use linemod-core directly.

Flags

  • --extension / -erequired – 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 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:

// linemod-add: import escape from 'stringify-entities';

Becomes:

import escape from 'stringify-entities';

linemod-prefix-with:

Prefixes the line with whatever is specified after the keyword:

const exportedMethod = () => {}; // linemod-prefix-with: export

Becomes:

export const exportedMethod = () => {};

linemod-replace-with:

Replaces the line with whatever is specified after the keyword:

const escape = require('stringify-entities'); // linemod-replace-with: import escape from 'stringify-entities';

Becomes:

import escape from 'stringify-entities';

linemod-remove

Simply removes the entire line.

Quite useful when combined with linemod-prefix-with:

const exportedMethod = () => {}; // linemod-prefix-with: export
module.exports = { exportedMethod }; // linemod-remove

Becomes:

export const exportedMethod = () => {};

changelog

Changelog

2.0.1 (2024-07-19)

🩹 Fixes

  • update linemod-core to get latest fixes (741ad97)

🧹 Chores

  • deps: update dev dependencies (2e2e6f2)
  • deps: update linting dependencies (#23) (a3cf58b)
  • deps: update type dependencies (#36) (26f58bd)
  • update husky related files (5b3be7d)

2.0.0 (2024-06-25)

⚠ BREAKING CHANGES

  • require node >=18

🩹 Fixes

🧹 Chores

  • deps: update dev dependencies (4b31875)
  • deps: update to neostandard based linting (9f084f7)
  • deps: update type dependencies (b8d73f2)