options.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /// <reference types="stylelint" />
  2. /** @typedef {import("stylelint")} stylelint */
  3. /** @typedef {import("stylelint").LinterOptions} StylelintOptions */
  4. /** @typedef {import("stylelint").FormatterType} FormatterType */
  5. /**
  6. * @typedef {Object} OutputReport
  7. * @property {string=} filePath
  8. * @property {FormatterType=} formatter
  9. */
  10. /**
  11. * @typedef {Object} PluginOptions
  12. * @property {string} context
  13. * @property {boolean} emitError
  14. * @property {boolean} emitWarning
  15. * @property {string|string[]=} exclude
  16. * @property {string|string[]} extensions
  17. * @property {boolean} failOnError
  18. * @property {boolean} failOnWarning
  19. * @property {string|string[]} files
  20. * @property {FormatterType} formatter
  21. * @property {boolean} lintDirtyModulesOnly
  22. * @property {boolean} quiet
  23. * @property {string} stylelintPath
  24. * @property {OutputReport} outputReport
  25. * @property {number|boolean=} threads
  26. */
  27. /** @typedef {Partial<PluginOptions & StylelintOptions>} Options */
  28. /**
  29. * @param {Options} pluginOptions
  30. * @returns {Partial<PluginOptions>}
  31. */
  32. export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
  33. /**
  34. * @param {Options} pluginOptions
  35. * @returns {Partial<StylelintOptions>}
  36. */
  37. export function getStylelintOptions(
  38. pluginOptions: Options
  39. ): Partial<StylelintOptions>;
  40. export type stylelint = import('postcss').PluginCreator<
  41. import('stylelint').PostcssPluginOptions
  42. > & {
  43. lint: (
  44. options: import('stylelint').LinterOptions
  45. ) => Promise<import('stylelint').LinterResult>;
  46. rules: {
  47. [k: string]: import('stylelint').Rule<any, any>;
  48. };
  49. formatters: {
  50. [k: string]: import('stylelint').Formatter;
  51. };
  52. createPlugin: (
  53. ruleName: string,
  54. plugin: import('stylelint').Plugin<any, any>
  55. ) => {
  56. ruleName: string;
  57. rule: import('stylelint').Rule<any, any>;
  58. };
  59. createLinter: (
  60. options: import('stylelint').LinterOptions
  61. ) => import('stylelint').InternalApi;
  62. utils: {
  63. report: (problem: import('stylelint').Problem) => void;
  64. ruleMessages: <
  65. T extends import('stylelint').RuleMessages,
  66. R extends { [K in keyof T]: T[K] }
  67. >(
  68. ruleName: string,
  69. messages: T
  70. ) => R;
  71. validateOptions: (
  72. result: import('stylelint').PostcssResult,
  73. ruleName: string,
  74. ...optionDescriptions: import('stylelint').RuleOptions[]
  75. ) => boolean;
  76. checkAgainstRule: <T_1, O extends Object>(
  77. options: {
  78. ruleName: string;
  79. ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
  80. root: import('postcss').Root;
  81. },
  82. callback: (warning: import('postcss').Warning) => void
  83. ) => void;
  84. };
  85. };
  86. export type StylelintOptions = import('stylelint').LinterOptions;
  87. export type FormatterType = import('stylelint').FormatterType;
  88. export type OutputReport = {
  89. filePath?: string | undefined;
  90. formatter?: FormatterType | undefined;
  91. };
  92. export type PluginOptions = {
  93. context: string;
  94. emitError: boolean;
  95. emitWarning: boolean;
  96. exclude?: (string | string[]) | undefined;
  97. extensions: string | string[];
  98. failOnError: boolean;
  99. failOnWarning: boolean;
  100. files: string | string[];
  101. formatter: FormatterType;
  102. lintDirtyModulesOnly: boolean;
  103. quiet: boolean;
  104. stylelintPath: string;
  105. outputReport: OutputReport;
  106. threads?: (number | boolean) | undefined;
  107. };
  108. export type Options = Partial<PluginOptions & StylelintOptions>;