diff --git a/.changeset/early-penguins-know.md b/.changeset/early-penguins-know.md new file mode 100644 index 0000000000..b6427022f8 --- /dev/null +++ b/.changeset/early-penguins-know.md @@ -0,0 +1,5 @@ +--- +"stylelint": major +--- + +Changed: type names to be more consistent diff --git a/types/stylelint/index.d.ts b/types/stylelint/index.d.ts index a32ce95b0d..f4547460f2 100644 --- a/types/stylelint/index.d.ts +++ b/types/stylelint/index.d.ts @@ -7,10 +7,10 @@ declare module 'stylelint' { export type Severity = 'warning' | 'error'; export type ConfigExtends = string | string[]; - export type PluginType = + export type Plugin = | { default?: { ruleName: string; rule: Rule } } | { ruleName: string; rule: Rule }; - export type ConfigPlugins = string | PluginType | (string | PluginType)[]; + export type ConfigPlugins = string | Plugin | (string | Plugin)[]; export type ConfigProcessor = string | [string, Object]; export type ConfigProcessors = string | ConfigProcessor[]; export type ConfigIgnoreFiles = string | string[]; @@ -196,8 +196,6 @@ declare module 'stylelint' { meta?: RuleMeta; }; - export type Plugin = RuleBase; - export type GetPostcssOptions = { code?: string; codeFilename?: string; @@ -449,7 +447,7 @@ declare module 'stylelint' { /** * Creates a Stylelint plugin. */ - createPlugin: (ruleName: string, rule: Rule) => { ruleName: string; rule: Rule }; + createPlugin: (ruleName: string, rule: Rule) => Plugin; /** * Internal use only. Do not use or rely on this method. It may * change at any time. diff --git a/types/stylelint/type-test.ts b/types/stylelint/type-test.ts index d964f37fdd..b3e0e266dc 100644 --- a/types/stylelint/type-test.ts +++ b/types/stylelint/type-test.ts @@ -11,8 +11,8 @@ import type { FormatterType, LintResult, LinterResult, - Plugin, Rule, + RuleBase, RuleMeta, Warning, } from 'stylelint'; @@ -89,9 +89,9 @@ const meta: RuleMeta = { url: '...' }; const problemMessage: string = messages.problem; const problemFunc: (...reason: string[]) => string = messages.warning; -const testPlugin: Plugin = (options) => { +const testRule: RuleBase = (option) => { return (root, result) => { - const validOptions = stylelint.utils.validateOptions(result, ruleName, { actual: options }); + const validOptions = stylelint.utils.validateOptions(result, ruleName, { actual: option }); if (!validOptions) { return; } @@ -117,12 +117,12 @@ const testPlugin: Plugin = (options) => { }; }; -(testPlugin as Rule).ruleName = ruleName; -(testPlugin as Rule).messages = messages; -(testPlugin as Rule).primaryOptionArray = true; -(testPlugin as Rule).meta = meta; +(testRule as Rule).ruleName = ruleName; +(testRule as Rule).messages = messages; +(testRule as Rule).primaryOptionArray = true; +(testRule as Rule).meta = meta; -stylelint.createPlugin(ruleName, testPlugin as Rule); +stylelint.createPlugin(ruleName, testRule as Rule); messages.withNarrowedParam('should work');