linter.d.ts 2.4 KB

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