File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,14 @@ const find_contextual_names = (compiler, node) => {
2222 }
2323 }
2424} ;
25+ // ignore_styles when a `lang=` or `type=` attribute is present on the <style> tag
26+ const ignoreStylesFallback = ( { type, lang } ) => ! ! type || ! ! lang ;
2527
2628// extract scripts to lint from component definition
2729export const preprocess = text => {
2830 const compiler = processor_options . custom_compiler || default_compiler || ( default_compiler = require ( 'svelte/compiler' ) ) ;
29- if ( processor_options . ignore_styles ) {
31+ const ignore_styles = processor_options . ignore_styles ? processor_options . ignore_styles : ignoreStylesFallback ;
32+ if ( ignore_styles ) {
3033 // wipe the appropriate <style> tags in the file
3134 text = text . replace ( / < s t y l e ( \s [ ^ ] * ?) ? > [ ^ ] * ?< \/ s t y l e > / gi, ( match , attributes = '' ) => {
3235 const attrs = { } ;
@@ -38,7 +41,7 @@ export const preprocess = text => {
3841 attrs [ attr . slice ( 0 , p ) ] = '\'"' . includes ( attr [ p + 1 ] ) ? attr . slice ( p + 2 , - 1 ) : attr . slice ( p + 1 ) ;
3942 }
4043 } ) ;
41- return processor_options . ignore_styles ( attrs ) ? match . replace ( / \S / g, ' ' ) : match ;
44+ return ignore_styles ( attrs ) ? match . replace ( / \S / g, ' ' ) : match ;
4245 } ) ;
4346 }
4447
You can’t perform that action at this time.
0 commit comments