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.
Files changed (89) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +231 -0
  3. package/docs/AnsiConsoleFormatter.html +467 -0
  4. package/docs/Formatter.html +577 -0
  5. package/docs/Formatter.js.html +135 -0
  6. package/docs/FormatterFactory.html +191 -0
  7. package/docs/FormatterFactory.js.html +109 -0
  8. package/docs/Parser.html +483 -0
  9. package/docs/Parser.js.html +122 -0
  10. package/docs/ParserFactory.js.html +109 -0
  11. package/docs/Plugin.html +847 -0
  12. package/docs/Plugin.js.html +168 -0
  13. package/docs/PluginManager.html +541 -0
  14. package/docs/PluginManager.js.html +125 -0
  15. package/docs/ResourceICUPlurals.html +278 -0
  16. package/docs/ResourceQuoteStyle.html +278 -0
  17. package/docs/ResourceRegExpChecker.html +295 -0
  18. package/docs/ResourceUniqueKeys.html +278 -0
  19. package/docs/Result.html +263 -0
  20. package/docs/Result.js.html +130 -0
  21. package/docs/Rule.html +774 -0
  22. package/docs/Rule.js.html +230 -0
  23. package/docs/RuleSet.html +760 -0
  24. package/docs/RuleSet.js.html +153 -0
  25. package/docs/SourceFile.html +826 -0
  26. package/docs/SourceFile.js.html +232 -0
  27. package/docs/XliffParser.html +396 -0
  28. package/docs/XliffPlugin.html +472 -0
  29. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  33. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  34. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  35. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  36. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  44. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  45. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  46. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  47. package/docs/formatters_AnsiConsoleFormatter.js.html +147 -0
  48. package/docs/global.html +448 -0
  49. package/docs/ilibLint.md +1013 -0
  50. package/docs/index.html +81 -0
  51. package/docs/plugins_XliffParser.js.html +129 -0
  52. package/docs/plugins_XliffPlugin.js.html +129 -0
  53. package/docs/rules_ResourceICUPlurals.js.html +297 -0
  54. package/docs/rules_ResourceQuoteStyle.js.html +238 -0
  55. package/docs/rules_ResourceRegExpChecker.js.html +248 -0
  56. package/docs/rules_ResourceUniqueKeys.js.html +144 -0
  57. package/docs/scripts/collapse.js +20 -0
  58. package/docs/scripts/linenumber.js +25 -0
  59. package/docs/scripts/nav.js +12 -0
  60. package/docs/scripts/polyfill.js +4 -0
  61. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  62. package/docs/scripts/prettify/lang-css.js +2 -0
  63. package/docs/scripts/prettify/prettify.js +28 -0
  64. package/docs/scripts/search.js +83 -0
  65. package/docs/styles/jsdoc.css +765 -0
  66. package/docs/styles/prettify.css +79 -0
  67. package/docs/walk.js.html +214 -0
  68. package/log4js.json +21 -0
  69. package/package.json +83 -0
  70. package/src/Formatter.js +66 -0
  71. package/src/FormatterFactory.js +41 -0
  72. package/src/Parser.js +53 -0
  73. package/src/ParserFactory.js +41 -0
  74. package/src/Plugin.js +99 -0
  75. package/src/PluginManager.js +56 -0
  76. package/src/Result.js +62 -0
  77. package/src/Rule.js +162 -0
  78. package/src/RuleSet.js +84 -0
  79. package/src/SourceFile.js +163 -0
  80. package/src/formatters/AnsiConsoleFormatter.js +78 -0
  81. package/src/index.js +213 -0
  82. package/src/plugins/XliffParser.js +60 -0
  83. package/src/plugins/XliffPlugin.js +60 -0
  84. package/src/rules/ResourceICUPlurals.js +229 -0
  85. package/src/rules/ResourceQuoteStyle.js +170 -0
  86. package/src/rules/ResourceRegExpChecker.js +179 -0
  87. package/src/rules/ResourceUniqueKeys.js +76 -0
  88. package/src/rules/utils.js +78 -0
  89. package/src/walk.js +146 -0
