html-validate 7.18.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,10 +144,10 @@ export declare class Config {
144
144
  private config;
145
145
  private configurations;
146
146
  private initialized;
147
+ private resolvers;
147
148
  private metaTable;
148
149
  private plugins;
149
150
  private transformers;
150
- private rootDir;
151
151
  /**
152
152
  * Create a new blank configuration. See also `Config.defaultConfig()`.
153
153
  */
@@ -155,7 +155,7 @@ export declare class Config {
155
155
  /**
156
156
  * Create configuration from object.
157
157
  */
158
- static fromObject(options: ConfigData, filename?: string | null): Config;
158
+ static fromObject(resolvers: Resolver | Resolver[], options: ConfigData, filename?: string | null): Config;
159
159
  /* Excluded from this release type: fromFile */
160
160
  /* Excluded from this release type: validate */
161
161
  /**
@@ -183,10 +183,9 @@ export declare class Config {
183
183
  * @public
184
184
  * @param rhs - Configuration to merge with this one.
185
185
  */
186
- merge(rhs: Config): Config;
186
+ merge(resolvers: Resolver[], rhs: Config): Config;
187
187
  private extendConfig;
188
188
  /* Excluded from this release type: getMetaTable */
189
- /* Excluded from this release type: expandRelative */
190
189
  /* Excluded from this release type: get */
191
190
  /* Excluded from this release type: getRules */
192
191
  private static getRulesObject;
@@ -229,9 +228,6 @@ export declare class Config {
229
228
  */
230
229
  private getUnnamedTransformerFromPlugin;
231
230
  private getTransformerFromModule;
232
- /* Excluded from this release type: rootDirCache */
233
- /* Excluded from this release type: rootDirCache */
234
- /* Excluded from this release type: findRootDir */
235
231
  }
236
232
 
237
233
  /**
@@ -287,16 +283,6 @@ export declare class ConfigError extends UserError {
287
283
  constructor(message: string, nested?: Error);
288
284
  }
289
285
 
290
- /**
291
- * @public
292
- */
293
- export declare interface ConfigFactory {
294
- defaultConfig(): Config;
295
- empty(): Config;
296
- fromObject(options: ConfigData, filename?: string | null): Config;
297
- fromFile(filename: string): Config;
298
- }
299
-
300
286
  /**
301
287
  * Configuration loader interface.
302
288
  *
@@ -306,9 +292,9 @@ export declare interface ConfigFactory {
306
292
  * @public
307
293
  */
308
294
  export declare abstract class ConfigLoader {
309
- protected readonly configFactory: ConfigFactory;
295
+ protected readonly resolvers: Resolver[];
310
296
  protected readonly globalConfig: Config;
311
- constructor(config?: ConfigData, configFactory?: ConfigFactory);
297
+ constructor(resolvers: Resolver[], config?: ConfigData);
312
298
  /**
313
299
  * Get configuration for given handle.
314
300
  *
@@ -317,13 +303,10 @@ export declare abstract class ConfigLoader {
317
303
  *
318
304
  * If [[configOverride]] is set it is merged with the final result.
319
305
  *
320
- * Returning a [[Config]] instance is deprecated and support will be removed
321
- * in the next major release.
322
- *
323
306
  * @param handle - Unique handle to get configuration for.
324
307
  * @param configOverride - Optional configuration to merge final results with.
325
308
  */
326
- abstract getConfigFor(handle: string, configOverride?: ConfigData): Config | ResolvedConfig;
309
+ abstract getConfigFor(handle: string, configOverride?: ConfigData): ResolvedConfig;
327
310
  /**
328
311
  * Flush configuration cache.
329
312
  *
@@ -332,6 +315,7 @@ export declare abstract class ConfigLoader {
332
315
  * @param handle - If given only the cache for given handle will be flushed.
333
316
  */
334
317
  abstract flushCache(handle?: string): void;
318
+ /* Excluded from this release type: _getGlobalConfig */
335
319
  /**
336
320
  * Default configuration used when no explicit configuration is passed to constructor.
337
321
  */
@@ -908,13 +892,29 @@ export declare class HtmlValidate {
908
892
  * @param hooks - Optional hooks (see [[Source]]) for definition.
909
893
  * @returns Report output.
910
894
  */
911
- validateString(str: string): Report;
912
- validateString(str: string, filename: string): Report;
913
- validateString(str: string, hooks: SourceHooks): Report;
914
- validateString(str: string, options: ConfigData): Report;
915
- validateString(str: string, filename: string, hooks: SourceHooks): Report;
916
- validateString(str: string, filename: string, options: ConfigData): Report;
917
- validateString(str: string, filename: string, options: ConfigData, hooks: SourceHooks): Report;
895
+ validateString(str: string): Promise<Report>;
896
+ validateString(str: string, filename: string): Promise<Report>;
897
+ validateString(str: string, hooks: SourceHooks): Promise<Report>;
898
+ validateString(str: string, options: ConfigData): Promise<Report>;
899
+ validateString(str: string, filename: string, hooks: SourceHooks): Promise<Report>;
900
+ validateString(str: string, filename: string, options: ConfigData): Promise<Report>;
901
+ validateString(str: string, filename: string, options: ConfigData, hooks: SourceHooks): Promise<Report>;
902
+ /**
903
+ * Parse and validate HTML from string.
904
+ *
905
+ * @public
906
+ * @param str - Text to parse.
907
+ * @param filename - If set configuration is loaded for given filename.
908
+ * @param hooks - Optional hooks (see [[Source]]) for definition.
909
+ * @returns Report output.
910
+ */
911
+ validateStringSync(str: string): Report;
912
+ validateStringSync(str: string, filename: string): Report;
913
+ validateStringSync(str: string, hooks: SourceHooks): Report;
914
+ validateStringSync(str: string, options: ConfigData): Report;
915
+ validateStringSync(str: string, filename: string, hooks: SourceHooks): Report;
916
+ validateStringSync(str: string, filename: string, options: ConfigData): Report;
917
+ validateStringSync(str: string, filename: string, options: ConfigData, hooks: SourceHooks): Report;
918
918
  /**
919
919
  * Parse and validate HTML from [[Source]].
920
920
  *
@@ -922,7 +922,23 @@ export declare class HtmlValidate {
922
922
  * @param input - Source to parse.
923
923
  * @returns Report output.
924
924
  */
925
- validateSource(input: Source, configOverride?: ConfigData): Report;
925
+ validateSource(input: Source, configOverride?: ConfigData): Promise<Report>;
926
+ /**
927
+ * Parse and validate HTML from [[Source]].
928
+ *
929
+ * @public
930
+ * @param input - Source to parse.
931
+ * @returns Report output.
932
+ */
933
+ validateSourceSync(input: Source, configOverride?: ConfigData): Report;
934
+ /**
935
+ * Parse and validate HTML from file.
936
+ *
937
+ * @public
938
+ * @param filename - Filename to read and parse.
939
+ * @returns Report output.
940
+ */
941
+ validateFile(filename: string): Promise<Report>;
926
942
  /**
927
943
  * Parse and validate HTML from file.
928
944
  *
@@ -930,7 +946,7 @@ export declare class HtmlValidate {
930
946
  * @param filename - Filename to read and parse.
931
947
  * @returns Report output.
932
948
  */
933
- validateFile(filename: string): Report;
949
+ validateFileSync(filename: string): Report;
934
950
  /**
935
951
  * Parse and validate HTML from multiple files. Result is merged together to a
936
952
  * single report.
@@ -938,7 +954,25 @@ export declare class HtmlValidate {
938
954
  * @param filenames - Filenames to read and parse.
939
955
  * @returns Report output.
940
956
  */
941
- validateMultipleFiles(filenames: string[]): Report;
957
+ validateMultipleFiles(filenames: string[]): Promise<Report>;
958
+ /**
959
+ * Parse and validate HTML from multiple files. Result is merged together to a
960
+ * single report.
961
+ *
962
+ * @param filenames - Filenames to read and parse.
963
+ * @returns Report output.
964
+ */
965
+ validateMultipleFilesSync(filenames: string[]): Report;
966
+ /**
967
+ * Returns true if the given filename can be validated.
968
+ *
969
+ * A file is considered to be validatable if the extension is `.html` or if a
970
+ * transformer matches the filename.
971
+ *
972
+ * This is mostly useful for tooling to determine whenever to validate the
973
+ * file or not. CLI tools will run on all the given files anyway.
974
+ */
975
+ canValidate(filename: string): Promise<boolean>;
942
976
  /**
943
977
  * Returns true if the given filename can be validated.
944
978
  *
@@ -948,7 +982,7 @@ export declare class HtmlValidate {
948
982
  * This is mostly useful for tooling to determine whenever to validate the
949
983
  * file or not. CLI tools will run on all the given files anyway.
950
984
  */
951
- canValidate(filename: string): boolean;
985
+ canValidateSync(filename: string): boolean;
952
986
  /* Excluded from this release type: dumpTokens */
953
987
  /* Excluded from this release type: dumpEvents */
954
988
  /* Excluded from this release type: dumpTree */
@@ -965,30 +999,202 @@ export declare class HtmlValidate {
965
999
  * handled by html-validate but the path will be used when resolving
966
1000
  * configuration. As a rule-of-thumb, set it to the elements json file.
967
1001
  */
968
- getElementsSchema(filename?: string): SchemaObject;
1002
+ getElementsSchema(filename?: string): Promise<SchemaObject>;
1003
+ /**
1004
+ * Get effective metadata element schema.
1005
+ *
1006
+ * If a filename is given the configured plugins can extend the
1007
+ * schema. Filename must not be an existing file or a filetype normally
1008
+ * handled by html-validate but the path will be used when resolving
1009
+ * configuration. As a rule-of-thumb, set it to the elements json file.
1010
+ */
1011
+ getElementsSchemaSync(filename?: string): SchemaObject;
1012
+ /**
1013
+ * Get contextual documentation for the given rule. The default configuration
1014
+ * will be used.
1015
+ *
1016
+ * @example
1017
+ *
1018
+ * ```js
1019
+ * const report = await htmlvalidate.validateFile("my-file.html");
1020
+ * for (const result of report.results){
1021
+ * for (const message of result.messages){
1022
+ * const documentation = await htmlvalidate.getRuleDocumentation(message, result.filePath);
1023
+ * // do something with documentation
1024
+ * }
1025
+ * }
1026
+ * ```
1027
+ *
1028
+ * @public
1029
+ * @since 8.0.0
1030
+ * @param message - Message reported during validation
1031
+ * @returns Contextual documentation or `null` if the rule does not exist.
1032
+ */
1033
+ getContextualDocumentation(message: Pick<Message, "ruleId" | "context">): Promise<RuleDocumentation | null>;
1034
+ /**
1035
+ * Get contextual documentation for the given rule. Configuration will be
1036
+ * resolved for given filename.
1037
+ *
1038
+ * @example
1039
+ *
1040
+ * ```js
1041
+ * const report = await htmlvalidate.validateFile("my-file.html");
1042
+ * for (const result of report.results){
1043
+ * for (const message of result.messages){
1044
+ * const documentation = await htmlvalidate.getRuleDocumentation(message, result.filePath);
1045
+ * // do something with documentation
1046
+ * }
1047
+ * }
1048
+ * ```
1049
+ *
1050
+ * @public
1051
+ * @since 8.0.0
1052
+ * @param message - Message reported during validation
1053
+ * @param filename - Filename used to resolve configuration.
1054
+ * @returns Contextual documentation or `null` if the rule does not exist.
1055
+ */
1056
+ getContextualDocumentation(message: Pick<Message, "ruleId" | "context">, filename: string): Promise<RuleDocumentation | null>;
1057
+ /**
1058
+ * Get contextual documentation for the given rule using provided
1059
+ * configuration.
1060
+ *
1061
+ * @example
1062
+ *
1063
+ * ```js
1064
+ * const report = await htmlvalidate.validateFile("my-file.html");
1065
+ * for (const result of report.results){
1066
+ * for (const message of result.messages){
1067
+ * const documentation = await htmlvalidate.getRuleDocumentation(message, result.filePath);
1068
+ * // do something with documentation
1069
+ * }
1070
+ * }
1071
+ * ```
1072
+ *
1073
+ * @public
1074
+ * @since 8.0.0
1075
+ * @param message - Message reported during validation
1076
+ * @param config - Configuration to use.
1077
+ * @returns Contextual documentation or `null` if the rule does not exist.
1078
+ */
1079
+ getContextualDocumentation(message: Pick<Message, "ruleId" | "context">, config: ResolvedConfig | Promise<ResolvedConfig>): Promise<RuleDocumentation | null>;
1080
+ /**
1081
+ * Get contextual documentation for the given rule. The default configuration
1082
+ * will be used.
1083
+ *
1084
+ * @example
1085
+ *
1086
+ * ```js
1087
+ * const report = htmlvalidate.validateFileSync("my-file.html");
1088
+ * for (const result of report.results){
1089
+ * for (const message of result.messages){
1090
+ * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);
1091
+ * // do something with documentation
1092
+ * }
1093
+ * }
1094
+ * ```
1095
+ *
1096
+ * @public
1097
+ * @since 8.0.0
1098
+ * @param message - Message reported during validation
1099
+ * @returns Contextual documentation or `null` if the rule does not exist.
1100
+ */
1101
+ getContextualDocumentationSync(message: Pick<Message, "ruleId" | "context">): RuleDocumentation | null;
1102
+ /**
1103
+ * Get contextual documentation for the given rule. Configuration will be
1104
+ * resolved for given filename.
1105
+ *
1106
+ * @example
1107
+ *
1108
+ * ```js
1109
+ * const report = htmlvalidate.validateFileSync("my-file.html");
1110
+ * for (const result of report.results){
1111
+ * for (const message of result.messages){
1112
+ * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);
1113
+ * // do something with documentation
1114
+ * }
1115
+ * }
1116
+ * ```
1117
+ *
1118
+ * @public
1119
+ * @since 8.0.0
1120
+ * @param message - Message reported during validation
1121
+ * @param filename - Filename used to resolve configuration.
1122
+ * @returns Contextual documentation or `null` if the rule does not exist.
1123
+ */
1124
+ getContextualDocumentationSync(message: Pick<Message, "ruleId" | "context">, filename: string): RuleDocumentation | null;
1125
+ /**
1126
+ * Get contextual documentation for the given rule using provided
1127
+ * configuration.
1128
+ *
1129
+ * @example
1130
+ *
1131
+ * ```js
1132
+ * const report = htmlvalidate.validateFileSync("my-file.html");
1133
+ * for (const result of report.results){
1134
+ * for (const message of result.messages){
1135
+ * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);
1136
+ * // do something with documentation
1137
+ * }
1138
+ * }
1139
+ * ```
1140
+ *
1141
+ * @public
1142
+ * @since 8.0.0
1143
+ * @param message - Message reported during validation
1144
+ * @param config - Configuration to use.
1145
+ * @returns Contextual documentation or `null` if the rule does not exist.
1146
+ */
1147
+ getContextualDocumentationSync(message: Pick<Message, "ruleId" | "context">, config: ResolvedConfig): RuleDocumentation | null;
969
1148
  /**
970
1149
  * Get contextual documentation for the given rule.
971
1150
  *
972
1151
  * Typical usage:
973
1152
  *
974
1153
  * ```js
975
- * const report = htmlvalidate.validateFile("my-file.html");
1154
+ * const report = await htmlvalidate.validateFile("my-file.html");
976
1155
  * for (const result of report.results){
977
- * const config = htmlvalidate.getConfigFor(result.filePath);
1156
+ * const config = await htmlvalidate.getConfigFor(result.filePath);
978
1157
  * for (const message of result.messages){
979
- * const documentation = htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
1158
+ * const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
980
1159
  * // do something with documentation
981
1160
  * }
982
1161
  * }
983
1162
  * ```
984
1163
  *
1164
+ * @public
1165
+ * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.
985
1166
  * @param ruleId - Rule to get documentation for.
986
1167
  * @param config - If set it provides more accurate description by using the
987
1168
  * correct configuration for the file.
988
1169
  * @param context - If set to `Message.context` some rules can provide
989
1170
  * contextual details and suggestions.
990
1171
  */
991
- getRuleDocumentation(ruleId: string, config?: ResolvedConfig | null, context?: any | null): RuleDocumentation | null;
1172
+ getRuleDocumentation(ruleId: string, config?: ResolvedConfig | Promise<ResolvedConfig> | null, context?: unknown | null): Promise<RuleDocumentation | null>;
1173
+ /**
1174
+ * Get contextual documentation for the given rule.
1175
+ *
1176
+ * Typical usage:
1177
+ *
1178
+ * ```js
1179
+ * const report = htmlvalidate.validateFileSync("my-file.html");
1180
+ * for (const result of report.results){
1181
+ * const config = htmlvalidate.getConfigForSync(result.filePath);
1182
+ * for (const message of result.messages){
1183
+ * const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);
1184
+ * // do something with documentation
1185
+ * }
1186
+ * }
1187
+ * ```
1188
+ *
1189
+ * @public
1190
+ * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.
1191
+ * @param ruleId - Rule to get documentation for.
1192
+ * @param config - If set it provides more accurate description by using the
1193
+ * correct configuration for the file.
1194
+ * @param context - If set to `Message.context` some rules can provide
1195
+ * contextual details and suggestions.
1196
+ */
1197
+ getRuleDocumentationSync(ruleId: string, config?: ResolvedConfig | null, context?: unknown | null): RuleDocumentation | null;
992
1198
  /* Excluded from this release type: getParserFor */
993
1199
  /**
994
1200
  * Get configuration for given filename.
@@ -999,7 +1205,17 @@ export declare class HtmlValidate {
999
1205
  * @param filename - Filename to get configuration for.
1000
1206
  * @param configOverride - Configuration to apply last.
1001
1207
  */
1002
- getConfigFor(filename: string, configOverride?: ConfigData): ResolvedConfig;
1208
+ getConfigFor(filename: string, configOverride?: ConfigData): Promise<ResolvedConfig>;
1209
+ /**
1210
+ * Get configuration for given filename.
1211
+ *
1212
+ * See [[FileSystemConfigLoader]] for details.
1213
+ *
1214
+ * @public
1215
+ * @param filename - Filename to get configuration for.
1216
+ * @param configOverride - Configuration to apply last.
1217
+ */
1218
+ getConfigForSync(filename: string, configOverride?: ConfigData): ResolvedConfig;
1003
1219
  /**
1004
1220
  * Flush configuration cache. Clears full cache unless a filename is given.
1005
1221
  *
@@ -1566,7 +1782,7 @@ export declare class Reporter {
1566
1782
  * Merge two or more reports into a single one.
1567
1783
  */
1568
1784
  static merge(reports: Report[]): Report;
1569
- add<ContextType, OptionsType>(rule: Rule<ContextType, OptionsType>, message: string, severity: number, node: DOMNode | null, location: Location_2, context?: ContextType): void;
1785
+ add<ContextType, OptionsType>(rule: Rule<ContextType, OptionsType>, message: string, severity: number, node: DOMNode | null, location: Location_2, context: ContextType): void;
1570
1786
  addManual(filename: string, message: DeferredMessage): void;
1571
1787
  save(sources?: Source[]): Report;
1572
1788
  protected isValid(): boolean;
@@ -1641,6 +1857,39 @@ export declare interface ResolvedConfigData {
1641
1857
  transformers: TransformerEntry[];
1642
1858
  }
1643
1859
 
1860
+ /**
1861
+ * @public
1862
+ * @since 8.0.0
1863
+ */
1864
+ export declare interface Resolver {
1865
+ /** Name of resolver, mostly for ease of debugging */
1866
+ name: string;
1867
+ /**
1868
+ * Resolve table of element metadata.
1869
+ */
1870
+ resolveElements?(id: string, options: ResolverOptions): unknown | null;
1871
+ /**
1872
+ * Resolve a configuration to extend.
1873
+ */
1874
+ resolveConfig?(id: string, options: ResolverOptions): ConfigData | null;
1875
+ /**
1876
+ * Resolve a plugin.
1877
+ */
1878
+ resolvePlugin?(id: string, options: ResolverOptions): Plugin_2 | null;
1879
+ /**
1880
+ * Resolve a transformer.
1881
+ */
1882
+ resolveTransformer?(id: string, options: ResolverOptions): Transformer_2 | null;
1883
+ }
1884
+
1885
+ /**
1886
+ * @public
1887
+ * @since 8.0.0
1888
+ */
1889
+ export declare interface ResolverOptions {
1890
+ cache: boolean;
1891
+ }
1892
+
1644
1893
  /**
1645
1894
  * @public
1646
1895
  */
@@ -1781,11 +2030,13 @@ export declare abstract class Rule<ContextType = void, OptionsType = void> {
1781
2030
  * Called when requesting additional documentation for a rule. Some rules
1782
2031
  * provide additional context to provide context-aware suggestions.
1783
2032
  *
2033
+ * @public
2034
+ * @virtual
1784
2035
  * @param context - Error context given by a reported error.
1785
2036
  * @returns Rule documentation and url with additional details or `null` if no
1786
2037
  * additional documentation is available.
1787
2038
  */
1788
- documentation(context?: ContextType): RuleDocumentation | null;
2039
+ documentation(context: ContextType): RuleDocumentation | null;
1789
2040
  }
1790
2041
 
1791
2042
  /* Excluded from this release type: RuleBlocker */
@@ -1989,11 +2240,61 @@ export declare interface SourceReadyEvent extends Event_2 {
1989
2240
  * @public
1990
2241
  */
1991
2242
  export declare class StaticConfigLoader extends ConfigLoader {
2243
+ /**
2244
+ * Create a static configuration loader with default resolvers.
2245
+ *
2246
+ * @param config - Global configuration
2247
+ * @param configFactory - Optional configuration factory
2248
+ */
2249
+ constructor(config?: ConfigData);
2250
+ /**
2251
+ * Create a static configuration loader with custom resolvers.
2252
+ *
2253
+ * @param resolvers - Resolvers to use
2254
+ * @param config - Global configuration
2255
+ * @param configFactory - Optional configuration factory
2256
+ */
2257
+ constructor(resolvers: Resolver[], config?: ConfigData);
1992
2258
  getConfigFor(_handle: string, configOverride?: ConfigData): ResolvedConfig;
1993
2259
  flushCache(): void;
1994
2260
  protected defaultConfig(): Config;
1995
2261
  }
1996
2262
 
2263
+ /**
2264
+ * Static resolver.
2265
+ *
2266
+ * @public
2267
+ * @since 8.0.0
2268
+ */
2269
+ export declare interface StaticResolver extends Required<Resolver> {
2270
+ addElements(id: string, elements: MetaDataTable): void;
2271
+ addConfig(id: string, config: ConfigData): void;
2272
+ addPlugin(id: string, plugin: Plugin_2): void;
2273
+ addTransformer(id: string, transformer: Transformer_2): void;
2274
+ }
2275
+
2276
+ /**
2277
+ * Create a new resolver for static content, i.e. plugins or transformers known
2278
+ * at compile time.
2279
+ *
2280
+ * @public
2281
+ * @since 8.0.0
2282
+ */
2283
+ export declare function staticResolver(map?: StaticResolverMap): StaticResolver;
2284
+
2285
+ /**
2286
+ * Entries for the static resolver.
2287
+ *
2288
+ * @public
2289
+ * @since 8.0.0
2290
+ */
2291
+ export declare interface StaticResolverMap {
2292
+ elements?: Record<string, MetaDataTable>;
2293
+ configs?: Record<string, ConfigData>;
2294
+ plugins?: Record<string, Plugin_2>;
2295
+ transformers?: Record<string, Transformer_2>;
2296
+ }
2297
+
1997
2298
  /* Excluded from this release type: StyleToken */
1998
2299
 
1999
2300
  /**
@@ -2056,55 +2357,6 @@ export declare interface TagStartEvent extends Event_2 {
2056
2357
  target: HtmlElement;
2057
2358
  }
2058
2359
 
2059
- /**
2060
- * @public
2061
- */
2062
- export declare class TemplateExtractor {
2063
- private ast;
2064
- private filename;
2065
- private data;
2066
- private constructor();
2067
- static fromFilename(filename: string): TemplateExtractor;
2068
- /**
2069
- * Create a new [[TemplateExtractor]] from javascript source code.
2070
- *
2071
- * `Source` offsets will be relative to the string, i.e. offset 0 is the first
2072
- * character of the string. If the string is only a subset of a larger string
2073
- * the offsets must be adjusted manually.
2074
- *
2075
- * @param source - Source code.
2076
- * @param filename - Optional filename to set in the resulting
2077
- * `Source`. Defauls to `"inline"`.
2078
- */
2079
- static fromString(source: string, filename?: string): TemplateExtractor;
2080
- /**
2081
- * Convenience function to create a [[Source]] instance from an existing file.
2082
- *
2083
- * @param filename - Filename with javascript source code. The file must exist
2084
- * and be readable by the user.
2085
- * @returns An array of Source's suitable for passing to [[Engine]] linting
2086
- * functions.
2087
- */
2088
- static createSource(filename: string): Source[];
2089
- /**
2090
- * Extract object properties.
2091
- *
2092
- * Given a key `"template"` this method finds all objects literals with a
2093
- * `"template"` property and creates a [[Source]] instance with proper offsets
2094
- * with the value of the property. For instance:
2095
- *
2096
- * ```
2097
- * const myObj = {
2098
- * foo: 'bar',
2099
- * };
2100
- * ```
2101
- *
2102
- * The above snippet would yield a `Source` with the content `bar`.
2103
- *
2104
- */
2105
- extractObjectProperty(key: string): Source[];
2106
- }
2107
-
2108
2360
  /* Excluded from this release type: TemplatingToken */
2109
2361
 
2110
2362
  /**