Skip to content

Commit bf55339

Browse files
fix(testing): fix eslint
1 parent 4e7bb26 commit bf55339

37 files changed

+274
-234
lines changed

__mocks__/@wdio/globals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function $$(selector) {
7373
parent._length = length
7474
els.parent = parent
7575

76-
els.foundWith = "$$"
76+
els.foundWith = '$$'
7777
// Required to check length prop
7878
els.props = []
7979
els.props.length = length

eslint.config.mjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@ import wdioEslint from '@wdio/eslint'
22

33
export default wdioEslint.config([
44
{
5-
ignores: ['dist']
5+
ignores: [
6+
'lib',
7+
'types'
8+
]
69
},
710
/**
811
* custom test configuration
912
*/
1013
{
11-
files: ['tests/**/*'],
14+
files: [
15+
'test/**/*',
16+
'__mocks__/**/*'
17+
],
18+
languageOptions: {
19+
globals: {
20+
beforeAll: true,
21+
afterAll: true,
22+
afterEach: true,
23+
beforeEach: true
24+
}
25+
},
1226
rules: {
1327
'@typescript-eslint/no-require-imports': 'off',
1428
'@typescript-eslint/no-explicit-any': 'off'

jasmine.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="expect-webdriverio/types/expect-webdriverio"/>
22

3-
declare module jasmine {
3+
declare namespace jasmine {
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
interface AsyncMatchers<T, U> extends ExpectWebdriverIO.Matchers<Promise<void>, T> {}
56
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
4848
"compile": "tsc --build tsconfig.build.json",
4949
"test": "run-s test:*",
50-
"test:lint": "eslint",
50+
"test:lint": "eslint .",
5151
"test:unit": "vitest --run",
5252
"test:types": "node test-types/copy && npm run ts && npm run clean:tests",
5353
"ts": "run-s ts:*",

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ expectLib.extend = (m) => {
1717
return extend(m)
1818
}
1919

20-
expectLib.extend(wdioMatchers)
20+
type MatchersObject = Parameters<typeof expectLib.extend>[0]
21+
22+
expectLib.extend(wdioMatchers as MatchersObject)
2123
export const expect = expectLib as unknown as ExpectWebdriverIO.Expect
22-
export const getConfig = (): any => DEFAULT_OPTIONS
24+
export const getConfig = (): ExpectWebdriverIO.DefaultOptions => DEFAULT_OPTIONS
2325
export const setDefaultOptions = (options = {}): void => {
2426
Object.entries(options).forEach(([key, value]) => {
2527
if (key in DEFAULT_OPTIONS) {

src/matchers/element/toBeExisting.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export async function toExist(
2525
return result
2626
}
2727

28-
export function toBeExisting(el: WdioElementMaybePromise, options?: ExpectWebdriverIO.CommandOptions): any {
28+
export function toBeExisting(el: WdioElementMaybePromise, options?: ExpectWebdriverIO.CommandOptions) {
2929
return aliasFn.call(this, toExist, { verb: 'be', expectation: 'existing' }, el, options)
3030
}
31-
export function toBePresent(el: WdioElementMaybePromise, options?: ExpectWebdriverIO.CommandOptions): any {
31+
export function toBePresent(el: WdioElementMaybePromise, options?: ExpectWebdriverIO.CommandOptions) {
3232
return aliasFn.call(this, toExist, { verb: 'be', expectation: 'present' }, el, options)
3333
}

src/matchers/element/toHaveAttribute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ async function conditionAttr(el: WebdriverIO.Element, attribute: string) {
1212
const attr = await el.getAttribute(attribute)
1313
if (typeof attr !== 'string') {
1414
return { result: false, value: attr }
15-
} else {
16-
return { result: true, value: attr }
1715
}
16+
return { result: true, value: attr }
17+
1818
}
1919

2020
async function conditionAttrAndValue(el: WebdriverIO.Element, attribute: string, value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options: ExpectWebdriverIO.StringOptions) {

src/matchers/element/toHaveClass.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function condition(el: WebdriverIO.Element, attribute: string, value: stri
2222
return Array.isArray(value)
2323
? compareTextWithArray(t, value, options).result
2424
: compareText(t, value, options).result
25-
});
25+
})
2626

2727
return {
2828
value: actualClass,
@@ -33,7 +33,7 @@ async function condition(el: WebdriverIO.Element, attribute: string, value: stri
3333
/**
3434
* @deprecated
3535
*/
36-
export function toHaveClass(...args: any): any {
36+
export function toHaveClass(...args: unknown[]) {
3737
return toHaveElementClass.call(this || {}, ...args)
3838
}
3939

src/matchers/element/toHaveElementProperty.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
async function condition(
1212
el: WebdriverIO.Element,
1313
property: string,
14-
value?: any,
14+
value: unknown,
1515
options: ExpectWebdriverIO.StringOptions = DEFAULT_OPTIONS
1616
) {
1717
const { asString = false } = options
@@ -31,7 +31,7 @@ async function condition(
3131

3232
prop = prop.toString()
3333

34-
return compareText(prop, value, options)
34+
return compareText(prop, value as string | RegExp | ExpectWebdriverIO.PartialMatcher, options)
3535
}
3636

3737
export async function toHaveElementProperty(
@@ -50,7 +50,7 @@ export async function toHaveElementProperty(
5050
})
5151

5252
let el = await received?.getElement()
53-
let prop: any
53+
let prop: unknown
5454
const pass = await waitUntil(
5555
async () => {
5656
const result = await executeCommand.call(this, el, condition, options, [property, value])

src/matchers/element/toHaveSize.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { DEFAULT_OPTIONS } from '../../constants.js';
2-
import type { WdioElementMaybePromise } from '../../types.js';
1+
import { DEFAULT_OPTIONS } from '../../constants.js'
2+
import type { WdioElementMaybePromise } from '../../types.js'
33
import {
44
compareObject,
55
enhanceError,
66
executeCommand,
77
waitUntil,
88
wrapExpectedWithArray,
9-
} from '../../utils.js';
9+
} from '../../utils.js'
1010

11-
async function condition(el: WebdriverIO.Element, size: { height: number; width: number }): Promise<any> {
11+
async function condition(el: WebdriverIO.Element, size: { height: number; width: number }) {
1212
const actualSize = await el.getSize()
1313

1414
return compareObject(actualSize, size)

0 commit comments

Comments
 (0)