@@ -63,20 +63,57 @@ ruleTester.run('require-meta-schema', rule, {
63
63
` ,
64
64
parserOptions : { sourceType : 'module' } ,
65
65
} ,
66
+ // Variable schema with array value.
66
67
`
67
68
const schema = [];
68
69
module.exports = {
69
70
meta: { schema },
70
71
create(context) {}
71
72
};
72
73
` ,
74
+ // Variable schema with object value.
73
75
`
74
76
const foo = {};
75
77
module.exports = {
76
78
meta: { schema: foo },
77
79
create(context) {}
78
80
};
79
81
` ,
82
+ // Variable schema with no static value.
83
+ `
84
+ module.exports = {
85
+ meta: { schema },
86
+ create(context) {}
87
+ };
88
+ ` ,
89
+ // Variable schema pointing to unknown variable chain.
90
+ `
91
+ module.exports = {
92
+ meta: { schema: baseRule.meta.schema },
93
+ create(context) {}
94
+ };
95
+ ` ,
96
+ // Schema with function call as value.
97
+ `
98
+ module.exports = {
99
+ meta: { schema: getSchema() },
100
+ create(context) {}
101
+ };
102
+ ` ,
103
+ // Schema with ternary (conditional) expression.
104
+ `
105
+ module.exports = {
106
+ meta: { schema: foo ? [] : {} },
107
+ create(context) {}
108
+ };
109
+ ` ,
110
+ // Schema with logical expression.
111
+ `
112
+ module.exports = {
113
+ meta: { schema: foo || {} },
114
+ create(context) {}
115
+ };
116
+ ` ,
80
117
`
81
118
let schema;
82
119
schema = foo ? [] : {};
@@ -296,6 +333,28 @@ schema: [] },
296
333
output : null ,
297
334
errors : [ { messageId : 'wrongType' , type : 'Identifier' , suggestions : [ ] } ] ,
298
335
} ,
336
+ {
337
+ // Schema with number literal value.
338
+ code : `
339
+ module.exports = {
340
+ meta: { schema: 123 },
341
+ create(context) {}
342
+ };
343
+ ` ,
344
+ output : null ,
345
+ errors : [ { messageId : 'wrongType' , type : 'Literal' , suggestions : [ ] } ] ,
346
+ } ,
347
+ {
348
+ // Schema with string literal value.
349
+ code : `
350
+ module.exports = {
351
+ meta: { schema: 'hello world' },
352
+ create(context) {}
353
+ };
354
+ ` ,
355
+ output : null ,
356
+ errors : [ { messageId : 'wrongType' , type : 'Literal' , suggestions : [ ] } ] ,
357
+ } ,
299
358
{
300
359
code : `
301
360
const schema = null;
0 commit comments