@@ -0,0 +1,1013 @@
1
+ ## Classes
2
+
3
+ <dl>
4
+ <dt><a href="#Formatter">Formatter</a></dt>
5
+ <dd><p>Represent an output formatter</p>
6
+ </dd>
7
+ <dt><a href="#FormatterFactory">FormatterFactory</a></dt>
8
+ <dd><p>Represent an output formatter</p>
9
+ </dd>
10
+ <dt><a href="#Parser">Parser</a></dt>
11
+ <dd><p>common SPI for parser plugins</p>
12
+ </dd>
13
+ <dt><a href="#Plugin">Plugin</a></dt>
14
+ <dd><p>common SPI that all plugins must implement</p>
15
+ </dd>
16
+ <dt><a href="#PluginManager">PluginManager</a></dt>
17
+ <dd><p>Represent a plugin manager, which loads a list of plugins
18
+ and then maintains references to them</p>
19
+ </dd>
20
+ <dt><a href="#Result">Result</a></dt>
21
+ <dd><p>Represent an ilib-lint rule check result</p>
22
+ </dd>
23
+ <dt><a href="#Rule">Rule</a></dt>
24
+ <dd><p>Represent an ilib-lint rule.</p>
25
+ </dd>
26
+ <dt><a href="#RuleSet">RuleSet</a></dt>
27
+ <dd><p>Represent a set of ilib-lint rules.</p>
28
+ </dd>
29
+ <dt><a href="#SourceFile">SourceFile</a></dt>
30
+ <dd><p>Represent a set of ilib-lint rules.</p>
31
+ </dd>
32
+ <dt><a href="#AnsiConsoleFormatter">AnsiConsoleFormatter</a></dt>
33
+ <dd><p>Represent an output formatter for an ANSI console/terminal</p>
34
+ </dd>
35
+ <dt><a href="#XliffParser">XliffParser</a></dt>
36
+ <dd><p>common SPI for parser plugins</p>
37
+ </dd>
38
+ <dt><a href="#XliffPlugin">XliffPlugin</a></dt>
39
+ <dd><p>Plugin that can parse XLIFF files</p>
40
+ </dd>
41
+ <dt><a href="#ResourceICUPlurals">ResourceICUPlurals</a></dt>
42
+ <dd><p>Represent an ilib-lint rule.</p>
43
+ </dd>
44
+ <dt><a href="#ResourceQuoteStyle">ResourceQuoteStyle</a></dt>
45
+ <dd><p>Represent an ilib-lint rule.</p>
46
+ </dd>
47
+ <dt><a href="#ResourceRegExpChecker">ResourceRegExpChecker</a></dt>
48
+ <dd><p>Resource checker class that checks that any regular expressions
49
+ that matches in the source also appears in the translation.</p>
50
+ </dd>
51
+ <dt><a href="#ResourceUniqueKeys">ResourceUniqueKeys</a></dt>
52
+ <dd><p>Represent an ilib-lint rule.</p>
53
+ </dd>
54
+ </dl>
55
+
56
+ ## Functions
57
+
58
+ <dl>
59
+ <dt><a href="#ParserFactory">ParserFactory()</a></dt>
60
+ <dd><p>Return a list of parsers for the given file name extension</p>
61
+ </dd>
62
+ <dt><a href="#walk">walk(root, options)</a> ⇒ <code><a href="#SourceFile">Array.&lt;SourceFile&gt;</a></code></dt>
63
+ <dd><p>Recursively walk a directory and return a list of files and directories
64
+ within that directory. The walk is controlled via a list of exclude and
65
+ include patterns. Each pattern should be a micromatch pattern like this:</p>
66
+ <code>
67
+ "*.json"
68
+ </code>
69
+
70
+ <p>The full path to every file and directory in the top-level directory will
71
+ be included, unless it matches an exclude pattern, it which case, it will be
72
+ excluded from the output. However, if the path
73
+ also matches an include pattern, it will still be included nonetheless. The
74
+ idea is that you can exclude a whole category of files (like all json files),
75
+ but include specific ones. For example, you may exclude all json files, but
76
+ still want to include the &quot;config.json&quot; file.<p>
77
+ The options parameter may include any of the following optional properties:</p>
78
+ <ul>
79
+ <li><i>quiet</i> (boolean) - whether or not to give output while walking
80
+ the directory tree
81
+ <li><i>excludes</i> (Array of strings) - A list of micromatch patterns to
82
+ exclude from the output. If a pattern matches a directory, that directory
83
+ will not be recursively searched.
84
+ <li><i>includes</i> (Array of strings) - A list of micromatch patterns to
85
+ include in the walk. If a pattern matches both an exclude and an include, the
86
+ include will override the exclude.
87
+ </ul></dd>
88
+ </dl>
89
+
90
+ <a name="Formatter"></a>
91
+
92
+ ## *Formatter*
93
+ Represent an output formatter
94
+
95
+ **Kind**: global abstract class
96
+
97
+ * *[Formatter](#Formatter)*
98
+ * *[new Formatter()](#new_Formatter_new)*
99
+ * *[.getName()](#Formatter+getName) ⇒ <code>String</code>*
100
+ * *[.getDescription()](#Formatter+getDescription) ⇒ <code>String</code>*
101
+ * **[.format(result)](#Formatter+format) ⇒ <code>String</code>**
102
+
103
+
104
+ * * *
105
+
106
+ <a name="new_Formatter_new"></a>
107
+
108
+ ### *new Formatter()*
109
+ Construct an formatter instance. Formatters and formatter plugins
110
+ should implement this abstract class.
111
+
112
+
113
+ * * *
114
+
115
+ <a name="Formatter+getName"></a>
116
+
117
+ ### *formatter.getName() ⇒ <code>String</code>*
118
+ Get the name of the formatter. This should be a unique string.
119
+
120
+ **Kind**: instance method of [<code>Formatter</code>](#Formatter)
121
+ **Returns**: <code>String</code> - the name of this formatter
122
+
123
+ * * *
124
+
125
+ <a name="Formatter+getDescription"></a>
126
+
127
+ ### *formatter.getDescription() ⇒ <code>String</code>*
128
+ Return a general description of the formatter for use in help output.
129
+
130
+ **Kind**: instance method of [<code>Formatter</code>](#Formatter)
131
+ **Returns**: <code>String</code> - a general description of the formatter
132
+
133
+ * * *
134
+
135
+ <a name="Formatter+format"></a>
136
+
137
+ ### **formatter.format(result) ⇒ <code>String</code>**
138
+ Format the given result with the current formatter and return the
139
+ formatted string.
140
+
141
+ **Kind**: instance abstract method of [<code>Formatter</code>](#Formatter)
142
+ **Returns**: <code>String</code> - the formatted result
143
+
144
+ | Param | Type | Description |
145
+ | --- | --- | --- |
146
+ | result | [<code>Result</code>](#Result) | the result to format |
147
+
148
+
149
+ * * *
150
+
151
+ <a name="FormatterFactory"></a>
152
+
153
+ ## *FormatterFactory*
154
+ Represent an output formatter
155
+
156
+ **Kind**: global abstract class
157
+
158
+ * * *
159
+
160
+ <a name="Parser"></a>
161
+
162
+ ## *Parser*
163
+ common SPI for parser plugins
164
+
165
+ **Kind**: global abstract class
166
+
167
+ * *[Parser](#Parser)*
168
+ * *[new Parser()](#new_Parser_new)*
169
+ * **[.init()](#Parser+init)**
170
+ * *[.parse()](#Parser+parse)*
171
+ * *[.getResources()](#Parser+getResources) ⇒ <code>Array.&lt;Resource&gt;</code>*
172
+
173
+
174
+ * * *
175
+
176
+ <a name="new_Parser_new"></a>
177
+
178
+ ### *new Parser()*
179
+ Construct a new plugin.
180
+
181
+
182
+ * * *
183
+
184
+ <a name="Parser+init"></a>
185
+
186
+ ### **parser.init()**
187
+ Initialize the current plugin,
188
+
189
+ **Kind**: instance abstract method of [<code>Parser</code>](#Parser)
190
+
191
+ * * *
192
+
193
+ <a name="Parser+parse"></a>
194
+
195
+ ### *parser.parse()*
196
+ Parse the current file into an intermediate representation.
197
+
198
+ **Kind**: instance method of [<code>Parser</code>](#Parser)
199
+
200
+ * * *
201
+
202
+ <a name="Parser+getResources"></a>
203
+
204
+ ### *parser.getResources() ⇒ <code>Array.&lt;Resource&gt;</code>*
205
+ For a "resource" type of plugin, this returns a list of Resource instances
206
+ that result from parsing the file.
207
+
208
+ **Kind**: instance method of [<code>Parser</code>](#Parser)
209
+ **Returns**: <code>Array.&lt;Resource&gt;</code> - list of Resource instances in this file
210
+
211
+ * * *
212
+
213
+ <a name="Plugin"></a>
214
+
215
+ ## *Plugin*
216
+ common SPI that all plugins must implement
217
+
218
+ **Kind**: global abstract class
219
+
220
+ * *[Plugin](#Plugin)*
221
+ * *[new Plugin()](#new_Plugin_new)*
222
+ * **[.init()](#Plugin+init)**
223
+ * **[.getType()](#Plugin+getType) ⇒ <code>String</code>**
224
+ * *[.getExtensions()](#Plugin+getExtensions) ⇒ <code>Array.&lt;String&gt;</code>*
225
+ * *[.getRules()](#Plugin+getRules) ⇒ [<code>Array.&lt;Rule&gt;</code>](#Rule)*
226
+ * *[.getParsers()](#Plugin+getParsers) ⇒ [<code>Array.&lt;Parser&gt;</code>](#Parser)*
227
+ * *[.getFormatters()](#Plugin+getFormatters) ⇒ [<code>Array.&lt;Formatter&gt;</code>](#Formatter)*
228
+
229
+
230
+ * * *
231
+
232
+ <a name="new_Plugin_new"></a>
233
+
234
+ ### *new Plugin()*
235
+ Construct a new plugin.
236
+
237
+
238
+ * * *
239
+
240
+ <a name="Plugin+init"></a>
241
+
242
+ ### **plugin.init()**
243
+ Initialize the current plugin,
244
+
245
+ **Kind**: instance abstract method of [<code>Plugin</code>](#Plugin)
246
+
247
+ * * *
248
+
249
+ <a name="Plugin+getType"></a>
250
+
251
+ ### **plugin.getType() ⇒ <code>String</code>**
252
+ Return the type of this plugin. This can be one of the
253
+ following:
254
+
255
+ <ul>
256
+ <li>rule - this plugin implements a new rules
257
+ <li>parser - this plugin knows how to parse files more deeply
258
+ than line-by-line
259
+ <li>formatter - this plugin formats results for a particular
260
+ type of output
261
+ </ul>
262
+
263
+ **Kind**: instance abstract method of [<code>Plugin</code>](#Plugin)
264
+ **Returns**: <code>String</code> - tells what type of plugin this is
265
+
266
+ * * *
267
+
268
+ <a name="Plugin+getExtensions"></a>
269
+
270
+ ### *plugin.getExtensions() ⇒ <code>Array.&lt;String&gt;</code>*
271
+ Return the list of extensions of the files that this parser handles.
272
+ The extensions are listed without the dot. eg. ["json", "jsn"]
273
+
274
+ **Kind**: instance method of [<code>Plugin</code>](#Plugin)
275
+ **Returns**: <code>Array.&lt;String&gt;</code> - a list of file name extensions
276
+
277
+ * * *
278
+
279
+ <a name="Plugin+getRules"></a>
280
+
281
+ ### *plugin.getRules() ⇒ [<code>Array.&lt;Rule&gt;</code>](#Rule)*
282
+ For a "rule" type of plugin, this returns a list of Rule instances
283
+ that this plugin implements.
284
+
285
+ **Kind**: instance method of [<code>Plugin</code>](#Plugin)
286
+ **Returns**: [<code>Array.&lt;Rule&gt;</code>](#Rule) - list of Rule instances implemented by this
287
+ plugin
288
+
289
+ * * *
290
+
291
+ <a name="Plugin+getParsers"></a>
292
+
293
+ ### *plugin.getParsers() ⇒ [<code>Array.&lt;Parser&gt;</code>](#Parser)*
294
+ For a "parser" type of plugin, this returns a list of Parser classes
295
+ that this plugin implements.
296
+
297
+ **Kind**: instance method of [<code>Plugin</code>](#Plugin)
298
+ **Returns**: [<code>Array.&lt;Parser&gt;</code>](#Parser) - list of Parser classes implemented by this
299
+ plugin
300
+
301
+ * * *
302
+
303
+ <a name="Plugin+getFormatters"></a>
304
+
305
+ ### *plugin.getFormatters() ⇒ [<code>Array.&lt;Formatter&gt;</code>](#Formatter)*
306
+ For a "formatter" type of plugin, this returns a list of Formatter
307
+ instances that this plugin implements.
308
+
309
+ **Kind**: instance method of [<code>Plugin</code>](#Plugin)
310
+ **Returns**: [<code>Array.&lt;Formatter&gt;</code>](#Formatter) - list of Formatter instances implemented by this
311
+ plugin
312
+
313
+ * * *
314
+
315
+ <a name="PluginManager"></a>
316
+
317
+ ## PluginManager
318
+ Represent a plugin manager, which loads a list of plugins
319
+ and then maintains references to them
320
+
321
+ **Kind**: global class
322
+
323
+ * [PluginManager](#PluginManager)
324
+ * [new PluginManager()](#new_PluginManager_new)
325
+ * [.load(name)](#PluginManager+load) ⇒ <code>Promise</code>
326
+ * [.getHandlers(pathName, type)](#PluginManager+getHandlers) ⇒ [<code>Array.&lt;Plugin&gt;</code>](#Plugin)
327
+
328
+
329
+ * * *
330
+
331
+ <a name="new_PluginManager_new"></a>
332
+
333
+ ### new PluginManager()
334
+ Construct a new plugin manager.
335
+
336
+
337
+ * * *
338
+
339
+ <a name="PluginManager+load"></a>
340
+
341
+ ### pluginManager.load(name) ⇒ <code>Promise</code>
342
+ Load the named plugin.
343
+
344
+ **Kind**: instance method of [<code>PluginManager</code>](#PluginManager)
345
+ **Returns**: <code>Promise</code> - a promise to load the named plugin.
346
+ **Accept**: [<code>Plugin</code>](#Plugin) the loaded plugin
347
+ **Reject**: the plugin could not be found or loaded
348
+
349
+ | Param | Type | Description |
350
+ | --- | --- | --- |
351
+ | name | <code>String</code> | plugin to load |
352
+
353
+
354
+ * * *
355
+
356
+ <a name="PluginManager+getHandlers"></a>
357
+
358
+ ### pluginManager.getHandlers(pathName, type) ⇒ [<code>Array.&lt;Plugin&gt;</code>](#Plugin)
359
+ Return an array of handlers that handle the given path name based
360
+ on things like the file name extension.
361
+
362
+ **Kind**: instance method of [<code>PluginManager</code>](#PluginManager)
363
+ **Returns**: [<code>Array.&lt;Plugin&gt;</code>](#Plugin) - an array of plugins that claim to handle
364
+ the given path name
365
+
366
+ | Param | Type | Description |
367
+ | --- | --- | --- |
368
+ | pathName | <code>String</code> | path to a file to match |
369
+ | type | <code>String</code> | the type of plugin being sought |
370
+
371
+
372
+ * * *
373
+
374
+ <a name="Result"></a>
375
+
376
+ ## *Result*
377
+ Represent an ilib-lint rule check result
378
+
379
+ **Kind**: global abstract class
380
+
381
+ * * *
382
+
383
+ <a name="new_Result_new"></a>
384
+
385
+ ### *new Result(fields)*
386
+ Construct an ilib-lint rule check result. Rules should return this
387
+ type when reporting issues in the source files. The fields can
388
+ contain any of the following properties:
389
+
390
+ - severity {String}: "warning" or "error" (required)
391
+ - description {String}: description of the problem in the source file
392
+ (required)
393
+ - pathName {String}: name of the file that the issue was found in (required)
394
+ - rule {Rule}: the rule that generated this issue (required)
395
+ - id {String}: key of a resource being checked
396
+ - source {String}: for resource problems, this is the original source string
397
+ - highlight {String}: highlighted text from the source file indicating
398
+ where the issue was. For resources, this is either the source or target
399
+ string, where-ever the problem occurred
400
+ - lineNumber {Number}: line number in the source fie where the issue
401
+ was found
402
+ - locale {String}: locale of associated with this issue
403
+
404
+ Only the severity, description, pathName, and rule are required. All other
405
+ properties are optional.
406
+
407
+
408
+ | Param | Type | Description |
409
+ | --- | --- | --- |
410
+ | fields | <code>Object</code> | result fields |
411
+
412
+
413
+ * * *
414
+
415
+ <a name="Rule"></a>
416
+
417
+ ## *Rule*
418
+ Represent an ilib-lint rule.
419
+
420
+ **Kind**: global abstract class
421
+
422
+ * *[Rule](#Rule)*
423
+ * *[new Rule()](#new_Rule_new)*
424
+ * *[.getName()](#Rule+getName) ⇒ <code>String</code>*
425
+ * *[.getDescription()](#Rule+getDescription) ⇒ <code>String</code>*
426
+ * *[.getRuleType()](#Rule+getRuleType) ⇒ <code>String</code>*
427
+ * *[.match(options)](#Rule+match) ⇒ <code>Object</code> \| <code>Array.&lt;Object&gt;</code> \| <code>undefined</code>*
428
+
429
+
430
+ * * *
431
+
432
+ <a name="new_Rule_new"></a>
433
+
434
+ ### *new Rule()*
435
+ Construct an ilib-lint rule. Rules in plugins should implement this
436
+ abstract class.
437
+
438
+
439
+ * * *
440
+
441
+ <a name="Rule+getName"></a>
442
+
443
+ ### *rule.getName() ⇒ <code>String</code>*
444
+ Get the name of the rule. This should be a string with a dash-separated
445
+ set of words (kebab or dash case). Example: "resource-match-whitespace"
446
+
447
+ **Kind**: instance method of [<code>Rule</code>](#Rule)
448
+ **Returns**: <code>String</code> - the name of this rule
449
+
450
+ * * *
451
+
452
+ <a name="Rule+getDescription"></a>
453
+
454
+ ### *rule.getDescription() ⇒ <code>String</code>*
455
+ Return a general description of the type of problems that this rule is
456
+ testing for. This description is not related to particular matches, so
457
+ it cannot be more specific. Examples:
458
+
459
+ "translation should use the appropriate quote style"
460
+ "parameters to the translation wrapper function must not be concatenated"
461
+ "translation should match the whitespace of the source string"
462
+
463
+ **Kind**: instance method of [<code>Rule</code>](#Rule)
464
+ **Returns**: <code>String</code> - a general description of the type of problems that this rule is
465
+ testing for
466
+
467
+ * * *
468
+
469
+ <a name="Rule+getRuleType"></a>
470
+
471
+ ### *rule.getRuleType() ⇒ <code>String</code>*
472
+ Return the type of this rule. Rules can be organized into the following
473
+ types:
474
+
475
+ - A resource rule. This checks a translated resource with a source string
476
+ and a translation to a given locale. eg. a rule that checks that
477
+ substitution parameters that exist in the source string also are
478
+ given in the target string.
479
+ - A line rule. This rule checks single lines of a file. eg. a rule to
480
+ check the parameters to a function call.
481
+ - A multiline rule. This rule checks multiple lines at once to find
482
+ problems that may span multiple lines. For example, a rule to enforce
483
+ a policy that all translatable strings in a source file have an appropriate
484
+ translator's comment on them.
485
+ - A multifile rule. This rule checks problems across multiple files. eg.
486
+ a rule to check that ids for translatable strings are unique across all
487
+ files.
488
+
489
+ **Kind**: instance method of [<code>Rule</code>](#Rule)
490
+ **Returns**: <code>String</code> - a string with either "resource", "line", "multiline", or
491
+ "multifile".
492
+
493
+ * * *
494
+
495
+ <a name="Rule+match"></a>
496
+
497
+ ### *rule.match(options) ⇒ <code>Object</code> \| <code>Array.&lt;Object&gt;</code> \| <code>undefined</code>*
498
+ Return whether or not this rule matches the input. The options object can
499
+ contain any of the following properties:
500
+
501
+ <ul>
502
+ <li>locale - the locale against which this rule should be checked. Some rules
503
+ are locale-sensitive, others not.
504
+ <li>resource - the resource to test this rule against. For resource rules, this
505
+ is a required property.
506
+ <li>line - a single line of a file to test this rule against (for line rules)
507
+ <li>lines - all the lines of a file to test this rule against (for multiline rules
508
+ and multifile rules)
509
+ <li>pathName - the name of the current file being matched in multifile rules.
510
+ <li>parameters - (optional) parameters for this rule from the configuration file
511
+ </ul>
512
+
513
+ The return value from this method when a rule matches is an object with the
514
+ following properties:
515
+
516
+ <ul>
517
+ <li>severity - the severity of this match. This can be one of the following:
518
+ <ul>
519
+ <li>suggestion - a suggestion of a better way to do things. The current way is
520
+ not incorrect, but probably not optimal
521
+ <li>warning - a problem that should be fixed, but which does not prevent
522
+ your app from operating internationally. This is more severe than a suggestion.
523
+ <li>error - a problem that must be fixed. This type of problem will prevent
524
+ your app from operating properly internationally and could possibly even
525
+ crash your app in some cases.
526
+ </ul>
527
+ <li>description - a description of the problem to display to the user. In order
528
+ to make the ilib-lint output useful, this description should attempt to make the
529
+ following things clear:
530
+ <ul>
531
+ <li>What part is wrong
532
+ <li>Why it is wrong
533
+ <li>Suggestions on how to fix it
534
+ </ul>
535
+ <li>lineNumber - the line number where the match occurred in multiline rules
536
+ <li>highlight - the line where the problem occurred, highlighted with XML syntax
537
+ (see below)
538
+ </ul>
539
+
540
+ For the `highlight` property, the line that has a problem is reproduced with
541
+ XML tags around the problem part, if it is known. The tags are of the form
542
+ &lt;eX&gt; where X is a digit starting with 0 and progressing to 9 for each
543
+ subsequent problem. If the file type is XML already, the rest of the line will
544
+ be XML-escaped first.<p>
545
+
546
+ Example:<p>
547
+
548
+ "const str = rb.getString(<e0>id</e0>);"<p>
549
+
550
+ In this rule, `getString()` must be called with a static string in order for the
551
+ loctool to be able to extract that string. The line above calls `getString()`
552
+ with a variable named "id" as a parameter. The variable is highlighted with the
553
+ e0 tag. Callers can then translate the open and close tags appropriately for
554
+ the output device, such as ASCII escapes for a regular terminal, or HTML tags
555
+ for a web-based device.
556
+
557
+ **Kind**: instance method of [<code>Rule</code>](#Rule)
558
+ **Returns**: <code>Object</code> \| <code>Array.&lt;Object&gt;</code> \| <code>undefined</code> - an object describing the problem if the rule
559
+ does match for this locale, or an array of such Objects if there are multiple
560
+ problems with the same input, or undefined if the rule does not match
561
+
562
+ | Param | Type | Description |
563
+ | --- | --- | --- |
564
+ | options | <code>Object</code> | The options object as per the description above |
565
+
566
+
567
+ * * *
568
+
569
+ <a name="RuleSet"></a>
570
+
571
+ ## RuleSet
572
+ Represent a set of ilib-lint rules.
573
+
574
+ **Kind**: global class
575
+
576
+ * [RuleSet](#RuleSet)
577
+ * [new RuleSet()](#new_RuleSet_new)
578
+ * [.addRule(rule)](#RuleSet+addRule)
579
+ * [.getRule(name)](#RuleSet+getRule) ⇒ [<code>Rule</code>](#Rule) \| <code>undefined</code>
580
+ * [.getRules(type)](#RuleSet+getRules) ⇒ [<code>Array.&lt;Rule&gt;</code>](#Rule)
581
+ * [.getSize()](#RuleSet+getSize) ⇒ <code>Number</code>
582
+
583
+
584
+ * * *
585
+
586
+ <a name="new_RuleSet_new"></a>
587
+
588
+ ### new RuleSet()
589
+ Construct an ilib-lint rule set.
590
+
591
+
592
+ * * *
593
+
594
+ <a name="RuleSet+addRule"></a>
595
+
596
+ ### ruleSet.addRule(rule)
597
+ **Kind**: instance method of [<code>RuleSet</code>](#RuleSet)
598
+
599
+ | Param | Type |
600
+ | --- | --- |
601
+ | rule | [<code>Rule</code>](#Rule) |
602
+
603
+
604
+ * * *
605
+
606
+ <a name="RuleSet+getRule"></a>
607
+
608
+ ### ruleSet.getRule(name) ⇒ [<code>Rule</code>](#Rule) \| <code>undefined</code>
609
+ Return the rule with the given name.
610
+
611
+ **Kind**: instance method of [<code>RuleSet</code>](#RuleSet)
612
+ **Returns**: [<code>Rule</code>](#Rule) \| <code>undefined</code> - the rule with the given name or
613
+ undefined if the rule is not known
614
+
615
+ | Param | Type | Description |
616
+ | --- | --- | --- |
617
+ | name | <code>String</code> | name to search for |
618
+
619
+
620
+ * * *
621
+
622
+ <a name="RuleSet+getRules"></a>
623
+
624
+ ### ruleSet.getRules(type) ⇒ [<code>Array.&lt;Rule&gt;</code>](#Rule)
625
+ Return all the rules of the given type in this set.
626
+
627
+ **Kind**: instance method of [<code>RuleSet</code>](#RuleSet)
628
+ **Returns**: [<code>Array.&lt;Rule&gt;</code>](#Rule) - the list of rules of the requested type
629
+
630
+ | Param | Type | Description |
631
+ | --- | --- | --- |
632
+ | type | <code>String</code> | to search for |
633
+
634
+
635
+ * * *
636
+
637
+ <a name="RuleSet+getSize"></a>
638
+
639
+ ### ruleSet.getSize() ⇒ <code>Number</code>
640
+ Return the number of rules in this set.
641
+
642
+ **Kind**: instance method of [<code>RuleSet</code>](#RuleSet)
643
+ **Returns**: <code>Number</code> - the number of rules in this set
644
+
645
+ * * *
646
+
647
+ <a name="SourceFile"></a>
648
+
649
+ ## SourceFile
650
+ Represent a set of ilib-lint rules.
651
+
652
+ **Kind**: global class
653
+
654
+ * [SourceFile](#SourceFile)
655
+ * [new SourceFile()](#new_SourceFile_new)
656
+ * [.getFilePath()](#SourceFile+getFilePath) ⇒ <code>String</code>
657
+ * [.getLocaleFromPath()](#SourceFile+getLocaleFromPath) ⇒ <code>String</code>
658
+ * [.parse()](#SourceFile+parse) ⇒ <code>Object</code>
659
+ * [.getType()](#SourceFile+getType) ⇒ <code>String</code>
660
+ * [.findIssues(ruleset, locales)](#SourceFile+findIssues) ⇒ [<code>Array.&lt;Result&gt;</code>](#Result)
661
+
662
+
663
+ * * *
664
+
665
+ <a name="new_SourceFile_new"></a>
666
+
667
+ ### new SourceFile()
668
+ Construct a source file instance
669
+ The options parameter can contain any of the following properties:
670
+
671
+ - filePath {String} path to the file
672
+ - settings {Object} the settings from the ilib-lint config that
673
+ apply to this file
674
+
675
+
676
+ * * *
677
+
678
+ <a name="SourceFile+getFilePath"></a>
679
+
680
+ ### sourceFile.getFilePath() ⇒ <code>String</code>
681
+ Return the file path for this source file.
682
+
683
+ **Kind**: instance method of [<code>SourceFile</code>](#SourceFile)
684
+ **Returns**: <code>String</code> - the file path for this source file
685
+
686
+ * * *
687
+
688
+ <a name="SourceFile+getLocaleFromPath"></a>
689
+
690
+ ### sourceFile.getLocaleFromPath() ⇒ <code>String</code>
691
+ Return the locale gleaned from the file path using the template in
692
+ the settings, or undefined if no locale could be found.
693
+
694
+ **Kind**: instance method of [<code>SourceFile</code>](#SourceFile)
695
+ **Returns**: <code>String</code> - the locale gleaned from the path, or the empty
696
+ string if no locale could be found.
697
+
698
+ * * *
699
+
700
+ <a name="SourceFile+parse"></a>
701
+
702
+ ### sourceFile.parse() ⇒ <code>Object</code>
703
+ Parse the current source file into a list of resources (in the case of
704
+ resource files, or lines in the case of other types of files.
705
+
706
+ **Kind**: instance method of [<code>SourceFile</code>](#SourceFile)
707
+ **Returns**: <code>Object</code> - the parsed representation of this file
708
+
709
+ * * *
710
+
711
+ <a name="SourceFile+getType"></a>
712
+
713
+ ### sourceFile.getType() ⇒ <code>String</code>
714
+ Return the type of this file, resource or line.
715
+
716
+ **Kind**: instance method of [<code>SourceFile</code>](#SourceFile)
717
+ **Returns**: <code>String</code> - the type of this file
718
+
719
+ * * *
720
+
721
+ <a name="SourceFile+findIssues"></a>
722
+
723
+ ### sourceFile.findIssues(ruleset, locales) ⇒ [<code>Array.&lt;Result&gt;</code>](#Result)
724
+ Check the current file and return a list of issues found in this file.
725
+ This method parses the source file and applies each rule in turn
726
+ using the given locales.
727
+
728
+ **Kind**: instance method of [<code>SourceFile</code>](#SourceFile)
729
+ **Returns**: [<code>Array.&lt;Result&gt;</code>](#Result) - a list of natch results
730
+
731
+ | Param | Type | Description |
732
+ | --- | --- | --- |
733
+ | ruleset | [<code>RuleSet</code>](#RuleSet) | a set of rules to apply |
734
+ | locales | <code>Array.&lt;Locale&gt;</code> | a set of locales to apply |
735
+
736
+
737
+ * * *
738
+
739
+ <a name="AnsiConsoleFormatter"></a>
740
+
741
+ ## *AnsiConsoleFormatter*
742
+ Represent an output formatter for an ANSI console/terminal
743
+
744
+ **Kind**: global abstract class
745
+
746
+ * *[AnsiConsoleFormatter](#AnsiConsoleFormatter)*
747
+ * *[new AnsiConsoleFormatter()](#new_AnsiConsoleFormatter_new)*
748
+ * *[.getDescription()](#AnsiConsoleFormatter+getDescription) ⇒ <code>String</code>*
749
+ * **[.format(result)](#AnsiConsoleFormatter+format) ⇒ <code>String</code>**
750
+
751
+
752
+ * * *
753
+
754
+ <a name="new_AnsiConsoleFormatter_new"></a>
755
+
756
+ ### *new AnsiConsoleFormatter()*
757
+ Construct an formatter instance.
758
+
759
+
760
+ * * *
761
+
762
+ <a name="AnsiConsoleFormatter+getDescription"></a>
763
+
764
+ ### *ansiConsoleFormatter.getDescription() ⇒ <code>String</code>*
765
+ Return a general description of the formatter for use in help output.
766
+
767
+ **Kind**: instance method of [<code>AnsiConsoleFormatter</code>](#AnsiConsoleFormatter)
768
+ **Returns**: <code>String</code> - a general description of the formatter
769
+
770
+ * * *
771
+
772
+ <a name="AnsiConsoleFormatter+format"></a>
773
+
774
+ ### **ansiConsoleFormatter.format(result) ⇒ <code>String</code>**
775
+ Format the given result with the current formatter and return the
776
+ formatted string.
777
+
778
+ **Kind**: instance abstract method of [<code>AnsiConsoleFormatter</code>](#AnsiConsoleFormatter)
779
+ **Returns**: <code>String</code> - the formatted result
780
+
781
+ | Param | Type | Description |
782
+ | --- | --- | --- |
783
+ | result | [<code>Result</code>](#Result) | the result to format |
784
+
785
+
786
+ * * *
787
+
788
+ <a name="XliffParser"></a>
789
+
790
+ ## *XliffParser*
791
+ common SPI for parser plugins
792
+
793
+ **Kind**: global abstract class
794
+
795
+ * *[XliffParser](#XliffParser)*
796
+ * *[new XliffParser()](#new_XliffParser_new)*
797
+ * *[.parse()](#XliffParser+parse)*
798
+ * *[.getResources()](#XliffParser+getResources) ⇒ <code>Array.&lt;Resource&gt;</code>*
799
+
800
+
801
+ * * *
802
+
803
+ <a name="new_XliffParser_new"></a>
804
+
805
+ ### *new XliffParser()*
806
+ Construct a new plugin.
807
+
808
+
809
+ * * *
810
+
811
+ <a name="XliffParser+parse"></a>
812
+
813
+ ### *xliffParser.parse()*
814
+ Parse the current file into an intermediate representation.
815
+
816
+ **Kind**: instance method of [<code>XliffParser</code>](#XliffParser)
817
+
818
+ * * *
819
+
820
+ <a name="XliffParser+getResources"></a>
821
+
822
+ ### *xliffParser.getResources() ⇒ <code>Array.&lt;Resource&gt;</code>*
823
+ For a "resource" type of plugin, this returns a list of Resource instances
824
+ that result from parsing the file.
825
+
826
+ **Kind**: instance method of [<code>XliffParser</code>](#XliffParser)
827
+ **Returns**: <code>Array.&lt;Resource&gt;</code> - list of Resource instances in this file
828
+
829
+ * * *
830
+
831
+ <a name="XliffPlugin"></a>
832
+
833
+ ## XliffPlugin
834
+ Plugin that can parse XLIFF files
835
+
836
+ **Kind**: global class
837
+
838
+ * [XliffPlugin](#XliffPlugin)
839
+ * [.getType()](#XliffPlugin+getType)
840
+ * [.getExtensions()](#XliffPlugin+getExtensions)
841
+ * [.getParsers()](#XliffPlugin+getParsers) ⇒ [<code>Array.&lt;Parser&gt;</code>](#Parser)
842
+
843
+
844
+ * * *
845
+
846
+ <a name="XliffPlugin+getType"></a>
847
+
848
+ ### xliffPlugin.getType()
849
+ **Kind**: instance method of [<code>XliffPlugin</code>](#XliffPlugin)
850
+
851
+ * * *
852
+
853
+ <a name="XliffPlugin+getExtensions"></a>
854
+
855
+ ### xliffPlugin.getExtensions()
856
+ **Kind**: instance method of [<code>XliffPlugin</code>](#XliffPlugin)
857
+
858
+ * * *
859
+
860
+ <a name="XliffPlugin+getParsers"></a>
861
+
862
+ ### xliffPlugin.getParsers() ⇒ [<code>Array.&lt;Parser&gt;</code>](#Parser)
863
+ For a "parser" type of plugin, this returns a list of Parser classes
864
+ that this plugin implements.
865
+
866
+ **Kind**: instance method of [<code>XliffPlugin</code>](#XliffPlugin)
867
+ **Returns**: [<code>Array.&lt;Parser&gt;</code>](#Parser) - list of Parser classes implemented by this
868
+ plugin
869
+
870
+ * * *
871
+
872
+ <a name="ResourceICUPlurals"></a>
873
+
874
+ ## ResourceICUPlurals
875
+ Represent an ilib-lint rule.
876
+
877
+ **Kind**: global class
878
+
879
+ * * *
880
+
881
+ <a name="ResourceICUPlurals+match"></a>
882
+
883
+ ### resourceICUPlurals.match()
884
+ **Kind**: instance method of [<code>ResourceICUPlurals</code>](#ResourceICUPlurals)
885
+
886
+ * * *
887
+
888
+ <a name="ResourceQuoteStyle"></a>
889
+
890
+ ## ResourceQuoteStyle
891
+ Represent an ilib-lint rule.
892
+
893
+ **Kind**: global class
894
+
895
+ * * *
896
+
897
+ <a name="ResourceQuoteStyle+match"></a>
898
+
899
+ ### resourceQuoteStyle.match()
900
+ **Kind**: instance method of [<code>ResourceQuoteStyle</code>](#ResourceQuoteStyle)
901
+
902
+ * * *
903
+
904
+ <a name="ResourceRegExpChecker"></a>
905
+
906
+ ## ResourceRegExpChecker
907
+ Resource checker class that checks that any regular expressions
908
+ that matches in the source also appears in the translation.
909
+
910
+ **Kind**: global class
911
+
912
+ * [ResourceRegExpChecker](#ResourceRegExpChecker)
913
+ * [new ResourceRegExpChecker()](#new_ResourceRegExpChecker_new)
914
+ * [.match()](#ResourceRegExpChecker+match)
915
+
916
+
917
+ * * *
918
+
919
+ <a name="new_ResourceRegExpChecker_new"></a>
920
+
921
+ ### new ResourceRegExpChecker()
922
+ Construct a new regular expression-based resource checker.
923
+
924
+ The options must contain the following required properties:
925
+
926
+ - name - a unique name for this rule
927
+ - description - a one-line description of what this rule checks for.
928
+ Example: "Check that URLs in the source also appear in the target"
929
+ - note - a one-line note that will be printed on screen when the
930
+ check fails. Example: "The URL {matchString} did not appear in the
931
+ the target." (Currently, matchString is the only replacement
932
+ param that is supported.)
933
+ - regexps - an array of strings that encode regular expressions to
934
+ look for
935
+
936
+
937
+ * * *
938
+
939
+ <a name="ResourceRegExpChecker+match"></a>
940
+
941
+ ### resourceRegExpChecker.match()
942
+ **Kind**: instance method of [<code>ResourceRegExpChecker</code>](#ResourceRegExpChecker)
943
+
944
+ * * *
945
+
946
+ <a name="ResourceUniqueKeys"></a>
947
+
948
+ ## ResourceUniqueKeys
949
+ Represent an ilib-lint rule.
950
+
951
+ **Kind**: global class
952
+
953
+ * * *
954
+
955
+ <a name="ResourceUniqueKeys+match"></a>
956
+
957
+ ### resourceUniqueKeys.match()
958
+ **Kind**: instance method of [<code>ResourceUniqueKeys</code>](#ResourceUniqueKeys)
959
+
960
+ * * *
961
+
962
+ <a name="ParserFactory"></a>
963
+
964
+ ## ParserFactory()
965
+ Return a list of parsers for the given file name extension
966
+
967
+ **Kind**: global function
968
+
969
+ * * *
970
+
971
+ <a name="walk"></a>
972
+
973
+ ## walk(root, options) ⇒ [<code>Array.&lt;SourceFile&gt;</code>](#SourceFile)
974
+ Recursively walk a directory and return a list of files and directories
975
+ within that directory. The walk is controlled via a list of exclude and
976
+ include patterns. Each pattern should be a micromatch pattern like this:
977
+
978
+ <code>
979
+ "*.json"
980
+ </code>
981
+
982
+ The full path to every file and directory in the top-level directory will
983
+ be included, unless it matches an exclude pattern, it which case, it will be
984
+ excluded from the output. However, if the path
985
+ also matches an include pattern, it will still be included nonetheless. The
986
+ idea is that you can exclude a whole category of files (like all json files),
987
+ but include specific ones. For example, you may exclude all json files, but
988
+ still want to include the "config.json" file.<p>
989
+ The options parameter may include any of the following optional properties:
990
+
991
+ <ul>
992
+ <li><i>quiet</i> (boolean) - whether or not to give output while walking
993
+ the directory tree
994
+ <li><i>excludes</i> (Array of strings) - A list of micromatch patterns to
995
+ exclude from the output. If a pattern matches a directory, that directory
996
+ will not be recursively searched.
997
+ <li><i>includes</i> (Array of strings) - A list of micromatch patterns to
998
+ include in the walk. If a pattern matches both an exclude and an include, the
999
+ include will override the exclude.
1000
+ </ul>
1001
+
1002
+ **Kind**: global function
1003
+ **Returns**: [<code>Array.&lt;SourceFile&gt;</code>](#SourceFile) - an array of file names in the directory, filtered
1004
+ by the the excludes and includes list
1005
+
1006
+ | Param | Type | Description |
1007
+ | --- | --- | --- |
1008
+ | root | <code>String</code> | Directory to walk |
1009
+ | options | <code>Object</code> | Options controlling how this walk happens. (See the description for more details.) |
1010
+
1011
+
1012
+ * * *
1013
+