Skip to content
This repository was archived by the owner on May 23, 2021. It is now read-only.

Commit a498b92

Browse files
authored
Merge pull request #32 from textlint/update-deps
chore(deps): update dependencies
2 parents 1b5e25c + 134f6da commit a498b92

File tree

15 files changed

+1266
-282
lines changed

15 files changed

+1266
-282
lines changed

bin/cmd.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env node
2-
var spawn = require("cross-spawn");
3-
var script = process.argv[2];
4-
var args = process.argv.slice(3);
2+
const spawn = require("cross-spawn");
3+
const script = process.argv[2];
4+
const args = process.argv.slice(3);
55

66
switch (script) {
77
case "init":
88
case "build":
99
case "test":
10-
var result = spawn.sync("node", [require.resolve("../scripts/" + script)].concat(args), { stdio: "inherit" });
10+
const result = spawn.sync("node", [require.resolve("../scripts/" + script)].concat(args), { stdio: "inherit" });
1111
process.exit(result.status);
1212
break;
1313
default:

configs/babel-register.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
"use strict";
2-
require("@babel/register")(require("./babelrc"));
1+
require("@babel/register")(require("./babel.config"));

configs/babel.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
"@babel/env",
5+
{
6+
// For async/await support
7+
// https://babeljs.io/docs/en/babel-preset-env#targetsesmodules
8+
targets: {
9+
esmodules: true
10+
}
11+
}
12+
]
13+
],
14+
plugins: [
15+
// inline fs content
16+
"static-fs"
17+
]
18+
};

configs/babelrc.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"build": "textlint-scripts build",
55
"test": "textlint-scripts test"
66
},
7+
"dependencies": {
8+
"prh": "^5.4.3"
9+
},
710
"devDependencies": {
811
"textlint-scripts": "file:../"
912
}

example/src/common.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const prh = require("prh");
2+
const fs = require("fs");
3+
const path = require("path");
4+
module.exports = function(text) {
5+
const dict = fs.readFileSync(path.join(__dirname, "prh.yml"), "utf-8");
6+
const engine = prh.fromYAML("", dict);
7+
return engine.makeChangeSet("", text);
8+
};

example/src/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
"use strict";
2-
import assert from "assert";
2+
import mod from "./module";
3+
4+
const path = require("path");
5+
const common = require("./common");
36
module.exports = function(context, options = {}) {
47
const { Syntax, RuleError, report, getSource } = context;
58
return {
9+
// async test
10+
async [Syntax.Code](node) {
11+
return null;
12+
},
613
[Syntax.Str](node) {
714
// "Str" node
815
const text = getSource(text);
16+
// check prh
17+
const result = common(text);
18+
if (result.diffs.length > 0) {
19+
result.diffs.forEach(diff => {
20+
const ruleError = new RuleError("Found " + diff.expected + "!", {
21+
index: diff.index // padding of index
22+
});
23+
report(node, ruleError);
24+
});
25+
}
26+
// check inline
927
if (/bugs/.test(text)) {
1028
const indexOfBugs = text.search(/bugs/);
1129
const ruleError = new RuleError("Found bugs.", {

example/src/module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {};

example/src/prh.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 1
2+
rules:
3+
- expected: jQuery
4+
specs:
5+
- from: jquery
6+
to: jQuery
7+
- from: JQUERY
8+
to: jQuery

example/test/index-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ tester.run("rule", rule, {
1313
"OK."
1414
],
1515
invalid: [
16+
// inline file
17+
{
18+
text: "jquery",
19+
errors: [
20+
{
21+
message: "Found jQuery!",
22+
index: 0
23+
}
24+
]
25+
},
1626
// single match
1727
{
1828
text: "It is bugs.",

0 commit comments

Comments
 (0)