@textlint/browser-run
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@textlint/browser-run

Run textlint rule on browser for testing.

Purpose

If you want to know whether your textlint rule work or not, This Command line tool help you.

This tools did following steps:

  1. Bundle your textlint rule and @textlint/kernel by Browserify
  2. Run the bundle code on Electron browser by browser-run
  3. Output results

Install

Install with npm:

npm install @textlint/browser-run --global

Usage

Usage
  $ npx @textlint/browser-run <input-file-path>

Options
  --ruleId rule id. Default: test-rule 
  --rule file path to rule module entry
  
  --preset file path to rule preset module entry

Examples
  $ npx @textlint/browser-run --rule ./lib/rule.js ./README.md
  $ npx @textlint/browser-run --preset ./lib/rule-preset.js ./README.md

Notes

You should specify rule file that is build by textlint-scripts.

Node Module

import * as fs from "fs"
import * as path from "path"
import { browserRun } from "@textlint/browser-run";

const ruleFile = require.resolve("./fixtures/rule.js");
browserRun({
    input: fs.readFileSync(path.join(__dirname, "fixtures/README.md"), "utf-8"),
    inputFilePath: path.join(__dirname, "fixtures/README.md"),
    ruleFilePath: ruleFile,
    ruleId: "test-rule",
    cwd: __dirname
}).then(() => {
    console.log("Work");
}).catch(error => {
    console.log("Does not work")
});

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Package Sidebar

Install

npm i @textlint/browser-run

Weekly Downloads

3

Version

1.1.0

License

MIT

Unpacked Size

28.4 kB

Total Files

19

Last publish

Collaborators

  • textlint-user
  • azu
  • 0x6b