From 0445664ca395fb13277c1d195d704461c4a24c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Fri, 15 Mar 2024 09:41:12 +0100 Subject: [PATCH] feat: improve types for `Config` (#93) Use proper names and keys for the type of the SVGLint config object. So you can use: /** @type {import('svglint').Config} */ export default { rules: { ... --- src/rules/custom.js | 2 ++ src/svglint.js | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rules/custom.js b/src/rules/custom.js index 6f63171..6f7892b 100644 --- a/src/rules/custom.js +++ b/src/rules/custom.js @@ -1,6 +1,7 @@ import Logger from "../lib/logger.js"; const logger = Logger("rule:custom"); +/** @typedef {import('cheerio').Cheerio} Cheerio */ /** @typedef {import("../lib/reporter.js")} Reporter */ /** @typedef {import("../lib/parse.js").AST} AST */ /** @typedef {import("../lib/parse.js").Node} Node */ @@ -11,6 +12,7 @@ const logger = Logger("rule:custom"); * @param {Reporter} reporter The reporter to report to * @param {Cheerio} $ A cheerio representation of the document * @param {AST} ast The AST of the document, which we should pass to reporter + * @param {Info} info Info related to the current file being linted */ /** * @typedef {CustomRule} CustomConfig diff --git a/src/svglint.js b/src/svglint.js index 64c5d94..1dc0a43 100644 --- a/src/svglint.js +++ b/src/svglint.js @@ -13,13 +13,19 @@ const logger = Logger(""); /** @typedef {import("./lib/parse.js").AST} AST */ /** @typedef {import("./lib/rule-loader.js").RuleModule} RuleModule */ +/** @typedef {import("./rules/elm.js").ElmConfig} ElmConfig */ +/** @typedef {import("./rules/attr.js").AttrConfig} AttrConfig */ +/** @typedef {import("./rules/custom.js").CustomConfig} CustomConfig */ /** - * @typedef {Object} RulesConfig + * @typedef RulesConfig * An object with each key representing a rule name, and each value representing * a rule config. * If the rule config is set to `false`, then the rule is disabled (useful for * e.g. overwriting presets). + * @property {ElmConfig} [elm={}] + * @property {Array} [attr=[]] + * @property {Array} [custom=[]] */ /** * @typedef {Object} NormalizedRules