11import { createRule } from '../utils/index.js' ;
22import { findAttribute , getLangValue } from '../utils/ast-utils.js' ;
33import type { SvelteScriptElement , SvelteStyleElement } from 'svelte-eslint-parser/lib/ast' ;
4- import { getSourceCode } from '../utils/compat.js' ;
54import type { SuggestionReportDescriptor , SourceCode } from '../types.js' ;
65
76export default createRule ( 'block-lang' , {
@@ -59,7 +58,7 @@ export default createRule('block-lang', {
5958 hasSuggestions : true
6059 } ,
6160 create ( context ) {
62- if ( ! getSourceCode ( context ) . parserServices . isSvelte ) {
61+ if ( ! context . sourceCode . parserServices . isSvelte ) {
6362 return { } ;
6463 }
6564 const enforceScriptPresent : boolean = context . options [ 0 ] ?. enforceScriptPresent ?? false ;
@@ -91,7 +90,7 @@ export default createRule('block-lang', {
9190 message : `The <script> block should be present and its lang attribute should be ${ prettyPrintLangs (
9291 allowedScriptLangs
9392 ) } .`,
94- suggest : buildAddLangSuggestions ( allowedScriptLangs , 'script' , getSourceCode ( context ) )
93+ suggest : buildAddLangSuggestions ( allowedScriptLangs , 'script' , context . sourceCode )
9594 } ) ;
9695 }
9796 for ( const scriptNode of scriptNodes ) {
@@ -106,7 +105,7 @@ export default createRule('block-lang', {
106105 }
107106 }
108107 if ( styleNodes . length === 0 && enforceStylePresent ) {
109- const sourceCode = getSourceCode ( context ) ;
108+ const sourceCode = context . sourceCode ;
110109 context . report ( {
111110 loc : { line : 1 , column : 1 } ,
112111 message : `The <style> block should be present and its lang attribute should be ${ prettyPrintLangs (
0 commit comments