@textlint-ja/textlint-rule-no-dropping-i
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -8,10 +8,8 @@ // LICENSE : MIT | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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 === "ます"; | ||
} | ||
@@ -21,25 +19,30 @@ | ||
var helper = new _textlintRuleHelper.RuleHelper(context); | ||
var Syntax = context.Syntax, | ||
report = context.report, | ||
getSource = context.getSource, | ||
RuleError = context.RuleError; | ||
return _defineProperty({}, Syntax.Str, function (node) { | ||
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) { | ||
return; | ||
} | ||
var { | ||
Syntax, | ||
report, | ||
getSource, | ||
RuleError | ||
} = context; | ||
return { | ||
[Syntax.Str](node) { | ||
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) { | ||
return; | ||
} | ||
var text = getSource(node); | ||
return (0, _kuromojin.tokenize)(text).then(function (tokens) { | ||
tokens.reduce(function (prev, current) { | ||
if (isTargetWord(prev) && isMasuWord(current)) { | ||
report(node, new RuleError("い抜き言葉を使用しています。", { | ||
index: current.word_position - 1 | ||
})); | ||
} | ||
var text = getSource(node); | ||
return (0, _kuromojin.tokenize)(text).then(tokens => { | ||
tokens.reduce((prev, current) => { | ||
if (isTargetWord(prev) && isMasuWord(current)) { | ||
report(node, new RuleError("い抜き言葉を使用しています。", { | ||
index: current.word_position - 1 | ||
})); | ||
} | ||
return current; | ||
return current; | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
}; | ||
//# sourceMappingURL=no-dropping-i.js.map |
123
package.json
{ | ||
"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": "2.0.0" | ||
} |
@@ -12,7 +12,5 @@ # textlint-rule-no-dropping-i [](https://github.com/textlint-ja/textlint-rule-no-dropping-i/actions?query=workflow%3A"test") | ||
textlint >= 5.0 | ||
## Usage | ||
Put "@textlint-ja/textlint-rule-no-dropping-i" to `.textlintrc` | ||
Put `@textlint-ja/textlint-rule-no-dropping-i` to `.textlintrc` | ||
@@ -27,2 +25,7 @@ ```js | ||
## 参考 | ||
- [い抜き言葉](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 | ||
@@ -29,0 +32,0 @@ |
@@ -7,7 +7,7 @@ // LICENSE : MIT | ||
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 === "ます"; | ||
} | ||
@@ -17,3 +17,3 @@ | ||
const helper = new RuleHelper(context); | ||
let { Syntax, report, getSource, RuleError } = context; | ||
const { Syntax, report, getSource, RuleError } = context; | ||
return { | ||
@@ -24,3 +24,3 @@ [Syntax.Str](node) { | ||
} | ||
let text = getSource(node); | ||
const text = getSource(node); | ||
return tokenize(text).then(tokens => { | ||
@@ -27,0 +27,0 @@ tokens.reduce((prev, current) => { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2
72
41
0
9099
+ Added@textlint/ast-node-types@13.4.1(transitive)
+ Added@types/unist@2.0.11(transitive)
+ Addedboundary@2.0.0(transitive)
+ Addedkuromoji@0.1.2(transitive)
+ Addedkuromojin@3.0.0(transitive)
+ Addedlru_map@0.4.1(transitive)
+ Addedstructured-source@4.0.0(transitive)
+ Addedtextlint-rule-helper@2.3.1(transitive)
+ Addedunist-util-is@4.1.0(transitive)
+ Addedunist-util-visit@2.0.3(transitive)
+ Addedunist-util-visit-parents@3.1.1(transitive)
+ Addedzlibjs@0.3.1(transitive)
- Removedkuromoji@0.1.1(transitive)
- Removedkuromojin@2.1.1(transitive)
- Removedtextlint-rule-helper@1.2.0(transitive)
- Removedunist-util-is@3.0.0(transitive)
- Removedunist-util-visit@1.4.1(transitive)
- Removedunist-util-visit-parents@2.1.2(transitive)
- Removedzlibjs@0.2.0(transitive)
Updatedkuromojin@^3.0.0
Updatedtextlint-rule-helper@^2.1.1