@cffnpwr/textlint-rule-nominal-list-item 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +136 -28
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +691 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +691 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cffnpwr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,153 @@
|
|
|
1
1
|
# @cffnpwr/textlint-rule-nominal-list-item
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/@cffnpwr/textlint-rule-nominal-list-item)
|
|
5
|
+
[](https://jsr.io/@cffnpwr/textlint-rule-nominal-list-item)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
A textlint rule that detects list items that do not end with a noun (体言止め).
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
[日本語のREADMEはこちら](./README-ja.md)
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
When the endings of list items differ from item to item, as in 「〜する」, 「〜します」, and
|
|
12
|
+
「〜です」, the items become harder to compare with one another. This rule classifies the end of each
|
|
13
|
+
item via morphological analysis (kuromoji) and reports items that end with a verb, an adjective, or
|
|
14
|
+
an auxiliary verb. Ordered lists are also inspected.
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
```markdown
|
|
17
|
+
<!-- NG -->
|
|
18
|
+
1. リポジトリをクローンします
|
|
19
|
+
2. 値を検証する
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
- 設定ファイルがない
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
<!-- OK -->
|
|
24
|
+
1. リポジトリのクローン
|
|
25
|
+
2. 値の検証
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
- 設定ファイルの不在
|
|
28
|
+
- `InvalidFormatError`: 書式が不正な場合
|
|
29
|
+
- 対応するOS: macOS
|
|
30
|
+
```
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
The rule inspects the end of the first paragraph directly under each list item. Items of nested
|
|
33
|
+
lists are inspected individually. After trailing whitespace, punctuation, and symbols (the full
|
|
34
|
+
stop, closing brackets, a colon, and so on) are removed, the last token is reported when it is a
|
|
35
|
+
verb, an adjective, or an auxiliary verb. At most one error is reported per item.
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
37
|
+
The following items are not reported.
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
- Items that end with a noun (including dependent nouns such as 「場合」, 「とき」, 「こと」, and
|
|
40
|
+
「もの」)
|
|
41
|
+
- Items that end with the continuative form of a verb (「値を読み込み」)
|
|
42
|
+
- Items that end with 「なし」 (「制限なし」)
|
|
43
|
+
- Items that end with inline code, a link, or an image (including when only symbols follow it)
|
|
44
|
+
- Items that end with a part of speech other than a verb, an adjective, or an auxiliary verb, such
|
|
45
|
+
as a particle or an adverb
|
|
30
46
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
Nominalized continuative forms such as 「読み込み」 and 「切り替え」 are analyzed as a noun in some
|
|
48
|
+
cases and as the continuative form of a verb in others. Because the two cannot be told apart, items
|
|
49
|
+
that end with the continuative form of a verb are treated as ending with a noun. 「なし」 is
|
|
50
|
+
analyzed as the classical dictionary form of an adjective, but it is treated as ending with a noun
|
|
51
|
+
because the word is used as a noun.
|
|
36
52
|
|
|
37
|
-
##
|
|
53
|
+
## How to Install
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
55
|
+
### npm
|
|
42
56
|
|
|
43
|
-
|
|
57
|
+
```sh
|
|
58
|
+
npm install --save-dev @cffnpwr/textlint-rule-nominal-list-item
|
|
59
|
+
```
|
|
44
60
|
|
|
45
|
-
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npx jsr add -D @cffnpwr/textlint-rule-nominal-list-item
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### yarn
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
yarn add --dev @cffnpwr/textlint-rule-nominal-list-item
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
or
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
yarn dlx jsr add -D @cffnpwr/textlint-rule-nominal-list-item
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### pnpm
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
pnpm add --save-dev @cffnpwr/textlint-rule-nominal-list-item
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
or
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
pnpm dlx jsr add -D @cffnpwr/textlint-rule-nominal-list-item
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Bun
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
bun add --dev @cffnpwr/textlint-rule-nominal-list-item
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
or
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
bunx jsr add -D @cffnpwr/textlint-rule-nominal-list-item
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Deno
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
deno add --dev npm:@cffnpwr/textlint-rule-nominal-list-item
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
or
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
deno add --dev jsr:@cffnpwr/textlint-rule-nominal-list-item
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## How to Use
|
|
116
|
+
|
|
117
|
+
Add it to `.textlintrc.json`.
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"rules": {
|
|
122
|
+
"@cffnpwr/textlint-rule-nominal-list-item": true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Options
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
interface Options {
|
|
131
|
+
skipBlockQuote?: boolean;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
| Option | Default | Description |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| `skipBlockQuote` | `true` | Excludes content under quotes (BlockQuote) from inspection |
|
|
138
|
+
|
|
139
|
+
Specifying an unknown option key or an invalid value results in an error.
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"rules": {
|
|
144
|
+
"@cffnpwr/textlint-rule-nominal-list-item": {
|
|
145
|
+
"skipBlockQuote": false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
[MIT](./LICENSE)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("@cffnpwr/textlint-rule-preset-ja-writing-extras-shared"),t=require("arktype"),n=require("kuromojin");const r=(0,t.type)({"+":`reject`,"skipBlockQuote?":`boolean`,"severity?":`unknown`}),i=/[\s\p{P}\p{S}]+$/u,a=/^[\s\p{P}\p{S}]*$/u,o=/* @__PURE__ */ new Set([`Code`,`Link`,`LinkReference`,`Image`,`ImageReference`,`Html`]),s=/* @__PURE__ */ new Set([`動詞`,`形容詞`,`助動詞`]),c=e=>{if(!(`children`in e))return!1;let t=e.children.findLast(e=>!(e.type===`Str`&&a.test(e.value)));return t===void 0?!1:o.has(t.type)||c(t)},l=(e,t)=>e===`動詞`&&t===`連用形`||e===`形容詞`&&t===`文語基本形`,u=(t,a={})=>{(0,e.validateOptions)(r,a);let{Syntax:o,RuleError:u,report:d,locator:f,getSource:p}=t,m=a.skipBlockQuote??!0,h=(0,e.createBlockQuoteDepth)(),g=async t=>{if(c(t))return;let r=(0,e.toMaskedStringSource)(t),a=r.toString().replace(i,``);if(a.length===0)return;let o=(await(0,n.tokenize)(a)).at(-1);if(o===void 0||!s.has(o.pos)||l(o.pos,o.conjugated_form))return;let m=o.surface_form,h=r.originalIndexFromIndex(a.length-m.length),g=r.originalIndexFromIndex(a.length-1);if(!a.endsWith(m)||h===void 0||g===void 0)return;let _=p(t).indexOf(m,h),[v,y]=_===-1?[h,g+1]:[_,_+m.length];d(t,new u(`箇条書きの項目が${o.pos}「${m}」で終わっています。「値を検証する」ではなく「値の検証」のように、体言止めで書いてください。`,{padding:f.range([v,y])}))};return{[o.BlockQuote]:h.enter,[o.BlockQuoteExit]:h.exit,async[o.ListItem](e){if(m&&h.isInside())return;let t=e.children.find(e=>e.type===o.Paragraph);t!==void 0&&await g(t)}}};module.exports=u;
|