html-validate-vue-webpack-plugin
Version:
extract html-validate rules from Vue single file components
57 lines (56 loc) • 2.26 kB
TypeScript
/**
* Wrapper for `JSON.stringify(value, null, 2);`.
* @param value - the value to prettify
*/
export declare function prettify(value: unknown): string;
/**
* Takes a value and converts it to kebab-case format.
* @param value - the value to convert
*/
export declare function toKebabCase(value: string): string;
/**
* Takes a file path and returns the file name from the end of the file path.
* @param filePath - the file path, i.e. example/file.vue or file.vue
*/
export declare function getFileName(filePath: string): string;
/**
* Takes a source and returns the value of the name property.
* If no name property is found it will return an empty string.
* @param source - the content with a Vue SFC, i.e.
* ```vue
* <script>
* export default { name: 'Example' };
* </script>
* ```
*/
export declare function getComponentName(source: string): string;
/**
* Takes a source and returns the content of the `<htmlvalidate>{}</htmlvalidate>` block.
* If no content is found it will return an empty string object `"{}"`.
* @param source - the content with a htmlvalidate block, i.e.
* ```vue
* <htmlvalidate>
* {}
* </htmlvalidate>
* ```
*/
export declare function getHtmlValidateContent(source: string): string;
/**
* Takes html validate content and returns all slot names.
* Slot names are prefixed with either `#` or `:`.
* If no slot names are found it will return an empty array.
* @param htmlValidateContent - @see getHtmlValidateContent
*/
export declare function getHtmlValidateSlotNames(htmlValidateContent: string): string[];
/**
* Takes html validate content and returns all the rules that should be in the root, i.e. no slot rules.
* @param htmlValidateContent - @see getHtmlValidateContent
* @param componentName - the name of the component
*/
export declare function getHtmlValidateRootRules(htmlValidateContent: string, componentName: string): Record<string, unknown>;
/**
* Takes html validate content and returns all the rules that are considered as slot rules.
* @param htmlValidateContent - @see getHtmlValidateContent
* @param componentName - the name of the component
*/
export declare function getHtmlValidateSlotRules(htmlValidateContent: string, componentName: string): Record<string, unknown>;