Skip to content

Commit 11de382

Browse files
committed
style: apply prettier
1 parent 3dd855f commit 11de382

File tree

22 files changed

+162672
-134584
lines changed

22 files changed

+162672
-134584
lines changed

.githooks/pre-commit

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
npx --no-install lint-staged

.yarn/releases/yarn-1.22.4.js

+162,236-134,181
Large diffs are not rendered by default.

package.json

+17-4
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,32 @@
55
"website"
66
],
77
"devDependencies": {
8-
"lerna": "^7.1.4"
8+
"lerna": "^7.1.4",
9+
"prettier": "^3.2.5"
910
},
1011
"scripts": {
1112
"build": "lerna run build",
1213
"test": "lerna run test",
13-
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
1414
"versionup": "lerna version --conventional-commits",
1515
"versionup:patch": "lerna version patch --conventional-commits",
1616
"versionup:minor": "lerna version minor --conventional-commits",
1717
"versionup:major": "lerna version major --conventional-commits",
18-
"release": "lerna publish from-package"
18+
"release": "lerna publish from-package",
19+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
20+
"prepare": "git config --local core.hooksPath .githooks"
1921
},
2022
"keywords": [
2123
"textlintrule"
22-
]
24+
],
25+
"prettier": {
26+
"singleQuote": false,
27+
"printWidth": 120,
28+
"tabWidth": 4,
29+
"trailingComma": "none"
30+
},
31+
"lint-staged": {
32+
"*.{js,jsx,ts,tsx,css}": [
33+
"prettier --write"
34+
]
35+
}
2336
}

packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,30 @@
44
カタカナ語間のスペースの有無
55
中黒または半角スペースを用いてカタカナ語を区切ります。
66
*/
7-
import {RuleHelper} from "textlint-rule-helper";
8-
import {matchCaptureGroupAll} from "match-index";
9-
module.exports = function(context) {
10-
const {Syntax, RuleError, report, getSource} = context;
7+
import { RuleHelper } from "textlint-rule-helper";
8+
import { matchCaptureGroupAll } from "match-index";
9+
module.exports = function (context) {
10+
const { Syntax, RuleError, report, getSource } = context;
1111
const helper = new RuleHelper();
1212
return {
13-
[Syntax.Str](node){
13+
[Syntax.Str](node) {
1414
if (!helper.isPlainStrNode(node)) {
1515
return;
1616
}
1717
const text = getSource(node);
1818
// カタカナ(カタカナ以外)カタカナ のパターンを取り出す
19-
matchCaptureGroupAll(text, /[-]([^[-])[-]/).forEach(match => {
19+
matchCaptureGroupAll(text, /[-]([^[-])[-]/).forEach((match) => {
2020
// カタカナの間を全角スペースでは区切らない
21-
const {text} = match;
21+
const { text } = match;
2222
if (text === " ") {
23-
report(node, new RuleError("カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります", {
24-
index: match.index
25-
}));
23+
report(
24+
node,
25+
new RuleError("カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります", {
26+
index: match.index
27+
})
28+
);
2629
}
2730
});
28-
2931
}
3032
};
3133
};

packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/test/index-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tester.run("カタカナ語間のスペースの有無", rule, {
77
valid: [
88
"カタカナ・カタカナ",
99
"カタカナ カタカナ",
10-
"カタカナ、カタカナ",// 例外としてしょうがない気がする
10+
"カタカナ、カタカナ", // 例外としてしょうがない気がする
1111
"あいう えお",
1212
"インターフェース ブラウザ"
1313
],

packages/textlint-rule-ja-no-space-around-parentheses/src/index.js

+29-25
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,50 @@
44
かっこ類と隣接する文字の間のスペースの有無
55
かっこの外側、内側ともにスペースを入れません。
66
*/
7-
import {RuleHelper} from "textlint-rule-helper";
8-
import {matchCaptureGroupAll} from "match-index";
7+
import { RuleHelper } from "textlint-rule-helper";
8+
import { matchCaptureGroupAll } from "match-index";
99

10-
const brackets = [
11-
"\\[", "\\]", "(", ")", "[", "]", "「", "」", "『", "』"
12-
];
10+
const brackets = ["\\[", "\\]", "(", ")", "[", "]", "「", "」", "『", "』"];
1311

14-
const leftBrackets = brackets.map(bracket => {
15-
return new RegExp("\([  ]\)" + bracket, "g");
12+
const leftBrackets = brackets.map((bracket) => {
13+
return new RegExp("([  ])" + bracket, "g");
1614
});
17-
const rightBrackets = brackets.map(bracket => {
18-
return new RegExp(bracket + "\([  ])", "g");
15+
const rightBrackets = brackets.map((bracket) => {
16+
return new RegExp(bracket + "([  ])", "g");
1917
});
2018
function reporter(context) {
21-
const {Syntax, RuleError, report, fixer, getSource} = context;
19+
const { Syntax, RuleError, report, fixer, getSource } = context;
2220
const helper = new RuleHelper();
2321
return {
24-
[Syntax.Str](node){
22+
[Syntax.Str](node) {
2523
if (!helper.isPlainStrNode(node)) {
2624
return;
2725
}
2826
const text = getSource(node);
2927
// 左にスペース
30-
leftBrackets.forEach(pattern => {
31-
matchCaptureGroupAll(text, pattern).forEach(match => {
32-
const {index} = match;
33-
report(node, new RuleError("かっこの外側、内側ともにスペースを入れません。", {
34-
index: index,
35-
fix: fixer.replaceTextRange([index, index + 1], "")
36-
}));
28+
leftBrackets.forEach((pattern) => {
29+
matchCaptureGroupAll(text, pattern).forEach((match) => {
30+
const { index } = match;
31+
report(
32+
node,
33+
new RuleError("かっこの外側、内側ともにスペースを入れません。", {
34+
index: index,
35+
fix: fixer.replaceTextRange([index, index + 1], "")
36+
})
37+
);
3738
});
3839
});
3940
// 右にスペース
40-
rightBrackets.forEach(pattern => {
41-
matchCaptureGroupAll(text, pattern).forEach(match => {
42-
const {index, text} = match;
43-
report(node, new RuleError("かっこの外側、内側ともにスペースを入れません。", {
44-
index: index,
45-
fix: fixer.replaceTextRange([index, index + 1], "")
46-
}));
41+
rightBrackets.forEach((pattern) => {
42+
matchCaptureGroupAll(text, pattern).forEach((match) => {
43+
const { index, text } = match;
44+
report(
45+
node,
46+
new RuleError("かっこの外側、内側ともにスペースを入れません。", {
47+
index: index,
48+
fix: fixer.replaceTextRange([index, index + 1], "")
49+
})
50+
);
4751
});
4852
});
4953
}

packages/textlint-rule-ja-no-space-around-parentheses/test/index-test.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@ tester.run("かっこ類と隣接する文字の間のスペースの有無", ru
1414
というルールがあるだけとも言えます。
1515
`,
1616
"[テスト 「文章」 です](https://example)", // ignore Link
17-
"[テスト 「文章」 です][]" +
18-
"\n\n" +
19-
"[テスト 「文章」 です]: https://example.com" // ignore ReferenceDef
17+
"[テスト 「文章」 です][]" + "\n\n" + "[テスト 「文章」 です]: https://example.com" // ignore ReferenceDef
2018
],
2119
invalid: [
2220
{
2321
text: "「 ダメ」",
2422
output: "「ダメ」",
25-
errors: [
26-
{message: "かっこの外側、内側ともにスペースを入れません。"}
27-
]
23+
errors: [{ message: "かっこの外側、内側ともにスペースを入れません。" }]
2824
},
2925
{
3026
text: "これは 「ダメ」です",
@@ -36,7 +32,8 @@ tester.run("かっこ類と隣接する文字の間のスペースの有無", ru
3632
column: 4
3733
}
3834
]
39-
}, {
35+
},
36+
{
4037
text: `TEST
4138
4239
- TODO

packages/textlint-rule-ja-no-space-between-full-width/src/index.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,40 @@
55
全角文字どうしの間にスペースを入れません。
66
ただしカタカナ複合語の場合を除きます。
77
*/
8-
import {RuleHelper} from "textlint-rule-helper";
9-
import {matchAll} from "match-index";
8+
import { RuleHelper } from "textlint-rule-helper";
9+
import { matchAll } from "match-index";
1010
import regx from "regx";
1111
const rx = regx("g");
12-
const japaneseRegExp = /(?:[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[--])/;
12+
const japaneseRegExp =
13+
/(?:[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[--])/;
1314

1415
function reporter(context) {
15-
const {Syntax, RuleError, report, fixer, getSource} = context;
16+
const { Syntax, RuleError, report, fixer, getSource } = context;
1617
const helper = new RuleHelper();
1718
return {
18-
[Syntax.Str](node){
19+
[Syntax.Str](node) {
1920
if (!helper.isPlainStrNode(node)) {
2021
return;
2122
}
2223
const text = getSource(node);
2324
// 全角同士の間は半角スペースを入れない
2425
const matchReg = rx`${japaneseRegExp}( )${japaneseRegExp}`;
2526
const katakakana = /[-]( )[-]/;
26-
matchAll(text, matchReg).forEach(match => {
27-
const {input, captureGroups} = match;
27+
matchAll(text, matchReg).forEach((match) => {
28+
const { input, captureGroups } = match;
2829
// ただしカタカナ複合語の場合を除きます。
2930
if (katakakana.test(input)) {
3031
return;
3132
}
32-
captureGroups.forEach(captureGroup => {
33+
captureGroups.forEach((captureGroup) => {
3334
const index = captureGroup.index;
34-
report(node, new RuleError("原則として、全角文字どうしの間にスペースを入れません。", {
35-
index: index,
36-
fix: fixer.replaceTextRange([index, index + 1], "")
37-
}));
35+
report(
36+
node,
37+
new RuleError("原則として、全角文字どうしの間にスペースを入れません。", {
38+
index: index,
39+
fix: fixer.replaceTextRange([index, index + 1], "")
40+
})
41+
);
3842
});
3943
});
4044
}

packages/textlint-rule-ja-no-space-between-full-width/test/index-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tester.run("全角文字どうし", rule, {
88
"これは正解",
99
"This is 大丈夫",
1010
"This is a pen.",
11-
"ユーザー インターフェース"//カタカナは例外
11+
"ユーザー インターフェース" //カタカナは例外
1212
],
1313
invalid: [
1414
{

packages/textlint-rule-ja-space-after-exclamation/src/index.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
文末に感嘆符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。
66
文中に感嘆符を使用する場合はスペースを挿入しません。
77
*/
8-
import {RuleHelper} from "textlint-rule-helper";
9-
import {matchCaptureGroupAll} from "match-index";
8+
import { RuleHelper } from "textlint-rule-helper";
9+
import { matchCaptureGroupAll } from "match-index";
1010
function reporter(context) {
11-
const {Syntax, RuleError, report, fixer, getSource} = context;
11+
const { Syntax, RuleError, report, fixer, getSource } = context;
1212
const helper = new RuleHelper();
1313
return {
14-
[Syntax.Str](node){
14+
[Syntax.Str](node) {
1515
if (!helper.isPlainStrNode(node)) {
1616
return;
1717
}
1818
let text = getSource(node);
1919
// !の後ろは全角スペースが推奨
2020
// 半角スペースである場合
2121
const matchAfter = /( )[^\n]/;
22-
matchCaptureGroupAll(text, matchAfter).forEach(match => {
23-
const {index} = match;
24-
return report(node, new RuleError("文末に感嘆符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。", {
25-
index: index,
26-
fix: fixer.replaceTextRange([index, index + 1], " ")
27-
}));
22+
matchCaptureGroupAll(text, matchAfter).forEach((match) => {
23+
const { index } = match;
24+
return report(
25+
node,
26+
new RuleError("文末に感嘆符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。", {
27+
index: index,
28+
fix: fixer.replaceTextRange([index, index + 1], " ")
29+
})
30+
);
2831
});
2932
}
3033
};

packages/textlint-rule-ja-space-after-exclamation/test/index-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tester.run("感嘆符(!)", rule, {
88
"【原文】Just plug it in, and coffee is ready in three minutes!",
99
"【訳文】プラグを差し込めば、3 分でコーヒーができます。",
1010
"警告!",
11-
"驚きの速さ! これが新製品のキャッチコピーでした。"// 文末感嘆符+全角スペース
11+
"驚きの速さ! これが新製品のキャッチコピーでした。" // 文末感嘆符+全角スペース
1212
],
1313
invalid: [
1414
{

packages/textlint-rule-ja-space-after-question/src/index.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
文末に疑問符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。
66
文中に疑問符を使用する場合はスペースを挿入しません。
77
*/
8-
import {RuleHelper} from "textlint-rule-helper";
9-
import {matchCaptureGroupAll} from "match-index";
8+
import { RuleHelper } from "textlint-rule-helper";
9+
import { matchCaptureGroupAll } from "match-index";
1010
function reporter(context) {
11-
const {Syntax, RuleError, report, fixer, getSource} = context;
11+
const { Syntax, RuleError, report, fixer, getSource } = context;
1212
const helper = new RuleHelper();
1313
return {
14-
[Syntax.Str](node){
14+
[Syntax.Str](node) {
1515
if (!helper.isPlainStrNode(node)) {
1616
return;
1717
}
1818
let text = getSource(node);
1919
// ?の後ろは全角スペースが推奨
2020
// 半角スペースである場合はエラーとする
2121
const matchAfter = /( )[^\n]/;
22-
matchCaptureGroupAll(text, matchAfter).forEach(match => {
23-
const {index} = match;
24-
return report(node, new RuleError("文末に疑問符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。", {
25-
index: index,
26-
fix: fixer.replaceTextRange([index, index + 1], " ")
27-
}));
22+
matchCaptureGroupAll(text, matchAfter).forEach((match) => {
23+
const { index } = match;
24+
return report(
25+
node,
26+
new RuleError("文末に疑問符を使用し、後に別の文が続く場合は、直後に全角スペースを挿入します。", {
27+
index: index,
28+
fix: fixer.replaceTextRange([index, index + 1], " ")
29+
})
30+
);
2831
});
2932
}
3033
};

packages/textlint-rule-ja-space-after-question/test/index-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tester.run("疑問符(?)", rule, {
1717
"> どう操作したらよいのか?という",
1818
"**どう操作したらよいのか?という**",
1919
"[どう操作したらよいのか?という][]",
20-
"[^どう操作したらよいのか?という]",
20+
"[^どう操作したらよいのか?という]"
2121
],
2222
invalid: [
2323
{

0 commit comments

Comments
 (0)