textlint-filter-rule-footnote 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/README.md +52 -0
- package/index.js +19 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# textlint-filter-rule-footnote
|
|
2
|
+
|
|
3
|
+
A textlint filter rule that ignores errors in footnotes.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install with [npm](https://www.npmjs.com/):
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install textlint-filter-rule-footnote
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Via `.textlintrc`(Recommended):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"filters": {
|
|
20
|
+
"footnote": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Options
|
|
26
|
+
|
|
27
|
+
* `ruleId`: String | String[]
|
|
28
|
+
* Target rule ID to ignore in footnotes.
|
|
29
|
+
* Default: `"ja-technical-writing/no-mix-dearu-desumasu"`
|
|
30
|
+
|
|
31
|
+
If you want to ignore other rules in footnotes, you can set `ruleId` option.
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"filters": {
|
|
36
|
+
"footnote": {
|
|
37
|
+
"ruleId": "textlint-rule-no-doubled-joshi"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Practical Use Case
|
|
44
|
+
|
|
45
|
+
In Japanese technical writing, it is common to use "Dearu" style (da/de-aru) for the main text and "Desumasu" style (desu/masu) for footnotes.
|
|
46
|
+
However, `textlint-rule-no-mix-dearu-desumasu` (included in `textlint-rule-preset-ja-technical-writing`) reports errors for mixed styles.
|
|
47
|
+
|
|
48
|
+
This filter rule automatically ignores `no-mix-dearu-desumasu` errors within footnotes, allowing you to mix styles appropriately without manual `<!-- textlint-disable -->` comments.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = (context, options) => {
|
|
3
|
+
const { shouldIgnore, Syntax } = context;
|
|
4
|
+
// Default: ignore no-mix-dearu-desumasu in footnotes
|
|
5
|
+
const targetRuleIds = Array.isArray(options.ruleId)
|
|
6
|
+
? options.ruleId
|
|
7
|
+
: [options.ruleId || 'ja-technical-writing/no-mix-dearu-desumasu'];
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
[Syntax.FootnoteDefinition](node) {
|
|
11
|
+
// Ignore the target rules in the range of the footnote definition
|
|
12
|
+
for (const ruleId of targetRuleIds) {
|
|
13
|
+
shouldIgnore(node.range, {
|
|
14
|
+
ruleId: ruleId,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "textlint-filter-rule-footnote",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "textlint filter rule that ignores errors in footnotes",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "mocha test/**/*.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"textlint",
|
|
11
|
+
"textlint-rule",
|
|
12
|
+
"textlint-filter-rule",
|
|
13
|
+
"footnote"
|
|
14
|
+
],
|
|
15
|
+
"files": [
|
|
16
|
+
"index.js",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@textlint/kernel": "^15.5.1",
|
|
23
|
+
"@textlint/textlint-plugin-markdown": "^15.5.1",
|
|
24
|
+
"mocha": "^10.0.0",
|
|
25
|
+
"textlint": "^13.0.0",
|
|
26
|
+
"textlint-rule-no-mix-dearu-desumasu": "^6.0.4",
|
|
27
|
+
"textlint-rule-no-todo": "^2.0.1",
|
|
28
|
+
"textlint-tester": "^13.0.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"textlint": ">=13.0.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {}
|
|
34
|
+
}
|