Skip to content

Commit f150588

Browse files
committed
style: apply prettier
1 parent 5d6b738 commit f150588

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1607
-1759
lines changed

.githooks/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
npx --no-install lint-staged

package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"pretest": "node tool/create-fixtures.js",
3030
"test": "textlint-scripts test && npm run test:textlint",
3131
"test:textlint": "(cd example && npm i --no-save && npm test)",
32-
"prettier": "prettier --write '**/*.{js,jsx,ts,tsx,css}'"
32+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
33+
"prepare": "git config --local core.hooksPath .githooks"
3334
},
3435
"keywords": [
3536
"textlint",
@@ -39,9 +40,8 @@
3940
],
4041
"devDependencies": {
4142
"glob": "^7.1.4",
42-
"husky": "^3.0.9",
43-
"lint-staged": "^9.4.2",
44-
"prettier": "^1.18.2",
43+
"lint-staged": "^11.0.0",
44+
"prettier": "^2.2.1",
4545
"textlint-scripts": "^3.0.0"
4646
},
4747
"dependencies": {
@@ -59,19 +59,14 @@
5959
"textlint": ">= 5.6.0"
6060
},
6161
"prettier": {
62+
"singleQuote": false,
6263
"printWidth": 120,
63-
"tabWidth": 4
64+
"tabWidth": 4,
65+
"trailingComma": "none"
6466
},
6567
"lint-staged": {
6668
"*.{js,jsx,ts,tsx,css}": [
67-
"prettier --write",
68-
"git add"
69+
"prettier --write"
6970
]
70-
},
71-
"husky": {
72-
"hooks": {
73-
"post-commit": "git reset",
74-
"pre-commit": "lint-staged"
75-
}
7671
}
7772
}

