|
2 | 2 |
|
3 | 3 | const { compile } = require('svelte/compiler'); |
4 | 4 |
|
5 | | -let messages, transformed_code, ignore_warnings, module_info, instance_info; |
| 5 | +let compiler_options, messages, transformed_code, ignore_warnings, module_info, instance_info; |
6 | 6 |
|
7 | 7 | // get the total length, number of lines, and length of the last line of a string |
8 | 8 | const get_offsets = str => { |
@@ -134,7 +134,7 @@ const preprocess = text => { |
134 | 134 | // get information about the component |
135 | 135 | let result; |
136 | 136 | try { |
137 | | - result = compile(text, { generate: false }); |
| 137 | + result = compile(text, compiler_options); |
138 | 138 | } catch ({ name, message, start, end }) { |
139 | 139 | // convert the error to a linting message, store it, and return |
140 | 140 | messages = [ |
@@ -241,7 +241,7 @@ const get_setting_function = (config, key, default_value) => { |
241 | 241 | } |
242 | 242 | const value = config.settings[key]; |
243 | 243 | return typeof value === 'function' ? value : |
244 | | - typeof value === 'boolean' ? () => value : |
| 244 | + typeof value === 'boolean' || typeof value === 'object' ? () => value : |
245 | 245 | Array.isArray(value) ? Array.prototype.includes.bind(value) : |
246 | 246 | v => v === value; |
247 | 247 | }; |
@@ -269,6 +269,8 @@ Linter.prototype.verify = function(code, config, options) { |
269 | 269 | return ignore_styles(attrs) ? match.replace(/\S/g, ' ') : match; |
270 | 270 | }); |
271 | 271 | } |
| 272 | + const compiler_options_setting = get_setting_function(config, 'svelte3/compiler-options', false); |
| 273 | + compiler_options = compiler_options_setting ? Object.assign({ generate: false }, compiler_options_setting(options.filename)) : { generate: false }; |
272 | 274 | } |
273 | 275 | } |
274 | 276 |
|
|
0 commit comments