Skip to content

fix(deps): update to kuromojin@3 #3

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": [
"textlint-scripts/register"
]
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

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

textlint >= 5.0

## Usage

Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc`
Put `@textlint-ja/textlint-rule-no-dropping-i` to `.textlintrc`

```js
{
Expand All @@ -23,6 +21,11 @@ Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc`
}
```

## 参考

- [い抜き言葉](https://www.students.keio.ac.jp/hy/law/class/registration/files/a1399948036427.pdf)
- [適切な表現](https://www.nhk.or.jp/kokokoza/tv/basickokugo/archive/basic_kokugo_20.pdf)

## Contributing

1. Fork it!
Expand Down
123 changes: 60 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,62 @@
{
"author": "shirayu",
"bugs": {
"url": "https://github.com/textlint-ja/textlint-rule-no-dropping-i/issues"
},
"dependencies": {
"kuromojin": "^2.1.1",
"textlint-rule-helper": "^1.1.4"
},
"description": "い抜き言葉を検出するtextlint rule",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"power-assert": "^1.4.1",
"prettier": "^1.15.3",
"textlint-scripts": "^2.1.0"
},
"directories": {
"test": "test"
},
"files": [
"lib",
"src"
],
"homepage": "https://github.com/textlint-ja/textlint-rule-no-dropping-i",
"husky": {
"hooks": {
"precommit": "lint-staged"
}
},
"keywords": [
"textlint"
],
"license": "MIT",
"lint-staged": {
"*.{js,jsx,ts,tsx,css}": [
"prettier --write",
"git add"
]
},
"main": "lib/no-dropping-i.js",
"name": "@textlint-ja/textlint-rule-no-dropping-i",
"prettier": {
"printWidth": 120,
"singleQuote": false,
"tabWidth": 4
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/textlint-ja/textlint-rule-no-dropping-i.git"
},
"scripts": {
"build": "textlint-scripts build",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"prepublish": "npm run --if-present build",
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
"test": "textlint-scripts test",
"watch": "textlint-scripts build --watch"
},
"version": "1.1.0"
"author": "shirayu",
"bugs": {
"url": "https://github.com/textlint-ja/textlint-rule-no-dropping-i/issues"
},
"dependencies": {
"kuromojin": "^3.0.0",
"textlint-rule-helper": "^2.1.1"
},
"description": "い抜き言葉を検出するtextlint rule",
"devDependencies": {
"prettier": "^2.2.1",
"textlint-scripts": "^3.0.0"
},
"directories": {
"test": "test"
},
"files": [
"lib",
"src"
],
"homepage": "https://github.com/textlint-ja/textlint-rule-no-dropping-i",
"husky": {
"hooks": {
"precommit": "lint-staged"
}
},
"keywords": [
"textlint"
],
"license": "MIT",
"lint-staged": {
"*.{js,jsx,ts,tsx,css}": [
"prettier --write",
"git add"
]
},
"main": "lib/no-dropping-i.js",
"name": "@textlint-ja/textlint-rule-no-dropping-i",
"prettier": {
"printWidth": 120,
"singleQuote": false,
"tabWidth": 4
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/textlint-ja/textlint-rule-no-dropping-i.git"
},
"scripts": {
"build": "textlint-scripts build",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"prepublish": "npm run --if-present build",
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
"test": "textlint-scripts test",
"watch": "textlint-scripts build --watch"
},
"version": "1.1.0"
}
8 changes: 4 additions & 4 deletions src/no-dropping-i.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { RuleHelper } from "textlint-rule-helper";
import { tokenize } from "kuromojin";

function isTargetWord(token) {
return token.pos == "助詞" && token.pos_detail_1 == "接続助詞" && token.basic_form == "て";
return token.pos === "助詞" && token.pos_detail_1 === "接続助詞" && token.basic_form === "て";
}

function isMasuWord(token) {
return token.pos == "助動詞" && token.pos_detail_1 == "*" && token.basic_form == "ます";
return token.pos === "助動詞" && token.pos_detail_1 === "*" && token.basic_form === "ます";
}

module.exports = function(context) {
const helper = new RuleHelper(context);
let { Syntax, report, getSource, RuleError } = context;
const { Syntax, report, getSource, RuleError } = context;
return {
[Syntax.Str](node) {
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
let text = getSource(node);
const text = getSource(node);
return tokenize(text).then(tokens => {
tokens.reduce((prev, current) => {
if (isTargetWord(prev) && isMasuWord(current)) {
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

11 changes: 8 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "power-assert";
import rule from "../src/no-dropping-i";
import TextLintTester from "textlint-tester";
var tester = new TextLintTester();

const tester = new TextLintTester();
tester.run("no-dropping-i", rule, {
valid: ["見ています", "開発しています。"],
invalid: [
Expand All @@ -24,6 +24,11 @@ tester.run("no-dropping-i", rule, {
column: 5
}
]
}
},
// TODO: support
// {
// text: "人が話してる",
// errors: [{}]
// }
]
});
Loading