ilib-lint 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 +201 -0
- package/README.md +231 -0
- package/docs/AnsiConsoleFormatter.html +467 -0
- package/docs/Formatter.html +577 -0
- package/docs/Formatter.js.html +135 -0
- package/docs/FormatterFactory.html +191 -0
- package/docs/FormatterFactory.js.html +109 -0
- package/docs/Parser.html +483 -0
- package/docs/Parser.js.html +122 -0
- package/docs/ParserFactory.js.html +109 -0
- package/docs/Plugin.html +847 -0
- package/docs/Plugin.js.html +168 -0
- package/docs/PluginManager.html +541 -0
- package/docs/PluginManager.js.html +125 -0
- package/docs/ResourceICUPlurals.html +278 -0
- package/docs/ResourceQuoteStyle.html +278 -0
- package/docs/ResourceRegExpChecker.html +295 -0
- package/docs/ResourceUniqueKeys.html +278 -0
- package/docs/Result.html +263 -0
- package/docs/Result.js.html +130 -0
- package/docs/Rule.html +774 -0
- package/docs/Rule.js.html +230 -0
- package/docs/RuleSet.html +760 -0
- package/docs/RuleSet.js.html +153 -0
- package/docs/SourceFile.html +826 -0
- package/docs/SourceFile.js.html +232 -0
- package/docs/XliffParser.html +396 -0
- package/docs/XliffPlugin.html +472 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/formatters_AnsiConsoleFormatter.js.html +147 -0
- package/docs/global.html +448 -0
- package/docs/ilibLint.md +1013 -0
- package/docs/index.html +81 -0
- package/docs/plugins_XliffParser.js.html +129 -0
- package/docs/plugins_XliffPlugin.js.html +129 -0
- package/docs/rules_ResourceICUPlurals.js.html +297 -0
- package/docs/rules_ResourceQuoteStyle.js.html +238 -0
- package/docs/rules_ResourceRegExpChecker.js.html +248 -0
- package/docs/rules_ResourceUniqueKeys.js.html +144 -0
- package/docs/scripts/collapse.js +20 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +83 -0
- package/docs/styles/jsdoc.css +765 -0
- package/docs/styles/prettify.css +79 -0
- package/docs/walk.js.html +214 -0
- package/log4js.json +21 -0
- package/package.json +83 -0
- package/src/Formatter.js +66 -0
- package/src/FormatterFactory.js +41 -0
- package/src/Parser.js +53 -0
- package/src/ParserFactory.js +41 -0
- package/src/Plugin.js +99 -0
- package/src/PluginManager.js +56 -0
- package/src/Result.js +62 -0
- package/src/Rule.js +162 -0
- package/src/RuleSet.js +84 -0
- package/src/SourceFile.js +163 -0
- package/src/formatters/AnsiConsoleFormatter.js +78 -0
- package/src/index.js +213 -0
- package/src/plugins/XliffParser.js +60 -0
- package/src/plugins/XliffPlugin.js +60 -0
- package/src/rules/ResourceICUPlurals.js +229 -0
- package/src/rules/ResourceQuoteStyle.js +170 -0
- package/src/rules/ResourceRegExpChecker.js +179 -0
- package/src/rules/ResourceUniqueKeys.js +76 -0
- package/src/rules/utils.js +78 -0
- package/src/walk.js +146 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# ilib-lint
|
|
2
|
+
|
|
3
|
+
A static analysis linter for many types of source files that looks for i18n problems.
|
|
4
|
+
|
|
5
|
+
This i18n linter differs from other static linters in the following ways:
|
|
6
|
+
|
|
7
|
+
* it can recognize the locale of files from the path name of files or from within
|
|
8
|
+
the file itself, and applies locale-sensitive rules. For example, you can apply
|
|
9
|
+
a rule that checks that the translations in a resource file of a plural resource
|
|
10
|
+
contain the correct set of plural categories for the target language.
|
|
11
|
+
* it can apply different rulesets to different sets of files. This is useful for
|
|
12
|
+
a number of reasons:
|
|
13
|
+
* when linting a mono-repo that has different subprojects inside of it
|
|
14
|
+
and each subproject needs different rules applied to its files
|
|
15
|
+
* when different file types need different rulesets
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install ilib-lint
|
|
21
|
+
|
|
22
|
+
or
|
|
23
|
+
|
|
24
|
+
yarn add ilib-lint
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then, in your package.json, add a script:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
"scripts": {
|
|
31
|
+
"lint": "ilib-lint"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Please note: nodejs version 14 or above is required to run this tool, as it
|
|
36
|
+
is written with ESM modules.
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
Running ilib-lint is easy. Just change your directory to the top level directory
|
|
41
|
+
of your project and run it with no parameters and no configuration file. When
|
|
42
|
+
there are no parameters and no configuration file, it will do all default
|
|
43
|
+
behaviours, which for some projects is sufficient.
|
|
44
|
+
|
|
45
|
+
The default behaviours are:
|
|
46
|
+
|
|
47
|
+
* Start in the current directory and recursively find all files
|
|
48
|
+
and subdirectories underneath there
|
|
49
|
+
* All built-in rules will be added to the current rule set
|
|
50
|
+
* There are a few built-in
|
|
51
|
+
types of files handled and default rulesets that apply to them.
|
|
52
|
+
* For each rule in a ruleset, it will use the default settings for that rule
|
|
53
|
+
* It will use the default set of locales (the top 20 locales on the internet
|
|
54
|
+
by traffic) with "en-US" being the source locale
|
|
55
|
+
* It will apply each rule in the current ruleset that applies to
|
|
56
|
+
each type of file. If a file type does not have any rulesets that apply to it,
|
|
57
|
+
it will be skipped.
|
|
58
|
+
* the locale of a file will be gleaned from its path name if possible
|
|
59
|
+
* for some types of resource files, the locale is documented in
|
|
60
|
+
the file itself. (eg. xliff files)
|
|
61
|
+
* Output will be printed on the standard output in human readable form
|
|
62
|
+
```
|
|
63
|
+
$ cd myproject
|
|
64
|
+
$ ilib-lint
|
|
65
|
+
ilib-lint - Copyright (c) 2022 JEDLsoft, All rights reserved.
|
|
66
|
+
WARN: i18n/ru_RU.properties(45): translation should use the appropriate
|
|
67
|
+
quote style
|
|
68
|
+
myproject.dialog1.body.text = Нажмите кнопку "Справка", чтобы получить
|
|
69
|
+
дополнительную информацию.
|
|
70
|
+
Rule (locale-quote-style): quote style for the the locale "ru-RU" should
|
|
71
|
+
be «text»
|
|
72
|
+
$
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Command-line Parameters
|
|
76
|
+
|
|
77
|
+
ilib-lint accepts the following command-line parameters:
|
|
78
|
+
|
|
79
|
+
* help - Print out a help message detailing these command-line parameters
|
|
80
|
+
* config - Give an explicit path to a configuration file instead of trying to
|
|
81
|
+
find it in the current directory.
|
|
82
|
+
* errorsOnly - Only give information on errors, not warnings. Also, only exit
|
|
83
|
+
with status 2 if there are errors, and status 0 if there are warnings. This
|
|
84
|
+
flag allows you to squelch the warnings and only fail a script if there are
|
|
85
|
+
actual errors.
|
|
86
|
+
* locales - Locales you want your app to support. Value is a comma-separated
|
|
87
|
+
list of BCP-47 style locale tags.
|
|
88
|
+
Default: the top 20 locales on the internet by traffic.
|
|
89
|
+
* sourceLocale - locale of the source files or the source locale for resource
|
|
90
|
+
files. Default: "en-US"
|
|
91
|
+
* quiet - Produce no progress output during the run, except for errors running
|
|
92
|
+
the tool such as the inability to load a plugin. Instead exit with a return
|
|
93
|
+
value. Zero indicates no errors, and a positive exit value indicates errors.
|
|
94
|
+
|
|
95
|
+
## Exit Status
|
|
96
|
+
|
|
97
|
+
If you want to use this linter in a script, you can check for the following
|
|
98
|
+
exit status:
|
|
99
|
+
|
|
100
|
+
* 0 - no problems found
|
|
101
|
+
* 1 - warnings found
|
|
102
|
+
* 2 - errors found
|
|
103
|
+
|
|
104
|
+
When the `--errorsOnly` flag is given, the program will return 0 if only
|
|
105
|
+
warnings can be found or if no issues are found.
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
If the named paths contain a file called `ilib-lint-config.json`, it
|
|
110
|
+
will be read and processed to configure the ilib-lint tool for that path. The
|
|
111
|
+
`ilib-lint-config.json` file can have any of the following properties:
|
|
112
|
+
|
|
113
|
+
* name (String) - name of this project
|
|
114
|
+
* locales (Array of strings) - that name the default set of locales for the
|
|
115
|
+
whole project if they are not configured by each path
|
|
116
|
+
* sourceLocale (String) - name the locale for source strings in this app.
|
|
117
|
+
Default if not specified is "en-US".
|
|
118
|
+
* paths (Object) - a set of configurations for various paths that are given
|
|
119
|
+
by a [micromatch](https://github.com/micromatch/micromatch) glob expression.
|
|
120
|
+
Each glob expression property should be an object that contains settings
|
|
121
|
+
that apply to files that match the glob expression. The settings can be
|
|
122
|
+
be any of:
|
|
123
|
+
* locales (Array of strings) - a set of locales that override
|
|
124
|
+
the global locales list
|
|
125
|
+
* rules - (Object) a set of rules to use with this set of files.
|
|
126
|
+
Each rule name maps either to a boolean (true means turn it
|
|
127
|
+
on, and false means off) or to a string or object that gives
|
|
128
|
+
options for the rule. (Each rule can be different)
|
|
129
|
+
* rulesets (Array of strings) - list the names of rule sets to
|
|
130
|
+
turn on. Rulesets are groups of rules that are typically
|
|
131
|
+
bundled together for particular purpose, such as rules for a
|
|
132
|
+
particular library in a particular programming languages. For
|
|
133
|
+
example, you might have a "android-kotlin" ruleset that turns
|
|
134
|
+
on a number of rules that are typical for checking Android
|
|
135
|
+
apps written in Kotlin. If a ruleset is given, the
|
|
136
|
+
individual rules in that rule set can still be overridden using
|
|
137
|
+
the "rules" property above. Rulesets are just a short-hand
|
|
138
|
+
to turn on many of them at once.
|
|
139
|
+
* template (string) - a template that can be used to parse the
|
|
140
|
+
file name for the locale of that file.
|
|
141
|
+
|
|
142
|
+
The `ilib-lint-config.json` file can be written in [JSON5](https://github.com/json5/json5)
|
|
143
|
+
syntax, which means it can contain comments and other enhancements.
|
|
144
|
+
|
|
145
|
+
### Example Config File
|
|
146
|
+
|
|
147
|
+
Here is an example of a configuration file:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"name": "tester",
|
|
152
|
+
"locales": [
|
|
153
|
+
"en-US",
|
|
154
|
+
"de-DE",
|
|
155
|
+
"ja-JP",
|
|
156
|
+
"ko-KR"
|
|
157
|
+
],
|
|
158
|
+
"excludes": {
|
|
159
|
+
"node_modules/**",
|
|
160
|
+
".git/**",
|
|
161
|
+
"test/**"
|
|
162
|
+
},
|
|
163
|
+
"paths": {
|
|
164
|
+
"src/**/*.json": {
|
|
165
|
+
// override the general locales
|
|
166
|
+
"locales": [
|
|
167
|
+
"en-US",
|
|
168
|
+
"de-DE",
|
|
169
|
+
"ja-JP"
|
|
170
|
+
],
|
|
171
|
+
"rulesets": [
|
|
172
|
+
"javascript-ilib"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
// check the translations from the translation vendor before
|
|
176
|
+
// we use them in our project
|
|
177
|
+
"**/*.xliff": {
|
|
178
|
+
"rules": {
|
|
179
|
+
"formatjs-plural-syntax": true,
|
|
180
|
+
"formatjs-plural-categories": true,
|
|
181
|
+
"formatjs-match-substitution-params": true,
|
|
182
|
+
"match-quote-style": "localeOnly"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Built-in Rules
|
|
190
|
+
|
|
191
|
+
Some generic rules that apply to many types of files are built-in to ilib-lint.
|
|
192
|
+
This apply mostly to resource files, such as XLIFF files.
|
|
193
|
+
|
|
194
|
+
The built-in rules are:
|
|
195
|
+
|
|
196
|
+
- resource-icu-plurals - check for ICU-style plurals. Also works with formatjs
|
|
197
|
+
plurals, as it has the same syntax.
|
|
198
|
+
- resource-quote-style - if the source string has quotes, check that the target
|
|
199
|
+
string also has quotes and that those quotes are appropriate for the locale
|
|
200
|
+
- resource-url-match - if the source string contains references to URLs, check
|
|
201
|
+
that the target string also contains references to the same URLs
|
|
202
|
+
- resource-named-params - Ensure that named parameters that appear in the source
|
|
203
|
+
string are also used in the translated string
|
|
204
|
+
- resource-unique-key - Ensure that the keys are unique within a locale across
|
|
205
|
+
all resource files
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
Copyright © 2022, JEDLSoft
|
|
210
|
+
|
|
211
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
212
|
+
you may not use this file except in compliance with the License.
|
|
213
|
+
You may obtain a copy of the License at
|
|
214
|
+
|
|
215
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
216
|
+
|
|
217
|
+
Unless required by applicable law or agreed to in writing, software
|
|
218
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
219
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
220
|
+
|
|
221
|
+
See the License for the specific language governing permissions and
|
|
222
|
+
limitations under the License.
|
|
223
|
+
|
|
224
|
+
## Release Notes
|
|
225
|
+
|
|
226
|
+
### v1.0.0
|
|
227
|
+
|
|
228
|
+
- initial version
|
|
229
|
+
- define initial code and default built-in rules
|
|
230
|
+
- this is an ESM-only project, which is why it can only be run with
|
|
231
|
+
nodejs v14+
|