Skip to content

Commit 9f2e9c5

Browse files
committedMay 24, 2021
fix: Strがユーザーに書かれたものをかの判定に
1 parent 82a4eb4 commit 9f2e9c5

File tree

9 files changed

+1233
-954
lines changed

9 files changed

+1233
-954
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+
}

‎example/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
`npm run-script textlint`が定義されているので次のようにすれば、この`README.md`ファイルをtextlint出来ます。
66

7+
これは問題です。
8+
9+
10+
711
```
812
npm install
913
npm run textlint -- README.md

‎example/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"scripts": {
88
"textlint": "textlint",
99
"textlint:fix": "textlint --fix ../README.md",
10-
"test": "npm run textlint -- -f pretty-error ../README.md",
10+
"test": "npm run textlint -- -f pretty-error ./README.md",
1111
"website": "textlint-website-generator --output-dir dist"
1212
},
1313
"author": "azu",
1414
"license": "MIT",
1515
"devDependencies": {
1616
"@textlint/website-generator": "^0.11.3",
17-
"textlint": "^11.4.0"
17+
"textlint": "^12.0.0-beta.2"
1818
},
1919
"dependencies": {
2020
"textlint-rule-preset-jtf-style": "file:.."
2121
}
22-
}
22+
}

‎example/yarn.lock

+424-232
Large diffs are not rendered by default.

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
"devDependencies": {
4242
"glob": "^7.1.4",
4343
"lint-staged": "^11.0.0",
44-
"prettier": "^2.2.1",
45-
"textlint-scripts": "^3.0.0"
44+
"prettier": "^2.3.0",
45+
"textlint-scripts": "^12.0.1",
46+
"textlint-tester": "^12.0.0"
4647
},
4748
"dependencies": {
4849
"analyze-desumasu-dearu": "^2.1.2",

‎src/util/node-util.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// LICENSE : MIT
22
"use strict";
33
import { RuleHelper } from "textlint-rule-helper";
4+
45
/**
56
* ユーザーが書いたと推測されるNodeかどうかを判定する
67
* ユーザーが管理できないテキストは対象外としたいため。
@@ -11,5 +12,11 @@ import { RuleHelper } from "textlint-rule-helper";
1112
export function isUserWrittenNode(node, context) {
1213
let helper = new RuleHelper(context);
1314
let Syntax = context.Syntax;
15+
// Strがユーザーに書かれたと断定できるNodeかを判定する
16+
// LinkやStrongなどはユーザーが書いていない可能性があるStrなので除外する
17+
if (node.type === Syntax.Str) {
18+
return helper.isPlainStrNode(node);
19+
}
20+
// ブロック要素の互換性のため古い除外ルールも残す
1421
return !helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis]);
1522
}

‎test/2.1.8-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tester.run("2.1.8.算用数字", rule, {
77
valid: [
88
"1,000円",
99
"100 + 100 = 200",
10-
"_200_円" // Strではない
10+
"*200*円" // Strではない
1111
],
1212
invalid: [
1313
{

‎test/mocha.opts

-1
This file was deleted.

‎yarn.lock

+786-715
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.