latexlint 0.0.0-stage → 2.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.
Files changed (73) hide show
  1. package/CLI.md +146 -0
  2. package/CLI_ja.md +137 -0
  3. package/LICENSE +21 -0
  4. package/README.md +809 -3
  5. package/dist/browser-types/LL/LLAlignAnd.d.ts +3 -0
  6. package/dist/browser-types/LL/LLAlignEnd.d.ts +3 -0
  7. package/dist/browser-types/LL/LLAlignSingleLine.d.ts +3 -0
  8. package/dist/browser-types/LL/LLArticle.d.ts +3 -0
  9. package/dist/browser-types/LL/LLBig.d.ts +3 -0
  10. package/dist/browser-types/LL/LLBracketCurly.d.ts +3 -0
  11. package/dist/browser-types/LL/LLBracketMissing.d.ts +3 -0
  12. package/dist/browser-types/LL/LLBracketRound.d.ts +3 -0
  13. package/dist/browser-types/LL/LLColonEqq.d.ts +3 -0
  14. package/dist/browser-types/LL/LLColonForMapping.d.ts +3 -0
  15. package/dist/browser-types/LL/LLCref.d.ts +3 -0
  16. package/dist/browser-types/LL/LLDots.d.ts +3 -0
  17. package/dist/browser-types/LL/LLDoubleQuotes.d.ts +3 -0
  18. package/dist/browser-types/LL/LLENDash.d.ts +3 -0
  19. package/dist/browser-types/LL/LLEqnarray.d.ts +3 -0
  20. package/dist/browser-types/LL/LLErrCompOps.d.ts +3 -0
  21. package/dist/browser-types/LL/LLFootnote.d.ts +3 -0
  22. package/dist/browser-types/LL/LLHeading.d.ts +3 -0
  23. package/dist/browser-types/LL/LLLlGg.d.ts +3 -0
  24. package/dist/browser-types/LL/LLMathPunctuation.d.ts +3 -0
  25. package/dist/browser-types/LL/LLNonASCII.d.ts +3 -0
  26. package/dist/browser-types/LL/LLNonstandard.d.ts +3 -0
  27. package/dist/browser-types/LL/LLOperator.d.ts +3 -0
  28. package/dist/browser-types/LL/LLPeriod.d.ts +3 -0
  29. package/dist/browser-types/LL/LLRefEq.d.ts +3 -0
  30. package/dist/browser-types/LL/LLSI.d.ts +3 -0
  31. package/dist/browser-types/LL/LLSharp.d.ts +3 -0
  32. package/dist/browser-types/LL/LLSortedCites.d.ts +3 -0
  33. package/dist/browser-types/LL/LLSpaceEnglish.d.ts +3 -0
  34. package/dist/browser-types/LL/LLSpaceJapanese.d.ts +3 -0
  35. package/dist/browser-types/LL/LLT.d.ts +3 -0
  36. package/dist/browser-types/LL/LLTextLint.d.ts +3 -0
  37. package/dist/browser-types/LL/LLThousands.d.ts +3 -0
  38. package/dist/browser-types/LL/LLTitle.d.ts +3 -0
  39. package/dist/browser-types/LL/LLURL.d.ts +3 -0
  40. package/dist/browser-types/LL/LLUnRef.d.ts +3 -0
  41. package/dist/browser-types/LL/LLUserDefined.d.ts +3 -0
  42. package/dist/browser-types/LLText/LLText.d.ts +27 -0
  43. package/dist/browser-types/LLText/computeValidRanges.d.ts +1 -0
  44. package/dist/browser-types/LLText/createLLText.d.ts +6 -0
  45. package/dist/browser-types/LLText/createLLTextVSCode.d.ts +3 -0
  46. package/dist/browser-types/LLText/isLabelOrURL.d.ts +1 -0
  47. package/dist/browser-types/TextLint/no_dropping_i.d.ts +3 -0
  48. package/dist/browser-types/TextLint/no_dropping_ra.d.ts +3 -0
  49. package/dist/browser-types/TextLint/no_successive_word.d.ts +3 -0
  50. package/dist/browser-types/TextLint/overlooked_typo.d.ts +2 -0
  51. package/dist/browser-types/TextLint/parser.d.ts +48 -0
  52. package/dist/browser-types/TextLint/tari_tari.d.ts +6 -0
  53. package/dist/browser-types/TextLint/types.d.ts +9 -0
  54. package/dist/browser-types/TextLint/usage_error.d.ts +2 -0
  55. package/dist/browser-types/TextLint/vocabulary_loader.d.ts +10 -0
  56. package/dist/browser-types/browser.d.ts +15 -0
  57. package/dist/browser-types/util/constants.d.ts +6 -0
  58. package/dist/browser-types/util/detectMathSpace.d.ts +3 -0
  59. package/dist/browser-types/util/filterDisabledLineDiagnostics.d.ts +2 -0
  60. package/dist/browser-types/util/findLatexCommandMatches.d.ts +6 -0
  61. package/dist/browser-types/util/formatException.d.ts +1 -0
  62. package/dist/browser-types/util/getCodeWithURI.d.ts +6 -0
  63. package/dist/browser-types/util/lintWithPerformanceTracking.d.ts +32 -0
  64. package/dist/browser-types/util/match2range.d.ts +2 -0
  65. package/dist/browser-types/util/ranges2diagnostics.d.ts +3 -0
  66. package/dist/browser-types/util/regex2diagnostics.d.ts +4 -0
  67. package/dist/browser-types/util/rules.d.ts +12 -0
  68. package/dist/browser-types/util/toTitleCase.d.ts +1 -0
  69. package/dist/browser-types/util/wordSet.d.ts +1 -0
  70. package/dist/browser.mjs +9 -0
  71. package/dist/cli-licenses.txt +247 -0
  72. package/dist/cli.cjs +30147 -0
  73. package/package.json +230 -6
