Skip to content

Commit 926b17a

Browse files
authored
[Eslint 9] Add schema declarations (#366)
Eslint 9 requires that all rules that accept options implement a `meta.schema` declaration. There are 5 rules that accept options: ``` missing-expect no-expect-in-setup-teardown no-spec-dupes no-suite-dupes prefer-toBeUndefined ``` The last one already has a `meta.schema` declaration. This change adds them for the others. Closes #365
1 parent f77738d commit 926b17a

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

lib/rules/missing-expect.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
var buildName = require('../helpers/buildName')
99

10-
module.exports = function (context) {
10+
function create (context) {
1111
var allowed = context.options.length ? context.options : ['expect()', 'expectAsync()']
1212

1313
var unchecked = []
@@ -42,3 +42,15 @@ module.exports = function (context) {
4242
}
4343
}
4444
}
45+
46+
module.exports = {
47+
meta: {
48+
schema: {
49+
type: 'array',
50+
items: {
51+
type: 'string'
52+
}
53+
}
54+
},
55+
create
56+
}

lib/rules/no-expect-in-setup-teardown.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
var buildName = require('../helpers/buildName')
99

10-
module.exports = function (context) {
10+
function create (context) {
1111
var allowed = context.options.length ? context.options : ['expect()', 'expectAsync()']
1212
var setupRegexp = /^(before|after)(Each|All)$/
1313

@@ -42,3 +42,12 @@ module.exports = function (context) {
4242
}
4343
}
4444
}
45+
46+
var missingExpect = require('./missing-expect')
47+
48+
module.exports = {
49+
meta: {
50+
schema: missingExpect.meta.schema
51+
},
52+
create
53+
}

lib/rules/no-spec-dupes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@ var checkedBlocks = [
1313
'it'
1414
]
1515

16-
module.exports = require('../helpers/no-dupes')('spec', branchBlocks, checkedBlocks)
16+
var noDupes = require('../helpers/no-dupes')
17+
var create = noDupes('spec', branchBlocks, checkedBlocks)
18+
19+
module.exports = {
20+
meta: {
21+
schema: create.schema
22+
},
23+
create
24+
}

lib/rules/no-suite-dupes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@ var checkedBlocks = [
1313
'describe'
1414
]
1515

16-
module.exports = require('../helpers/no-dupes')('suite', branchBlocks, checkedBlocks)
16+
var noDupes = require('../helpers/no-dupes')
17+
var create = noDupes('suite', branchBlocks, checkedBlocks)
18+
19+
module.exports = {
20+
meta: {
21+
schema: create.schema
22+
},
23+
create
24+
}

0 commit comments

Comments
 (0)