getStylelint.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /// <reference types="stylelint" />
  2. /**
  3. * @param {string|undefined} key
  4. * @param {Options} options
  5. * @returns {Linter}
  6. */
  7. export default function getStylelint(
  8. key: string | undefined,
  9. { threads, ...options }: Options
  10. ): Linter;
  11. export type Stylelint = import('postcss').PluginCreator<
  12. import('stylelint').PostcssPluginOptions
  13. > & {
  14. lint: (
  15. options: import('stylelint').LinterOptions
  16. ) => Promise<import('stylelint').LinterResult>;
  17. rules: {
  18. [k: string]: import('stylelint').Rule<any, any>;
  19. };
  20. formatters: {
  21. [k: string]: import('stylelint').Formatter;
  22. };
  23. createPlugin: (
  24. ruleName: string,
  25. plugin: import('stylelint').Plugin<any, any>
  26. ) => {
  27. ruleName: string;
  28. rule: import('stylelint').Rule<any, any>;
  29. };
  30. createLinter: (
  31. options: import('stylelint').LinterOptions
  32. ) => import('stylelint').InternalApi;
  33. utils: {
  34. report: (problem: import('stylelint').Problem) => void;
  35. ruleMessages: <
  36. T extends import('stylelint').RuleMessages,
  37. R extends { [K in keyof T]: T[K] }
  38. >(
  39. ruleName: string,
  40. messages: T
  41. ) => R;
  42. validateOptions: (
  43. result: import('stylelint').PostcssResult,
  44. ruleName: string,
  45. ...optionDescriptions: import('stylelint').RuleOptions[]
  46. ) => boolean;
  47. checkAgainstRule: <T_1, O extends Object>(
  48. options: {
  49. ruleName: string;
  50. ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
  51. root: import('postcss').Root;
  52. },
  53. callback: (warning: import('postcss').Warning) => void
  54. ) => void;
  55. };
  56. };
  57. export type LintResult = import('stylelint').LintResult;
  58. export type Options = import('./options').Options;
  59. export type AsyncTask = () => Promise<void>;
  60. export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
  61. export type Worker = JestWorker & {
  62. lintFiles: LintTask;
  63. };
  64. export type Linter = {
  65. stylelint: Stylelint;
  66. lintFiles: LintTask;
  67. cleanup: AsyncTask;
  68. threads: number;
  69. };
  70. import { Worker as JestWorker } from 'jest-worker';