Skip to content

Commit 8686ce0

Browse files
authored
fix(deps): update to kuromojin@3 (#3)
* Update READE * Update README * fix(deps): Update to kuromojin@3 * chore: remove unsed deps * refactor: use === * test: add test case
1 parent 1eeace2 commit 8686ce0

File tree

7 files changed

+1700
-1950
lines changed

7 files changed

+1700
-1950
lines changed

.mocharc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": [
3+
"textlint-scripts/register"
4+
]
5+
}

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
npm install @textlint-ja/textlint-rule-no-dropping-i
1111

12-
textlint >= 5.0
13-
1412
## Usage
1513

16-
Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc`
14+
Put `@textlint-ja/textlint-rule-no-dropping-i` to `.textlintrc`
1715

1816
```js
1917
{
@@ -23,6 +21,11 @@ Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc`
2321
}
2422
```
2523

24+
## 参考
25+
26+
- [い抜き言葉](https://www.students.keio.ac.jp/hy/law/class/registration/files/a1399948036427.pdf)
27+
- [適切な表現](https://www.nhk.or.jp/kokokoza/tv/basickokugo/archive/basic_kokugo_20.pdf)
28+
2629
## Contributing
2730

2831
1. Fork it!

package.json

+60-63
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,62 @@
11
{
2-
"author": "shirayu",
3-
"bugs": {
4-
"url": "https://github.com/textlint-ja/textlint-rule-no-dropping-i/issues"
5-
},
6-
"dependencies": {
7-
"kuromojin": "^2.1.1",
8-
"textlint-rule-helper": "^1.1.4"
9-
},
10-
"description": "い抜き言葉を検出するtextlint rule",
11-
"devDependencies": {
12-
"@babel/core": "^7.9.0",
13-
"@babel/preset-env": "^7.9.0",
14-
"power-assert": "^1.4.1",
15-
"prettier": "^1.15.3",
16-
"textlint-scripts": "^2.1.0"
17-
},
18-
"directories": {
19-
"test": "test"
20-
},
21-
"files": [
22-
"lib",
23-
"src"
24-
],
25-
"homepage": "https://github.com/textlint-ja/textlint-rule-no-dropping-i",
26-
"husky": {
27-
"hooks": {
28-
"precommit": "lint-staged"
29-
}
30-
},
31-
"keywords": [
32-
"textlint"
33-
],
34-
"license": "MIT",
35-
"lint-staged": {
36-
"*.{js,jsx,ts,tsx,css}": [
37-
"prettier --write",
38-
"git add"
39-
]
40-
},
41-
"main": "lib/no-dropping-i.js",
42-
"name": "@textlint-ja/textlint-rule-no-dropping-i",
43-
"prettier": {
44-
"printWidth": 120,
45-
"singleQuote": false,
46-
"tabWidth": 4
47-
},
48-
"publishConfig": {
49-
"access": "public"
50-
},
51-
"repository": {
52-
"type": "git",
53-
"url": "git+https://github.com/textlint-ja/textlint-rule-no-dropping-i.git"
54-
},
55-
"scripts": {
56-
"build": "textlint-scripts build",
57-
"husky": "^1.3.1",
58-
"lint-staged": "^8.1.0",
59-
"prepublish": "npm run --if-present build",
60-
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
61-
"test": "textlint-scripts test",
62-
"watch": "textlint-scripts build --watch"
63-
},
64-
"version": "1.1.0"
2+
"author": "shirayu",
3+
"bugs": {
4+
"url": "https://github.com/textlint-ja/textlint-rule-no-dropping-i/issues"
5+
},
6+
"dependencies": {
7+
"kuromojin": "^3.0.0",
8+
"textlint-rule-helper": "^2.1.1"
9+
},
10+
"description": "い抜き言葉を検出するtextlint rule",
11+
"devDependencies": {
12+
"prettier": "^2.2.1",
13+
"textlint-scripts": "^3.0.0"
14+
},
15+
"directories": {
16+
"test": "test"
17+
},
18+
"files": [
19+
"lib",
20+
"src"
21+
],
22+
"homepage": "https://github.com/textlint-ja/textlint-rule-no-dropping-i",
23+
"husky": {
24+
"hooks": {
25+
"precommit": "lint-staged"
26+
}
27+
},
28+
"keywords": [
29+
"textlint"
30+
],
31+
"license": "MIT",
32+
"lint-staged": {
33+
"*.{js,jsx,ts,tsx,css}": [
34+
"prettier --write",
35+
"git add"
36+
]
37+
},
38+
"main": "lib/no-dropping-i.js",
39+
"name": "@textlint-ja/textlint-rule-no-dropping-i",
40+
"prettier": {
41+
"printWidth": 120,
42+
"singleQuote": false,
43+
"tabWidth": 4
44+
},
45+
"publishConfig": {
46+
"access": "public"
47+
},
48+
"repository": {
49+
"type": "git",
50+
"url": "git+https://github.com/textlint-ja/textlint-rule-no-dropping-i.git"
51+
},
52+
"scripts": {
53+
"build": "textlint-scripts build",
54+
"husky": "^1.3.1",
55+
"lint-staged": "^8.1.0",
56+
"prepublish": "npm run --if-present build",
57+
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
58+
"test": "textlint-scripts test",
59+
"watch": "textlint-scripts build --watch"
60+
},
61+
"version": "1.1.0"
6562
}

src/no-dropping-i.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import { RuleHelper } from "textlint-rule-helper";
44
import { tokenize } from "kuromojin";
55

66
function isTargetWord(token) {
7-
return token.pos == "助詞" && token.pos_detail_1 == "接続助詞" && token.basic_form == "て";
7+
return token.pos === "助詞" && token.pos_detail_1 === "接続助詞" && token.basic_form === "て";
88
}
99

1010
function isMasuWord(token) {
11-
return token.pos == "助動詞" && token.pos_detail_1 == "*" && token.basic_form == "ます";
11+
return token.pos === "助動詞" && token.pos_detail_1 === "*" && token.basic_form === "ます";
1212
}
1313

1414
module.exports = function(context) {
1515
const helper = new RuleHelper(context);
16-
let { Syntax, report, getSource, RuleError } = context;
16+
const { Syntax, report, getSource, RuleError } = context;
1717
return {
1818
[Syntax.Str](node) {
1919
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
2020
return;
2121
}
22-
let text = getSource(node);
22+
const text = getSource(node);
2323
return tokenize(text).then(tokens => {
2424
tokens.reduce((prev, current) => {
2525
if (isTargetWord(prev) && isMasuWord(current)) {

test/mocha.opts

-1
This file was deleted.

test/test.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import assert from "power-assert";
21
import rule from "../src/no-dropping-i";
32
import TextLintTester from "textlint-tester";
4-
var tester = new TextLintTester();
3+
4+
const tester = new TextLintTester();
55
tester.run("no-dropping-i", rule, {
66
valid: ["見ています", "開発しています。"],
77
invalid: [
@@ -24,6 +24,11 @@ tester.run("no-dropping-i", rule, {
2424
column: 5
2525
}
2626
]
27-
}
27+
},
28+
// TODO: support
29+
// {
30+
// text: "人が話してる",
31+
// errors: [{}]
32+
// }
2833
]
2934
});

0 commit comments

Comments
 (0)