Skip to content

Commit 7f7fb40

Browse files
committed
Initial commit
0 parents  commit 7f7fb40

File tree

9 files changed

+4772
-0
lines changed

9 files changed

+4772
-0
lines changed

.gitignore

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/lib
2+
### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Node.gitignore
3+
4+
# Logs
5+
logs
6+
*.log
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
13+
# Directory for instrumented libs generated by jscoverage/JSCover
14+
lib-cov
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20+
.grunt
21+
22+
# node-waf configuration
23+
.lock-wscript
24+
25+
# Compiled binary addons (http://nodejs.org/api/addons.html)
26+
build/Release
27+
28+
# Dependency directory
29+
# Commenting this out is preferred by some people, see
30+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
31+
node_modules
32+
33+
34+
### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Global/JetBrains.gitignore
35+
36+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
37+
38+
*.iml
39+
40+
## Directory-based project format:
41+
.idea/
42+
# if you remove the above rule, at least ignore the following:
43+
44+
# User-specific stuff:
45+
# .idea/workspace.xml
46+
# .idea/tasks.xml
47+
# .idea/dictionaries
48+
49+
# Sensitive or high-churn files:
50+
# .idea/dataSources.ids
51+
# .idea/dataSources.xml
52+
# .idea/sqlDataSources.xml
53+
# .idea/dynamic.xml
54+
# .idea/uiDesigner.xml
55+
56+
# Gradle:
57+
# .idea/gradle.xml
58+
# .idea/libraries
59+
60+
# Mongo Explorer plugin:
61+
# .idea/mongoSettings.xml
62+
63+
## File-based project format:
64+
*.ipr
65+
*.iws
66+
67+
## Plugin-specific files:
68+
69+
# IntelliJ
70+
out/
71+
72+
# mpeltonen/sbt-idea plugin
73+
.idea_modules/
74+
75+
# JIRA plugin
76+
atlassian-ide-plugin.xml
77+
78+
# Crashlytics plugin (for Android Studio and IntelliJ)
79+
com_crashlytics_export_strings.xml
80+
crashlytics.properties
81+
crashlytics-build.properties
82+
83+

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sudo: false
2+
language: node_js
3+
node_js: "stable"

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2015 shirayu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# textlint-rule-no-dropping-i [![Build Status](https://travis-ci.org/textlint-ja/textlint-rule-no-dropping-i.svg?branch=master)](https://travis-ci.org/textlint-ja/textlint-rule-no-dropping-i) [![Gitter](https://badges.gitter.im/textlint-ja/textlint-ja.svg)](https://gitter.im/textlint-ja/textlint-ja)
2+
3+
い抜き言葉を検出する[textlint](https://github.com/textlint/textlint "textlint")ルールです。
4+
5+
- ◯ 開発しています。
6+
- ✗ 開発してます。
7+
8+
## Installation
9+
10+
npm install @textlint-ja/textlint-rule-no-dropping-i
11+
12+
textlint >= 5.0
13+
14+
## Usage
15+
16+
Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc`
17+
18+
```js
19+
{
20+
"rules": {
21+
"@textlint-ja/textlint-rule-no-dropping-i": true
22+
}
23+
}
24+
```
25+
26+
## Contributing
27+
28+
1. Fork it!
29+
2. Create your feature branch: `git checkout -b my-new-feature`
30+
3. Commit your changes: `git commit -am 'Add some feature'`
31+
4. Push to the branch: `git push origin my-new-feature`
32+
5. Submit a pull request :D
33+
34+
## License
35+
36+
MIT
37+

package.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"author": "shirayu",
3+
"bugs": {
4+
"url": "https://github.com/textlint-ja/textlint-rule-no-dropping-i/issues"
5+
},
6+
"dependencies": {
7+
"kuromojin": "^1.2.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.0.0"
65+
}

src/no-dropping-i.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// LICENSE : MIT
2+
"use strict";
3+
import { RuleHelper } from "textlint-rule-helper";
4+
import kuromojin from "kuromojin";
5+
6+
function isTargetWord(token) {
7+
return token.pos == "助詞" && token.pos_detail_1 == "接続助詞" && token.basic_form == "て";
8+
}
9+
10+
function isMasuWord(token) {
11+
return token.pos == "助動詞" && token.pos_detail_1 == "*" && token.basic_form == "ます";
12+
}
13+
14+
module.exports = function(context) {
15+
const helper = new RuleHelper(context);
16+
let { Syntax, report, getSource, RuleError } = context;
17+
return {
18+
[Syntax.Str](node) {
19+
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
20+
return;
21+
}
22+
let text = getSource(node);
23+
return kuromojin(text).then(tokens => {
24+
tokens.reduce((prev, current) => {
25+
if (isTargetWord(prev) && isMasuWord(current)) {
26+
report(
27+
node,
28+
new RuleError("い抜き言葉を使用しています。", {
29+
index: current.word_position - 1
30+
})
31+
);
32+
}
33+
return current;
34+
});
35+
});
36+
}
37+
};
38+
};

test/mocha.opts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---require textlint-scripts/register

test/test.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import assert from "power-assert";
2+
import rule from "../src/no-dropping-i";
3+
import TextLintTester from "textlint-tester";
4+
var tester = new TextLintTester();
5+
tester.run("no-dropping-i", rule, {
6+
valid: ["見ています", "開発しています。"],
7+
invalid: [
8+
{
9+
text: "見てます。",
10+
errors: [
11+
{
12+
message: "い抜き言葉を使用しています。",
13+
line: 1,
14+
column: 3
15+
}
16+
]
17+
},
18+
{
19+
text: "開発してます。",
20+
errors: [
21+
{
22+
message: "い抜き言葉を使用しています。",
23+
line: 1,
24+
column: 5
25+
}
26+
]
27+
}
28+
]
29+
});

0 commit comments

Comments
 (0)