package/CLI.md ADDED
@@ -0,0 +1,146 @@
1
+ # CLI
2
+
3
+ English | [日本語](CLI_ja.md)
4
+
5
+ LaTeX Lint integrates with pre-commit and CI.
6
+ Node.js 22 or later and npm are required.
7
+
8
+ ## Installation
9
+
10
+ Install with npm.
11
+
12
+ Windows (PowerShell):
13
+
14
+ ```powershell
15
+ npm.cmd install --save-dev latexlint
16
+ ```
17
+
18
+ macOS and Linux:
19
+
20
+ ```sh
21
+ npm install --save-dev latexlint
22
+ ```
23
+
24
+ The remaining examples use `npm` for macOS and Linux.
25
+ On Windows, use `npm.cmd` instead.
26
+
27
+ ## Checking and fixing
28
+
29
+ The CLI primarily checks files; automatic fixes currently cover only the
30
+ `LLSpaceJapanese` rule.
31
+
32
+ If `paper.tex` and `notes.md` are the files you want to check, run:
33
+
34
+ ```sh
35
+ npm exec -- latexlint paper.tex notes.md
36
+ ```
37
+
38
+ This runs `latexlint` against both files and reports diagnostics
39
+ as `file:line:column rule message`.
40
+
41
+ You can also pass directories or quoted glob patterns instead of file names:
42
+
43
+ ```sh
44
+ npm exec -- latexlint "src/**/*.tex" "docs/**/*.md"
45
+ ```
46
+
47
+ ### Options
48
+
49
+ The options for `npm exec -- latexlint` are listed below.
50
+
51
+ | Option | Meaning |
52
+ | --- | --- |
53
+ | `-c, --config FILE` | Read [JSON settings](#json-settings); default: `.latexlint.json` in cwd. |
54
+ | `-f, --fix` | Fix active `LLSpaceJapanese` diagnostics in place and recheck. |
55
+ | `--enable RULE...` | Enable extra rules; use `--` before file names. |
56
+ | `--disable RULE...` | Disable rules; overrides settings and `--enable`. |
57
+ | `-i, --ignore PATTERN` | Exclude a file, directory, or glob; repeatable. |
58
+ | `-p, --ignore-path FILE` | Read [exclusions](#exclusions); default: `.latexlintignore`. |
59
+ | `-d, --dot` | Discover names starting with `.`, such as `.a.tex`. |
60
+ | `-q, --quiet` | Hide diagnostics; preserve exit status and execution errors. |
61
+ | `-V, --version` | Show the version. |
62
+ | `-h, --help` | Show help. |
63
+
64
+ For `RULE`, use a rule name from the
65
+ [rule list](https://github.com/HirokiHamaguchi/latexlint/blob/master/README.md#rules).
66
+
67
+ `--fix` alone does not enable rules.
68
+ To enable and fix Japanese spacing, the only rule with automatic fixes:
69
+
70
+ ```sh
71
+ npm exec -- latexlint --fix --enable LLSpaceJapanese -- paper.tex notes.md
72
+ ```
73
+
74
+ ### Exit codes
75
+
76
+ Exit codes follow
77
+ [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#exit-codes),
78
+ except that codes `2` and `3` are not currently used.
79
+
80
+ | Exit code | Meaning |
81
+ | --- | --- |
82
+ | `0` | No active diagnostics remain. |
83
+ | `1` | Active diagnostics remain, including Information diagnostics. |
84
+ | `4` | Argument, configuration, file I/O, or other execution error. |
85
+
86
+ ## Configuration
87
+
88
+ ### JSON settings
89
+
90
+ Place `.latexlint.json` in the working directory to customize settings.
91
+
92
+ To always enable `LLSpaceJapanese`, which is disabled by default:
93
+
94
+ ```json
95
+ {
96
+ "LLSpaceJapanese": true
97
+ }
98
+ ```
99
+
100
+ Set it to `false` to disable it. You can also use `"default": false` to disable
101
+ all rules before enabling individual rules.
102
+
103
+ ### Exclusions
104
+
105
+ Use `.latexlintignore` for gitignore-style exclusions.
106
+ Patterns are relative to the working directory. To exclude TeX and Markdown
107
+ files under `node_modules/` and `build/`:
108
+
109
+ ```gitignore
110
+ node_modules/
111
+ build/
112
+ ```
113
+
114
+ ## pre-commit
115
+
116
+ pre-commit provides hooks that automatically check or fix files before a Git
117
+ commit. LaTeX Lint can be used as a pre-commit Node hook.
118
+
119
+ [Install pre-commit](https://pre-commit.com/#installation) and add the following
120
+ to your project's `.pre-commit-config.yaml`:
121
+
122
+ ```yaml
123
+ repos:
124
+ - repo: https://github.com/HirokiHamaguchi/latexlint
125
+ rev: REVISION
126
+ hooks:
127
+ - id: latexlint
128
+ ```
129
+
130
+ Replace `REVISION` with the tag for the version you want to use (2.0.0 or later)
131
+ from the [published tags](https://github.com/HirokiHamaguchi/latexlint/tags).
132
+ To also fix files, replace the hook entry with:
133
+
134
+ ```yaml
135
+ - id: latexlint-fix
136
+ args: ["--enable", "LLSpaceJapanese", "--"]
137
+ ```
138
+
139
+ Both hooks check `.tex` and `.md` files and use the same project configuration.
140
+
141
+ Enable checks at commit time on Windows, macOS, or Linux with:
142
+
143
+ ```sh
144
+ pre-commit install
145
+ pre-commit run --all-files
146
+ ```
package/CLI_ja.md ADDED
@@ -0,0 +1,137 @@
1
+ # CLI版
2
+
3
+ [English](CLI.md) | 日本語
4
+
5
+ LaTeX Lintはpre-commitやCIに組み込めます。
6
+ Node.js 22以降とnpmが必要です。
7
+
8
+ ## 導入
9
+
10
+ npmでインストールします。
11
+
12
+ Windows (PowerShell):
13
+
14
+ ```powershell
15
+ npm.cmd install --save-dev latexlint
16
+ ```
17
+
18
+ macOS・Linux:
19
+
20
+ ```sh
21
+ npm install --save-dev latexlint
22
+ ```
23
+
24
+ 以降ではmacOS・Linux向けの表記として`npm`を使います。
25
+ Windowsでは`npm.cmd`に置き換えて下さい。
26
+
27
+ ## 検査と修正
28
+
29
+ 現状のCLI版では、検査を主機能とし、修正は`LLSpaceJapanese`ルールのみに限定しています。
30
+
31
+ `paper.tex`と`notes.md`を校正したいファイルとするとき、以下を実行します:
32
+
33
+ ```sh
34
+ npm exec -- latexlint paper.tex notes.md
35
+ ```
36
+
37
+ これは、`latexlint`で両ファイルを検査し、指摘を`ファイル名:行:列 ルール名 メッセージ`の形式で表示するコマンドです。
38
+
39
+ また、ファイル名の代わりにディレクトリや引用符で囲んだglobも指定できます。例えば、次のように出来ます:
40
+
41
+ ```sh
42
+ npm exec -- latexlint "src/**/*.tex" "docs/**/*.md"
43
+ ```
44
+
45
+ ### オプション
46
+
47
+ `npm exec -- latexlint`のオプションは次の通りです。
48
+
49
+ | オプション | 意味 |
50
+ | --- | --- |
51
+ | `-c, --config FILE` | 読み込む[JSON設定](#json設定)を指定する。既定は作業ディレクトリの`.latexlint.json`。 |
52
+ | `-f, --fix` | 有効な`LLSpaceJapanese`の指摘をファイルに修正し、再検査する。 |
53
+ | `--enable RULE...` | 指定ルールを追加で有効にする。ファイル名の前を`--`で区切る。 |
54
+ | `--disable RULE...` | 指定ルールを無効にする。設定ファイルや`--enable`より優先する。 |
55
+ | `-i, --ignore PATTERN` | ファイル・ディレクトリ・globを除外する。繰り返し指定できる。 |
56
+ | `-p, --ignore-path FILE` | [除外ファイル](#除外設定)を指定する。既定は`.latexlintignore`。 |
57
+ | `-d, --dot` | 探索時に`.`で始まるファイル・ディレクトリ(`.a.tex`など)も含める。 |
58
+ | `-q, --quiet` | 指摘の表示を抑える。終了コードと実行エラーの表示は維持する。 |
59
+ | `-V, --version` | バージョンを表示する。 |
60
+ | `-h, --help` | ヘルプを表示する。 |
61
+
62
+ `RULE`には[ルール一覧](https://github.com/HirokiHamaguchi/latexlint/blob/master/README_ja.md#ルール)にあるルール名を指定します。
63
+
64
+ なお、`--fix`だけではルールは有効になりません。
65
+ 現状唯一存在する、日本語空白を有効にして修正する例は、以下の通りです:
66
+
67
+ ```sh
68
+ npm exec -- latexlint --fix --enable LLSpaceJapanese -- paper.tex notes.md
69
+ ```
70
+
71
+ ### 終了コード
72
+
73
+ [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#exit-codes)の仕様に合わせて終了コードを返します。ただし、2,3は現状ありません。
74
+
75
+ | 終了コード | 意味 |
76
+ | --- | --- |
77
+ | `0` | 有効な指摘が残っていない。 |
78
+ | `1` | 有効な指摘が残っている。Informationも含む。 |
79
+ | `4` | 引数・設定・読み書きなどの実行エラー。 |
80
+
81
+ ## 設定
82
+
83
+ ### JSON設定
84
+
85
+ 作業ディレクトリに`.latexlint.json`を置くことで、設定をカスタマイズできます。
86
+ 既定では無効の`LLSpaceJapanese`を常に有効にするには、次のようにします:
87
+
88
+ ```json
89
+ {
90
+ "LLSpaceJapanese": true
91
+ }
92
+ ```
93
+
94
+ `false`にすると無効になります。`"default": false`ですべてのルールを無効にしてから、個別に有効化することもできます。
95
+
96
+ ### 除外設定
97
+
98
+ `.latexlintignore`にはgitignore形式で除外対象を記述できます。
99
+ パターンは作業ディレクトリが基準で、`node_modules/`や`build/`以下のtex・mdファイルを除外する場合は、次のようにします:
100
+
101
+ ```gitignore
102
+ node_modules/
103
+ build/
104
+ ```
105
+
106
+ ## pre-commit
107
+
108
+ pre-commitは、gitのコミット前に自動で検査・修正を行うフックを提供するツールです。
109
+ LaTeX Lintも、pre-commitのNodeフックとして利用できます。
110
+
111
+ [pre-commitを導入](https://pre-commit.com/#installation)し、プロジェクトの`.pre-commit-config.yaml`へ次を追加します。
112
+
113
+ ```yaml
114
+ repos:
115
+ - repo: https://github.com/HirokiHamaguchi/latexlint
116
+ rev: REVISION
117
+ hooks:
118
+ - id: latexlint
119
+ ```
120
+
121
+ `REVISION`には、利用するバージョン(2.0.0以降)のタグを
122
+ [公開タグ一覧](https://github.com/HirokiHamaguchi/latexlint/tags)から指定します。
123
+ 修正もしたい場合は、フックの指定を次に置き換えます:
124
+
125
+ ```yaml
126
+ - id: latexlint-fix
127
+ args: ["--enable", "LLSpaceJapanese", "--"]
128
+ ```
129
+
130
+ どちらのフックも`.tex`・`.md`を対象とし、同じプロジェクト設定を使います。
131
+
132
+ Windows・macOS・Linuxのいずれも、次のコマンドでコミット時の実行を設定できます。
133
+
134
+ ```sh
135
+ pre-commit install
136
+ pre-commit run --all-files
137
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hiroki Hamaguchi
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.