@diplodoc/yfmlint 1.0.0 → 1.2.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/build/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { LintError, Options } from './typings';
2
- export { LogLevels, log } 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,7 +21336,9 @@ 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,
21341
+ normalizeConfig: () => normalizeConfig,
21340
21342
  yfmlint: () => yfmlint
21341
21343
  });
21342
21344
  module.exports = __toCommonJS(src_exports);
@@ -21353,33 +21355,42 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
21353
21355
  })(LogLevels || {});
21354
21356
  var DEFAULT_LOG_LEVEL = "warn" /* WARN */;
21355
21357
  function normalizeConfig(...parts) {
21358
+ const simplify = (config) => {
21359
+ return Object.keys(config).reduce((result, key) => {
21360
+ if (config[key].level === "disabled" /* DISABLED */) {
21361
+ config[key] = false;
21362
+ }
21363
+ return result;
21364
+ }, config);
21365
+ };
21356
21366
  const normalized = parts.map((part) => {
21357
21367
  return Object.keys(part).reduce((result, key) => {
21358
21368
  if (key === "default") {
21359
21369
  result[key] = part[key];
21360
- } else {
21361
- if (typeof part[key] === "boolean") {
21362
- result[key] = part[key] ? {
21363
- level: DEFAULT_LOG_LEVEL
21364
- } : false;
21365
- }
21366
- if (typeof part[key] === "string") {
21367
- result[key] = {
21368
- level: part[key]
21369
- };
21370
- }
21371
- if (part[key] && typeof part[key] === "object") {
21372
- result[key] = {
21373
- ...part[key],
21374
- // @ts-ignore
21375
- level: part[key].level || DEFAULT_LOG_LEVEL
21376
- };
21377
- }
21370
+ } else if (typeof part[key] === "boolean") {
21371
+ result[key] = {
21372
+ level: part[key] ? DEFAULT_LOG_LEVEL : "disabled" /* DISABLED */
21373
+ };
21374
+ } else if (part[key] === "disabled" /* DISABLED */) {
21375
+ result[key] = {
21376
+ level: "disabled" /* DISABLED */
21377
+ };
21378
+ } else if (typeof part[key] === "string") {
21379
+ result[key] = {
21380
+ level: part[key]
21381
+ };
21382
+ } else if (part[key] && typeof part[key] === "object") {
21383
+ result[key] = {
21384
+ ...part[key],
21385
+ // @ts-ignore
21386
+ level: part[key].level || DEFAULT_LOG_LEVEL
21387
+ };
21378
21388
  }
21379
21389
  return result;
21380
21390
  }, {});
21381
21391
  });
21382
- return (0, import_merge.default)({}, ...normalized);
21392
+ const merged = (0, import_merge.default)({}, ...normalized);
21393
+ return simplify(merged);
21383
21394
  }
21384
21395
  function getLogLevel(logLevels, ruleNames) {
21385
21396
  return ruleNames.map((ruleName) => {
@@ -21812,7 +21823,9 @@ async function yfmlint(content3, path3, opts) {
21812
21823
  // Annotate the CommonJS export names for ESM import in node:
21813
21824
  0 && (module.exports = {
21814
21825
  LogLevels,
21826
+ getLogLevel,
21815
21827
  log,
21828
+ normalizeConfig,
21816
21829
  yfmlint
21817
21830
  });
21818
21831
  //# sourceMappingURL=index.js.map