prevent-test-commit

1.0.0 • Public • Published

Introduction

Prohibit submitting test code to git by annotating TODO

Usage

npm i prevent-test-commit
# or
pnpm add prevent-test-commit

You can add comments to your code:

javascript

function add(a, b) {
  return a + b;
}

// #test Experimental code
add(1, 1);
prevent-test "./test.js"

Alt text

html

<div>hello word</div>

// #test Experimental code
<div>111111</div>
prevent-test "./test.html"

Alt text

bash

# #test Experimental code
echo "111111"
prevent-test "./test.sh"

Alt text

git hook

You can cooperate with git hook and lint-staged to verify before code submission

{
  "pre-commit": ["lint:staged"],
  "lint-staged": {
    "*": ["prevent-test"]
  }
}

API

matchAll

import { matchAll } from "prevent-test-commit";

// source
matchAll({
  source: `
    // #test 111
    console.log('hello word')
    `,
});
// or file path
matchAll({
  filePath: `./test.js`,
});

returns result:

[
  {
    "name": "test",
    "content": "111",
    "source": "",
    "index": 5,
    "filePath": "./test.js"
  }
]

Readme

Keywords

Package Sidebar

Install

npm i prevent-test-commit

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

5.57 kB

Total Files

4

Last publish

Collaborators

  • li13