File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export default createRule("system", {
2222
2323 const ignoreWarnings =
2424 context . settings ?. [ "@ota-meshi/svelte" ] ?. ignoreWarnings
25- if ( ! Array . isArray ( ignoreWarnings ) ) {
25+ if ( ignoreWarnings && ! Array . isArray ( ignoreWarnings ) ) {
2626 context . report ( {
2727 loc : { line : 1 , column : 0 } ,
2828 message :
@@ -31,7 +31,7 @@ export default createRule("system", {
3131 return { }
3232 }
3333 const ignoreTests : ( ( ruleId : string ) => boolean ) [ ] = [ ]
34- for ( const ignoreWarning of ignoreWarnings ) {
34+ for ( const ignoreWarning of ignoreWarnings || [ ] ) {
3535 if ( typeof ignoreWarning !== "string" ) {
3636 context . report ( {
3737 loc : { line : 1 , column : 0 } ,
Original file line number Diff line number Diff line change @@ -125,4 +125,38 @@ describe("ignore-warnings", () => {
125125 ] ,
126126 )
127127 } )
128+
129+ it ( "without settings" , async ( ) => {
130+ const code = `
131+ {@html a+b}
132+ {@debug a}
133+ <script>
134+ a+b;
135+ </script>
136+ `
137+
138+ const linter = new eslint . ESLint ( {
139+ plugins : {
140+ "@ota-meshi/svelte" : plugin ,
141+ } ,
142+ baseConfig : {
143+ parser : require . resolve ( "svelte-eslint-parser" ) ,
144+ parserOptions : {
145+ ecmaVersion : 2020 ,
146+ } ,
147+ plugins : [ "@ota-meshi/svelte" ] ,
148+ rules : {
149+ "@ota-meshi/svelte/system" : "error" ,
150+ } ,
151+ } ,
152+ useEslintrc : false ,
153+ } )
154+ const result = await linter . lintText ( code , { filePath : "test.svelte" } )
155+ const messages = result [ 0 ] . messages
156+
157+ assert . deepStrictEqual (
158+ messages . map ( ( m ) => ( { ruleId : m . ruleId , line : m . line } ) ) ,
159+ [ ] ,
160+ )
161+ } )
128162} )
You can’t perform that action at this time.
0 commit comments