Skip to content

Commit

Permalink
feat: improve types for Config (#93)
Browse files Browse the repository at this point in the history
Use proper names and keys for the type of the SVGLint config object.

So you can use:

    /** @type {import('svglint').Config} */
    export default {
      rules: {
        ...
  • Loading branch information
mondeja authored Mar 15, 2024
1 parent f15e463 commit 0445664
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/rules/custom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Logger from "../lib/logger.js";
const logger = Logger("rule:custom");

/** @typedef {import('cheerio').Cheerio<import('domhandler').Document>} Cheerio */
/** @typedef {import("../lib/reporter.js")} Reporter */
/** @typedef {import("../lib/parse.js").AST} AST */
/** @typedef {import("../lib/parse.js").Node} Node */
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/svglint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,any>} 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<AttrConfig>} [attr=[]]
* @property {Array<CustomConfig>} [custom=[]]
*/
/**
* @typedef {Object<string,Function|Function[]>} NormalizedRules
Expand Down

0 comments on commit 0445664

Please sign in to comment.