Skip to content

Commit

Permalink
Merge pull request #5 from textlint-rule/module-interop
Browse files Browse the repository at this point in the history
chore(deps): upgrade dependencies
  • Loading branch information
azu authored Jul 20, 2019
2 parents 679e5bc + 153d53d commit dd80dd1
Show file tree
Hide file tree
Showing 6 changed files with 3,791 additions and 52 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# textlint-rule-rousseau [![Build Status](https://travis-ci.org/azu/textlint-rule-rousseau.svg?branch=master)](https://travis-ci.org/azu/textlint-rule-rousseau)
# textlint-rule-rousseau [![Build Status](https://travis-ci.org/textlint-rule/textlint-rule-rousseau.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-rousseau)

A [textlint](https://github.com/textlint/textlint "textlint") rule check english sentence using [rousseau](https://github.com/GitbookIO/rousseau "rousseau").

Expand All @@ -16,7 +16,7 @@ Lint results:
$ textlint --rule textlint-rule-rousseau README.md
textlint-rule-rousseau: omit 'So' from the beginning of sentences
/Users/azu/.ghq/github.com/azu/textlint-rule-rousseau/README.md:11:1
/Users/textlint-rule/.ghq/github.com/textlint-rule/textlint-rule-rousseau/README.md:11:1
v
10.
11. So the cat was stolen.
Expand All @@ -26,7 +26,7 @@ textlint-rule-rousseau: omit 'So' from the beginning of sentences
textlint-rule-rousseau: "was stolen" may be passive voice
Suggestions:
=> stole
/Users/azu/.ghq/github.com/azu/textlint-rule-rousseau/README.md:11:12
/Users/textlint-rule/.ghq/github.com/textlint-rule/textlint-rule-rousseau/README.md:11:12
v
10.
11. So the cat was stolen.
Expand Down
23 changes: 8 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "textlint-rule-rousseau",
"repository": {
"type": "git",
"url": "git+https://github.com/azu/textlint-rule-rousseau.git"
"url": "git+https://github.com/textlint-rule/textlint-rule-rousseau.git"
},
"author": "azu",
"email": "[email protected]",
"homepage": "https://github.com/azu/textlint-rule-rousseau",
"homepage": "https://github.com/textlint-rule/textlint-rule-rousseau",
"license": "MIT",
"bugs": {
"url": "https://github.com/azu/textlint-rule-rousseau/issues"
"url": "https://github.com/textlint-rule/textlint-rule-rousseau/issues"
},
"version": "1.4.5",
"description": "textlint rule check english sentence using rousseau",
Expand All @@ -22,10 +22,10 @@
"test": "test"
},
"scripts": {
"build": "babel src --out-dir lib --source-maps",
"watch": "babel src --out-dir lib --watch --source-maps",
"build": "textlint-scripts build",
"watch": "textlint-scripts build --watch",
"prepublish": "npm run --if-present build",
"test": "mocha",
"test": "textlint-scripts test",
"example": "npm run build && textlint --rulesdir lib README.md"
},
"keywords": [
Expand All @@ -35,19 +35,12 @@
"spellcheck"
],
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.5.0",
"babel-register": "^6.5.2",
"mocha": "^2.4.5",
"textlint": "^6.0.1",
"textlint-tester": "^1.1.0"
"textlint-scripts": "^2.1.0"
},
"dependencies": {
"object-assign": "^4.0.1",
"rousseau": "^1.0.0",
"textlint-rule-helper": "^2.0.0",
"textlint-util-to-string": "^1.2.1",
"textlint-util-to-string": "^2.1.1",
"unist-util-map": "^1.0.2"
}
}
49 changes: 24 additions & 25 deletions src/textlint-rule-rousseau.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// LICENSE : MIT
"use strict";
import {RuleHelper, IgnoreNodeManager} from "textlint-rule-helper";
const StringSource = require("textlint-util-to-string").default;
const StringSource = require("textlint-util-to-string");
const rousseau = require("rousseau");
const map = require("unist-util-map");
const ObjectAssign = require("object-assign");
const defaultOptions = {
// "suggestion", "warning", "error"
showLevels: ["suggestion", "warning", "error"],
Expand All @@ -16,7 +15,7 @@ const defaultOptions = {

const mapNode = function (ast, mapFn) {
return (function preorder(node, index, parent) {
const newNode = ObjectAssign({}, mapFn(node, index, parent));
const newNode = Object.assign({}, mapFn(node, index, parent));
if (node.children) {
newNode.children = node.children.map(function (child, index) {
return preorder(child, index, node);
Expand All @@ -26,43 +25,43 @@ const mapNode = function (ast, mapFn) {
}(ast, null, null));
};

export default function textlintRousseau(context, options = defaultOptions) {
module.exports = function textlintRousseau(context, options = defaultOptions) {
const helper = new RuleHelper(context);
const ignoreNodeManager = new IgnoreNodeManager();
const {Syntax, RuleError, report, getSource} = context;
const showLevels = options.showLevels || defaultOptions.showLevels;
const ignoreTypes = options.ignoreTypes || defaultOptions.ignoreTypes;
const ignoreInlineNodeTypes = options.ignoreInlineNodeTypes || [Syntax.Code];
const isShowType = (type)=> {
const isShowType = (type) => {
return ignoreTypes.indexOf(type) === -1;
};
const isShowLevel = (level) => {
return showLevels.indexOf(level) !== -1;
};
/*
{
// Type of check that output this suggestion
type: "so",
// Type of check that output this suggestion
type: "so",
// Level of importance
// "suggestion", "warning", "error"
level: "warning",
// Level of importance
// "suggestion", "warning", "error"
level: "warning",
// Index in the text
index: 10,
// Index in the text
index: 10,
// Size of the section in the text
offset: 2,
// Size of the section in the text
offset: 2,
// Message to describe the suggestion
message: "omit 'So' from the beginning of sentences",
// Message to describe the suggestion
message: "omit 'So' from the beginning of sentences",
// Replacements suggestion
replacements: [
{
value: ""
}
]
// Replacements suggestion
replacements: [
{
value: ""
}
]
}
*/
const createSuggest = (replacements) => {
Expand Down Expand Up @@ -97,7 +96,7 @@ export default function textlintRousseau(context, options = defaultOptions) {
};

return {
[Syntax.Paragraph](node){
[Syntax.Paragraph](node) {
// ignore if wrapped node types
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
Expand All @@ -110,7 +109,7 @@ export default function textlintRousseau(context, options = defaultOptions) {
const filteredNode = map(node, (node) => {
if (node.type === Syntax.Code) {
// only change `value` to dummy
return ObjectAssign({}, node, {
return Object.assign({}, node, {
value: new Array(node.value.length + 1).join("x")
});
}
Expand All @@ -132,4 +131,4 @@ export default function textlintRousseau(context, options = defaultOptions) {
});
}
}
}
};
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--compilers js:babel-register
--require textlint-scripts/register
Loading

0 comments on commit dd80dd1

Please sign in to comment.