src/1.1.1.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@
1717
*/
1818
import { analyzeDesumasu, analyzeDearu } from "analyze-desumasu-dearu";
1919
import { RuleHelper } from "textlint-rule-helper";
20-
module.exports = function(context) {
20+
module.exports = function (context) {
2121
let { Syntax, RuleError, report, getSource } = context;
2222
let helper = new RuleHelper(context);
2323
let desumasuList = [];
2424
let dearuList = [];
2525

2626
function reportResult(list, { desumasu, dearu }) {
2727
list.forEach(({ node, matches }) => {
28-
matches.forEach(match => {
28+
matches.forEach((match) => {
2929
let message;
3030
if (desumasu) {
31-
message = `本文を常体(である調)に統一して下さい。\n本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。\n"${
32-
match.value
33-
}"が敬体(ですます調)です。`;
31+
message = `本文を常体(である調)に統一して下さい。\n本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。\n"${match.value}"が敬体(ですます調)です。`;
3432
} else if (dearu) {
35-
message = `本文を敬体(ですます調)に統一して下さい。\n本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。\n"${
36-
match.value
37-
}"が常体(である調)です。`;
33+
message = `本文を敬体(ですます調)に統一して下さい。\n本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。\n"${match.value}"が常体(である調)です。`;
3834
}
3935
report(
4036
node,

src/1.1.3.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
いずれの場合も、ひとまとまりの箇条書きでは、敬体と常体を混在させません。文末に句点(。)を付けるかどうかも統一します。
1111
*/
1212
import { analyzeDesumasu, analyzeDearu } from "analyze-desumasu-dearu";
13-
module.exports = function(context) {
13+
module.exports = function (context) {
1414
let { Syntax, RuleError, report, getSource } = context;
1515
let desumasuList = [];
1616
let dearuList = [];
@@ -27,7 +27,7 @@ module.exports = function(context) {
2727
}
2828

2929
function reportPointResult(nodeList, { shouldUsePoint }) {
30-
nodeList.forEach(node => {
30+
nodeList.forEach((node) => {
3131
let message;
3232
if (shouldUsePoint) {
3333
message = `箇条書きの文末に句点(。)を付けて下さい。\n箇条書きの文末に句点(。)を付けるかを統一します。`;
@@ -40,16 +40,12 @@ module.exports = function(context) {
4040

4141
function reportDesumaruDearuResult(list, { desumasu, dearu }) {
4242
list.forEach(({ node, matches }) => {
43-
matches.forEach(match => {
43+
matches.forEach((match) => {
4444
let message;
4545
if (desumasu) {
46-
message = `箇条書きを敬体(ですます調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${
47-
match.value
48-
}"が常体(である調)です。`;
46+
message = `箇条書きを敬体(ですます調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${match.value}"が常体(である調)です。`;
4947
} else if (dearu) {
50-
message = `箇条書きを常体(である調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${
51-
match.value
52-
}"が敬体(ですます調)です。`;
48+
message = `箇条書きを常体(である調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${match.value}"が敬体(ですます調)です。`;
5349
}
5450
report(
5551
node,

src/1.1.5.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
キャプション間で文体が混ざっていないことを確認する。
1010
*/
1111
import { analyzeDesumasu, analyzeDearu } from "analyze-desumasu-dearu";
12-
module.exports = function(context) {
12+
module.exports = function (context) {
1313
let { Syntax, RuleError, report, getSource } = context;
1414
let desumasuList = [];
1515
let dearuList = [];
@@ -22,16 +22,12 @@ module.exports = function(context) {
2222
const imagePaddingLet = 2; // ![ の分paddingを付ける
2323
function reportResult(list, { desumasu, dearu }) {
2424
list.forEach(({ node, matches }) => {
25-
matches.forEach(match => {
25+
matches.forEach((match) => {
2626
let message;
2727
if (desumasu) {
28-
message = `図表のキャプションを敬体(ですます調)に統一して下さい。\n図表のキャプション内で敬体、常体を混在させないことが重要です。\n"${
29-
match.value
30-
}"が常体(である調)です。`;
28+
message = `図表のキャプションを敬体(ですます調)に統一して下さい。\n図表のキャプション内で敬体、常体を混在させないことが重要です。\n"${match.value}"が常体(である調)です。`;
3129
} else if (dearu) {
32-
message = `図表のキャプションを常体(である調)に統一して下さい。\n図表のキャプション内で敬体、常体を混在させないことが重要です。\n"${
33-
match.value
34-
}"が敬体(ですます調)です。`;
30+
message = `図表のキャプションを常体(である調)に統一して下さい。\n図表のキャプション内で敬体、常体を混在させないことが重要です。\n"${match.value}"が敬体(ですます調)です。`;
3531
}
3632
report(
3733
node,

src/1.2.1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const replaceSymbol = {
2828
",": "、"
2929
};
3030

31-
const reporter = context => {
31+
const reporter = (context) => {
3232
let { Syntax, RuleError, report, fixer, getSource } = context;
3333
return {
3434
[Syntax.Str](node) {
@@ -39,7 +39,7 @@ const reporter = context => {
3939
const leftMatches = matchCaptureGroupAll(text, leftTarget);
4040
const rightMatches = matchCaptureGroupAll(text, rightTarget);
4141
const matches = mergeMatches(leftMatches, rightMatches);
42-
matches.forEach(match => {
42+
matches.forEach((match) => {
4343
const symbol = replaceSymbol[match.text];
4444
const indexOfSymbol = match.index;
4545
report(

src/2.1.10.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function reporter(context) {
2424
// この段階では 10,000 も含まれている
2525
// ^0,xxx をだけを取り出す
2626
let matchedString = match[0];
27-
matchCaptureGroupAll(matchedString, strictMatchReg).forEach(subMatch => {
27+
matchCaptureGroupAll(matchedString, strictMatchReg).forEach((subMatch) => {
2828
const { index } = subMatch;
2929
report(
3030
node,

src/2.1.2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function stringToArray(value) {
1313
return value.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
1414
}
1515

16-
module.exports = function(context) {
16+
module.exports = function (context) {
1717
let { Syntax, RuleError, report, getSource } = context;
1818
return {
1919
[Syntax.Str](node) {

src/2.1.5.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import moji from "moji";
2121
* @param {String} str 変換したい文字列
2222
*/
2323
function toZenkaku(string) {
24-
return moji(string)
25-
.convert("HK", "ZK")
26-
.toString();
24+
return moji(string).convert("HK", "ZK").toString();
2725
}
2826

2927
function reporter(context) {
@@ -34,14 +32,14 @@ function reporter(context) {
3432
});
3533
let originalStrRule = dictRule[Syntax.Str];
3634
// 半角カタカナの使用をチェックする
37-
dictRule[Syntax.Str] = function(node) {
35+
dictRule[Syntax.Str] = function (node) {
3836
originalStrRule(node);
3937
if (!isUserWrittenNode(node, context)) {
4038
return;
4139
}
4240
const text = getSource(node);
4341
const matches = matchCaptureGroupAll(text, /([\uFF65-\uFF9F]+)/g);
44-
matches.forEach(match => {
42+
matches.forEach((match) => {
4543
const { index, text } = match;
4644
report(
4745
node,

src/2.1.6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import fs from "fs";
1010
import path from "path";
1111
import prh from "textlint-rule-prh";
1212

13-
module.exports = function(context) {
13+
module.exports = function (context) {
1414
// 辞書ベースのカタカナ末尾の長音のチェックを行う
1515
return prh.fixer(context, {
1616
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.1.6.yml"), "utf-8")]

0 commit comments

Comments
 (0)