latexlint 0.0.0-stage → 2.0.1

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