@diplodoc/yfmlint 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +1 -1
- package/build/index.js +32 -21
- package/build/index.js.map +2 -2
- package/build/typings.d.ts +7 -10
- package/build/utils.d.ts +2 -2
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LintError, Options } from './typings';
|
|
2
|
-
export { LogLevels, log, normalizeConfig } from './utils';
|
|
2
|
+
export { LogLevels, log, getLogLevel, normalizeConfig } from './utils';
|
|
3
3
|
export declare function yfmlint(content: string, path: string, opts: Options): Promise<LintError[] | undefined>;
|
package/build/index.js
CHANGED
|
@@ -21336,6 +21336,7 @@ var init_exports_promise = __esm({
|
|
|
21336
21336
|
var src_exports = {};
|
|
21337
21337
|
__export(src_exports, {
|
|
21338
21338
|
LogLevels: () => LogLevels,
|
|
21339
|
+
getLogLevel: () => getLogLevel,
|
|
21339
21340
|
log: () => log,
|
|
21340
21341
|
normalizeConfig: () => normalizeConfig,
|
|
21341
21342
|
yfmlint: () => yfmlint
|
|
@@ -21354,40 +21355,49 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
21354
21355
|
})(LogLevels || {});
|
|
21355
21356
|
var DEFAULT_LOG_LEVEL = "warn" /* WARN */;
|
|
21356
21357
|
function normalizeConfig(...parts) {
|
|
21358
|
+
const simplify = (config) => {
|
|
21359
|
+
return Object.keys(config).reduce((result, key) => {
|
|
21360
|
+
if (config[key].loglevel === "disabled" /* DISABLED */) {
|
|
21361
|
+
config[key] = false;
|
|
21362
|
+
}
|
|
21363
|
+
return result;
|
|
21364
|
+
}, config);
|
|
21365
|
+
};
|
|
21357
21366
|
const normalized = parts.map((part) => {
|
|
21358
21367
|
return Object.keys(part).reduce((result, key) => {
|
|
21359
21368
|
if (key === "default") {
|
|
21360
21369
|
result[key] = part[key];
|
|
21361
|
-
} else {
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
}
|
|
21370
|
+
} else if (typeof part[key] === "boolean") {
|
|
21371
|
+
result[key] = {
|
|
21372
|
+
loglevel: part[key] ? DEFAULT_LOG_LEVEL : "disabled" /* DISABLED */
|
|
21373
|
+
};
|
|
21374
|
+
} else if (part[key] === "disabled" /* DISABLED */) {
|
|
21375
|
+
result[key] = {
|
|
21376
|
+
loglevel: "disabled" /* DISABLED */
|
|
21377
|
+
};
|
|
21378
|
+
} else if (typeof part[key] === "string") {
|
|
21379
|
+
result[key] = {
|
|
21380
|
+
loglevel: part[key]
|
|
21381
|
+
};
|
|
21382
|
+
} else if (part[key] && typeof part[key] === "object") {
|
|
21383
|
+
result[key] = {
|
|
21384
|
+
...part[key],
|
|
21385
|
+
// @ts-ignore
|
|
21386
|
+
loglevel: part[key].level || DEFAULT_LOG_LEVEL
|
|
21387
|
+
};
|
|
21379
21388
|
}
|
|
21380
21389
|
return result;
|
|
21381
21390
|
}, {});
|
|
21382
21391
|
});
|
|
21383
|
-
|
|
21392
|
+
const merged = (0, import_merge.default)({}, ...normalized);
|
|
21393
|
+
return simplify(merged);
|
|
21384
21394
|
}
|
|
21385
21395
|
function getLogLevel(logLevels, ruleNames) {
|
|
21386
21396
|
return ruleNames.map((ruleName) => {
|
|
21387
21397
|
if (!logLevels[ruleName]) {
|
|
21388
21398
|
return "disabled" /* DISABLED */;
|
|
21389
21399
|
}
|
|
21390
|
-
return logLevels[ruleName].
|
|
21400
|
+
return logLevels[ruleName].loglevel;
|
|
21391
21401
|
})[0] || DEFAULT_LOG_LEVEL;
|
|
21392
21402
|
}
|
|
21393
21403
|
function log(errors, logger) {
|
|
@@ -21430,7 +21440,7 @@ var config_default = {
|
|
|
21430
21440
|
// Term used without definition
|
|
21431
21441
|
YFM008: "warn" /* WARN */,
|
|
21432
21442
|
// Term inside definition not allowed
|
|
21433
|
-
YFM009: "
|
|
21443
|
+
YFM009: "warn" /* WARN */
|
|
21434
21444
|
// Term definition used not at the end of file
|
|
21435
21445
|
};
|
|
21436
21446
|
|
|
@@ -21813,6 +21823,7 @@ async function yfmlint(content3, path3, opts) {
|
|
|
21813
21823
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21814
21824
|
0 && (module.exports = {
|
|
21815
21825
|
LogLevels,
|
|
21826
|
+
getLogLevel,
|
|
21816
21827
|
log,
|
|
21817
21828
|
normalizeConfig,
|
|
21818
21829
|
yfmlint
|