Commit f67d4ab8 authored by Mark Tyneway's avatar Mark Tyneway

lint: fix

parent 24cb20d4
...@@ -9,51 +9,51 @@ const checks: Array<{ ...@@ -9,51 +9,51 @@ const checks: Array<{
check: (parts: string[]) => boolean check: (parts: string[]) => boolean
error: string error: string
}> = [ }> = [
{ {
error: 'test name parts should be in camelCase', error: 'test name parts should be in camelCase',
check: (parts: string[]): boolean => { check: (parts: string[]): boolean => {
return parts.every((part) => { return parts.every((part) => {
return part[0] === part[0].toLowerCase() return part[0] === part[0].toLowerCase()
}) })
},
}, },
{ },
error: {
'test names should have either 3 or 4 parts, each separated by underscores', error:
check: (parts: string[]): boolean => { 'test names should have either 3 or 4 parts, each separated by underscores',
return parts.length === 3 || parts.length === 4 check: (parts: string[]): boolean => {
}, return parts.length === 3 || parts.length === 4
}, },
{ },
error: 'test names should begin with "test", "testFuzz", or "testDiff"', {
check: (parts: string[]): boolean => { error: 'test names should begin with "test", "testFuzz", or "testDiff"',
return ['test', 'testFuzz', 'testDiff'].includes(parts[0]) check: (parts: string[]): boolean => {
}, return ['test', 'testFuzz', 'testDiff'].includes(parts[0])
}, },
{ },
error: {
'test names should end with either "succeeds", "reverts", "fails", "works" or "benchmark[_num]"', error:
check: (parts: string[]): boolean => { 'test names should end with either "succeeds", "reverts", "fails", "works" or "benchmark[_num]"',
return ( check: (parts: string[]): boolean => {
['succeeds', 'reverts', 'fails', 'benchmark', 'works'].includes( return (
parts[parts.length - 1] ['succeeds', 'reverts', 'fails', 'benchmark', 'works'].includes(
) || parts[parts.length - 1]
(parts[parts.length - 2] === 'benchmark' && ) ||
!isNaN(parseInt(parts[parts.length - 1], 10))) (parts[parts.length - 2] === 'benchmark' &&
) !isNaN(parseInt(parts[parts.length - 1], 10)))
}, )
}, },
{ },
error: {
'failure tests should have 4 parts, third part should indicate the reason for failure', error:
check: (parts: string[]): boolean => { 'failure tests should have 4 parts, third part should indicate the reason for failure',
return ( check: (parts: string[]): boolean => {
parts.length === 4 || return (
!['reverts', 'fails'].includes(parts[parts.length - 1]) parts.length === 4 ||
) !['reverts', 'fails'].includes(parts[parts.length - 1])
}, )
}, },
] },
]
/** /**
* Script for checking that all test functions are named correctly. * Script for checking that all test functions are named correctly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment