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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.pln {
|
|
2
|
+
color: #ddd;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/* string content */
|
|
6
|
+
.str {
|
|
7
|
+
color: #61ce3c;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* a keyword */
|
|
11
|
+
.kwd {
|
|
12
|
+
color: #fbde2d;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* a comment */
|
|
16
|
+
.com {
|
|
17
|
+
color: #aeaeae;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* a type name */
|
|
21
|
+
.typ {
|
|
22
|
+
color: #8da6ce;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* a literal value */
|
|
26
|
+
.lit {
|
|
27
|
+
color: #fbde2d;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* punctuation */
|
|
31
|
+
.pun {
|
|
32
|
+
color: #ddd;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* lisp open bracket */
|
|
36
|
+
.opn {
|
|
37
|
+
color: #000000;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* lisp close bracket */
|
|
41
|
+
.clo {
|
|
42
|
+
color: #000000;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* a markup tag name */
|
|
46
|
+
.tag {
|
|
47
|
+
color: #8da6ce;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* a markup attribute name */
|
|
51
|
+
.atn {
|
|
52
|
+
color: #fbde2d;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* a markup attribute value */
|
|
56
|
+
.atv {
|
|
57
|
+
color: #ddd;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* a declaration */
|
|
61
|
+
.dec {
|
|
62
|
+
color: #EF5050;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* a variable name */
|
|
66
|
+
.var {
|
|
67
|
+
color: #c82829;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* a function name */
|
|
71
|
+
.fun {
|
|
72
|
+
color: #4271ae;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Specify class=linenums on a pre to get line numbering */
|
|
76
|
+
ol.linenums {
|
|
77
|
+
margin-top: 0;
|
|
78
|
+
margin-bottom: 0;
|
|
79
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<title>walk.js - Documentation</title>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
10
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
11
|
+
<!--[if lt IE 9]>
|
|
12
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
+
<![endif]-->
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
+
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
|
|
21
|
+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
22
|
+
<label for="nav-trigger" class="navicon-button x">
|
|
23
|
+
<div class="navicon"></div>
|
|
24
|
+
</label>
|
|
25
|
+
|
|
26
|
+
<label for="nav-trigger" class="overlay"></label>
|
|
27
|
+
|
|
28
|
+
<nav >
|
|
29
|
+
|
|
30
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnsiConsoleFormatter.html">AnsiConsoleFormatter</a><ul class='methods'><li data-type='method'><a href="AnsiConsoleFormatter.html#format">format</a></li><li data-type='method'><a href="AnsiConsoleFormatter.html#getDescription">getDescription</a></li></ul></li><li><a href="Formatter.html">Formatter</a><ul class='methods'><li data-type='method'><a href="Formatter.html#format">format</a></li><li data-type='method'><a href="Formatter.html#getDescription">getDescription</a></li><li data-type='method'><a href="Formatter.html#getName">getName</a></li></ul></li><li><a href="FormatterFactory.html">FormatterFactory</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getResources">getResources</a></li><li data-type='method'><a href="Parser.html#init">init</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li></ul></li><li><a href="Plugin.html">Plugin</a><ul class='methods'><li data-type='method'><a href="Plugin.html#getExtensions">getExtensions</a></li><li data-type='method'><a href="Plugin.html#getFormatters">getFormatters</a></li><li data-type='method'><a href="Plugin.html#getParsers">getParsers</a></li><li data-type='method'><a href="Plugin.html#getRules">getRules</a></li><li data-type='method'><a href="Plugin.html#getType">getType</a></li><li data-type='method'><a href="Plugin.html#init">init</a></li></ul></li><li><a href="PluginManager.html">PluginManager</a><ul class='methods'><li data-type='method'><a href="PluginManager.html#getHandlers">getHandlers</a></li><li data-type='method'><a href="PluginManager.html#load">load</a></li></ul></li><li><a href="ResourceICUPlurals.html">ResourceICUPlurals</a><ul class='methods'><li data-type='method'><a href="ResourceICUPlurals.html#match">match</a></li></ul></li><li><a href="ResourceQuoteStyle.html">ResourceQuoteStyle</a><ul class='methods'><li data-type='method'><a href="ResourceQuoteStyle.html#match">match</a></li></ul></li><li><a href="ResourceRegExpChecker.html">ResourceRegExpChecker</a><ul class='methods'><li data-type='method'><a href="ResourceRegExpChecker.html#match">match</a></li></ul></li><li><a href="ResourceUniqueKeys.html">ResourceUniqueKeys</a><ul class='methods'><li data-type='method'><a href="ResourceUniqueKeys.html#match">match</a></li></ul></li><li><a href="Result.html">Result</a></li><li><a href="Rule.html">Rule</a><ul class='methods'><li data-type='method'><a href="Rule.html#getDescription">getDescription</a></li><li data-type='method'><a href="Rule.html#getName">getName</a></li><li data-type='method'><a href="Rule.html#getRuleType">getRuleType</a></li><li data-type='method'><a href="Rule.html#match">match</a></li></ul></li><li><a href="RuleSet.html">RuleSet</a><ul class='methods'><li data-type='method'><a href="RuleSet.html#addRule">addRule</a></li><li data-type='method'><a href="RuleSet.html#getRule">getRule</a></li><li data-type='method'><a href="RuleSet.html#getRules">getRules</a></li><li data-type='method'><a href="RuleSet.html#getSize">getSize</a></li></ul></li><li><a href="SourceFile.html">SourceFile</a><ul class='methods'><li data-type='method'><a href="SourceFile.html#findIssues">findIssues</a></li><li data-type='method'><a href="SourceFile.html#getFilePath">getFilePath</a></li><li data-type='method'><a href="SourceFile.html#getLocaleFromPath">getLocaleFromPath</a></li><li data-type='method'><a href="SourceFile.html#getType">getType</a></li><li data-type='method'><a href="SourceFile.html#parse">parse</a></li></ul></li><li><a href="XliffParser.html">XliffParser</a><ul class='methods'><li data-type='method'><a href="XliffParser.html#getResources">getResources</a></li><li data-type='method'><a href="XliffParser.html#parse">parse</a></li></ul></li><li><a href="XliffPlugin.html">XliffPlugin</a><ul class='methods'><li data-type='method'><a href="XliffPlugin.html#getExtensions">getExtensions</a></li><li data-type='method'><a href="XliffPlugin.html#getParsers">getParsers</a></li><li data-type='method'><a href="XliffPlugin.html#getType">getType</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#ParserFactory">ParserFactory</a></li><li><a href="global.html#walk">walk</a></li></ul>
|
|
31
|
+
</nav>
|
|
32
|
+
|
|
33
|
+
<div id="main">
|
|
34
|
+
|
|
35
|
+
<h1 class="page-title">walk.js</h1>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
<section>
|
|
44
|
+
<article>
|
|
45
|
+
<pre class="prettyprint source linenums"><code>/*
|
|
46
|
+
* walk.js - walk a directory tree
|
|
47
|
+
*
|
|
48
|
+
* Copyright © 2022 JEDLSoft
|
|
49
|
+
*
|
|
50
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
+
* you may not use this file except in compliance with the License.
|
|
52
|
+
* You may obtain a copy of the License at
|
|
53
|
+
*
|
|
54
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
+
*
|
|
56
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
57
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
+
*
|
|
60
|
+
* See the License for the specific language governing permissions and
|
|
61
|
+
* limitations under the License.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
import fs from 'node:fs';
|
|
65
|
+
import path from 'node:path';
|
|
66
|
+
import log4js from 'log4js';
|
|
67
|
+
import mm from 'micromatch';
|
|
68
|
+
|
|
69
|
+
import SourceFile from './SourceFile.js';
|
|
70
|
+
|
|
71
|
+
const logger = log4js.getLogger("ilib-lint.walk");
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Recursively walk a directory and return a list of files and directories
|
|
75
|
+
* within that directory. The walk is controlled via a list of exclude and
|
|
76
|
+
* include patterns. Each pattern should be a micromatch pattern like this:
|
|
77
|
+
*
|
|
78
|
+
* <code>
|
|
79
|
+
* "*.json"
|
|
80
|
+
* </code>
|
|
81
|
+
*
|
|
82
|
+
* The full path to every file and directory in the top-level directory will
|
|
83
|
+
* be included, unless it matches an exclude pattern, it which case, it will be
|
|
84
|
+
* excluded from the output. However, if the path
|
|
85
|
+
* also matches an include pattern, it will still be included nonetheless. The
|
|
86
|
+
* idea is that you can exclude a whole category of files (like all json files),
|
|
87
|
+
* but include specific ones. For example, you may exclude all json files, but
|
|
88
|
+
* still want to include the "config.json" file.<p>
|
|
89
|
+
|
|
90
|
+
* The options parameter may include any of the following optional properties:
|
|
91
|
+
*
|
|
92
|
+
* <ul>
|
|
93
|
+
* <li><i>quiet</i> (boolean) - whether or not to give output while walking
|
|
94
|
+
* the directory tree
|
|
95
|
+
* <li><i>excludes</i> (Array of strings) - A list of micromatch patterns to
|
|
96
|
+
* exclude from the output. If a pattern matches a directory, that directory
|
|
97
|
+
* will not be recursively searched.
|
|
98
|
+
* <li><i>includes</i> (Array of strings) - A list of micromatch patterns to
|
|
99
|
+
* include in the walk. If a pattern matches both an exclude and an include, the
|
|
100
|
+
* include will override the exclude.
|
|
101
|
+
* </ul>
|
|
102
|
+
*
|
|
103
|
+
* @param {String} root Directory to walk
|
|
104
|
+
* @param {Object} options Options controlling how this walk happens. (See
|
|
105
|
+
* the description for more details.)
|
|
106
|
+
* @returns {Array.<SourceFile>} an array of file names in the directory, filtered
|
|
107
|
+
* by the the excludes and includes list
|
|
108
|
+
*/
|
|
109
|
+
function walk(root, options) {
|
|
110
|
+
let results = [], projectRoot = false, newProject, list;
|
|
111
|
+
|
|
112
|
+
if (typeof(root) !== "string") {
|
|
113
|
+
return results;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { config, quiet = false } = options || {};
|
|
117
|
+
const includes = config && config.paths ? Object.keys(config.paths) : ["**"];
|
|
118
|
+
let excludes = config && config.excludes;
|
|
119
|
+
let pathName, relPath, included, stat, glob;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
if (fs.existsSync(root)) {
|
|
123
|
+
stat = fs.statSync(root);
|
|
124
|
+
if (stat && stat.isDirectory()) {
|
|
125
|
+
list = fs.readdirSync(root);
|
|
126
|
+
if (!quiet) logger.trace("Searching " + root);
|
|
127
|
+
|
|
128
|
+
if (list && list.length !== 0) {
|
|
129
|
+
list.sort().forEach((file) => {
|
|
130
|
+
if (file === "." || file === "..") {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
pathName = path.join(root, file);
|
|
135
|
+
included = true;
|
|
136
|
+
|
|
137
|
+
if (excludes) {
|
|
138
|
+
if (!quiet) logger.trace(`There are excludes. Relpath is ${pathName}`);
|
|
139
|
+
included = !mm.isMatch(pathName, excludes);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (included) {
|
|
143
|
+
results = results.concat(walk(pathName, options));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
// file
|
|
149
|
+
included = false;
|
|
150
|
+
|
|
151
|
+
if (includes) {
|
|
152
|
+
if (!quiet) logger.trace(`There are includes.`);
|
|
153
|
+
mm.match(root, includes, {
|
|
154
|
+
onMatch: (params) => {
|
|
155
|
+
if (!glob && params.isMatch) {
|
|
156
|
+
glob = params.glob;
|
|
157
|
+
excludes = config && ((config.paths && config.paths[glob] && config.paths[glob].excludes) || excludes);
|
|
158
|
+
included = excludes ? !mm.isMatch(root, excludes) : true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (included) {
|
|
165
|
+
if (!quiet) logger.trace(`${pathName} ... included`);
|
|
166
|
+
glob = glob || "**";
|
|
167
|
+
results.push(new SourceFile({
|
|
168
|
+
filePath: root,
|
|
169
|
+
settings: config.paths && config.paths[glob]
|
|
170
|
+
}));
|
|
171
|
+
} else {
|
|
172
|
+
if (!quiet) logger.trace(`${pathName} ... excluded`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
if (!quiet) logger.warn(`File ${pathName} does not exist.`);
|
|
177
|
+
}
|
|
178
|
+
} catch (e) {
|
|
179
|
+
// if the readdirSync did not work, it's maybe a file?
|
|
180
|
+
if (fs.existsSync(root)) {
|
|
181
|
+
return [new SourceFile({
|
|
182
|
+
filePath: root
|
|
183
|
+
})];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return results;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default walk;</code></pre>
|
|
191
|
+
</article>
|
|
192
|
+
</section>
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<br class="clear">
|
|
202
|
+
|
|
203
|
+
<footer>
|
|
204
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Mon Dec 19 2022 15:00:46 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
205
|
+
</footer>
|
|
206
|
+
|
|
207
|
+
<script>prettyPrint();</script>
|
|
208
|
+
<script src="scripts/polyfill.js"></script>
|
|
209
|
+
<script src="scripts/linenumber.js"></script>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
</body>
|
|
214
|
+
</html>
|
package/log4js.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"appenders": {
|
|
3
|
+
"default": {
|
|
4
|
+
"type": "stdout",
|
|
5
|
+
"layout": {
|
|
6
|
+
"type": "pattern",
|
|
7
|
+
"pattern": "%[%p%]: %m"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"categories": {
|
|
12
|
+
"default": {
|
|
13
|
+
"appenders": [ "default" ],
|
|
14
|
+
"level": "info"
|
|
15
|
+
},
|
|
16
|
+
"ilib-lint.root": {
|
|
17
|
+
"appenders": [ "default" ],
|
|
18
|
+
"level": "info"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ilib-lint",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"module": "./src/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "./src/index.js",
|
|
7
|
+
"description": "A linter for i18n issues for any type of project",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"internationalization",
|
|
10
|
+
"i18n",
|
|
11
|
+
"localization",
|
|
12
|
+
"l10n",
|
|
13
|
+
"globalization",
|
|
14
|
+
"g11n",
|
|
15
|
+
"lint",
|
|
16
|
+
"locale"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/iLib-js/ilib-common",
|
|
19
|
+
"bugs": "https://github.com/iLib-js/ilib-common/issues",
|
|
20
|
+
"email": "marketing@translationcircle.com",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Edwin Hoogerbeets",
|
|
24
|
+
"web": "http://www.translationcircle.com/",
|
|
25
|
+
"email": "edwin@translationcircle.com"
|
|
26
|
+
},
|
|
27
|
+
"contributors": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Edwin Hoogerbeets",
|
|
30
|
+
"email": "ehoogerbeets@gmail.com"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Goun Lee",
|
|
34
|
+
"email": "goun.lee@lge.com"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"files": [
|
|
38
|
+
"src",
|
|
39
|
+
"docs",
|
|
40
|
+
"log4js.json",
|
|
41
|
+
"i18nlint.js",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/iLib-js/i18nlint.git"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=10.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "npm run build:prod",
|
|
54
|
+
"build:prod": "grunt babel --mode=prod",
|
|
55
|
+
"build:dev": "grunt babel --mode=dev",
|
|
56
|
+
"build:test": "webpack-cli --config webpack-test.config.js",
|
|
57
|
+
"dist": "npm-run-all doc build:prod build:pkg; npm pack",
|
|
58
|
+
"test": "LANG=en_US.UTF8 node test/testSuite.js",
|
|
59
|
+
"debug": "LANG=en_US.UTF8 node --inspect-brk test/testSuite.js",
|
|
60
|
+
"clean": "git clean -f -d src test",
|
|
61
|
+
"doc": "mkdir -p docs ; jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibLint.md ; npm run doc:html",
|
|
62
|
+
"doc:html": "jsdoc -c jsdoc.json"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"assertextras": "^1.1.0",
|
|
66
|
+
"docdash": "^1.2.0",
|
|
67
|
+
"jsdoc": "^3.6.11",
|
|
68
|
+
"jsdoc-to-markdown": "^7.1.1",
|
|
69
|
+
"nodeunit": "^0.11.3",
|
|
70
|
+
"npm-run-all": "^4.1.5"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@formatjs/intl": "^2.5.1",
|
|
74
|
+
"ilib-common": "^1.1.3",
|
|
75
|
+
"ilib-locale": "^1.2.2",
|
|
76
|
+
"ilib-localeinfo": "^1.0.4",
|
|
77
|
+
"ilib-tools-common": "^1.2.0",
|
|
78
|
+
"json5": "^2.2.1",
|
|
79
|
+
"log4js": "^6.7.0",
|
|
80
|
+
"micromatch": "^4.0.5",
|
|
81
|
+
"options-parser": "^0.4.0"
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/Formatter.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Formatter.js - Formats result output
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2022 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @class Represent an output formatter
|
|
22
|
+
* @abstract
|
|
23
|
+
*/
|
|
24
|
+
class Formatter {
|
|
25
|
+
/**
|
|
26
|
+
* Construct an formatter instance. Formatters and formatter plugins
|
|
27
|
+
* should implement this abstract class.
|
|
28
|
+
*/
|
|
29
|
+
constructor() {
|
|
30
|
+
if (this.constructor === Formatter) {
|
|
31
|
+
throw new Error("Cannot instantiate abstract class Formatter!");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the name of the formatter. This should be a unique string.
|
|
37
|
+
*
|
|
38
|
+
* @returns {String} the name of this formatter
|
|
39
|
+
*/
|
|
40
|
+
getName() {
|
|
41
|
+
// make sure to define this.name in your implementation
|
|
42
|
+
return this.name;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Return a general description of the formatter for use in help output.
|
|
47
|
+
*
|
|
48
|
+
* @returns {String} a general description of the formatter
|
|
49
|
+
*/
|
|
50
|
+
getDescription() {
|
|
51
|
+
return this.description;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Format the given result with the current formatter and return the
|
|
56
|
+
* formatted string.
|
|
57
|
+
*
|
|
58
|
+
* @abstract
|
|
59
|
+
* @param {Result} result the result to format
|
|
60
|
+
* @returns {String} the formatted result
|
|
61
|
+
*/
|
|
62
|
+
format(result) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default Formatter;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* FormatterFactory.js - Factory to create and return the right formatter
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2022 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import AnsiConsoleFormatter from './formatters/AnsiConsoleFormatter.js';
|
|
21
|
+
|
|
22
|
+
const formatterCache = {};
|
|
23
|
+
|
|
24
|
+
const cfmt = new AnsiConsoleFormatter();
|
|
25
|
+
formatterCache[cfmt.getName()] = cfmt;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @class Represent an output formatter
|
|
29
|
+
* @abstract
|
|
30
|
+
*/
|
|
31
|
+
function FormatterFactory(options) {
|
|
32
|
+
let fmt = formatterCache[cfmt.getName()];
|
|
33
|
+
|
|
34
|
+
if (options && options.formatter && formatterCache[options.formatter]) {
|
|
35
|
+
fmt = formatterCache[options.formatter];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return fmt;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default FormatterFactory;
|
package/src/Parser.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Parser.js - common SPI for parser plugins
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2022 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @class common SPI for parser plugins
|
|
22
|
+
* @abstract
|
|
23
|
+
*/
|
|
24
|
+
class Parser {
|
|
25
|
+
/**
|
|
26
|
+
* Construct a new plugin.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the current plugin,
|
|
33
|
+
* @abstract
|
|
34
|
+
*/
|
|
35
|
+
init() {}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parse the current file into an intermediate representation.
|
|
39
|
+
*/
|
|
40
|
+
parse() {}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* For a "resource" type of plugin, this returns a list of Resource instances
|
|
44
|
+
* that result from parsing the file.
|
|
45
|
+
*
|
|
46
|
+
* @returns {Array.<Resource>} list of Resource instances in this file
|
|
47
|
+
*/
|
|
48
|
+
getResources() {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default Parser;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ParserFactory.js - Factory to create and return the right parser for the file
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2022 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import XliffPlugin from './plugins/XliffPlugin.js';
|
|
21
|
+
|
|
22
|
+
const parserCache = {};
|
|
23
|
+
|
|
24
|
+
const xp = new XliffPlugin();
|
|
25
|
+
const extensions = xp.getExtensions();
|
|
26
|
+
const xpParsers = xp.getParsers();
|
|
27
|
+
extensions.forEach(ext => {
|
|
28
|
+
parserCache[ext] = xpParsers;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Return a list of parsers for the given file name extension
|
|
33
|
+
*/
|
|
34
|
+
function ParserFactory(options) {
|
|
35
|
+
const { extension } = options;
|
|
36
|
+
let parserClasses = parserCache[extension];
|
|
37
|
+
|
|
38
|
+
return parserClasses || [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default ParserFactory;
|