Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow importing AVA as anyTest in TypeScript files #294

Merged
merged 4 commits into from
Feb 16, 2020

Conversation

pvdlg
Copy link
Contributor

@pvdlg pvdlg commented Feb 15, 2020

Fix #293

Change use-test to allow importing AVA as anyTest in order to account for the example in Typing t.context.

This change could be further improved by making sure that when AVA is imported as any it is assigned to a variable name test, e.g:

const test = anyTest as TestInterface<{foo: string}>;

In other words the following should be invalid:

import anyTest, {TestInterface} from 'ava';

const myTest = anyTest as TestInterface<{foo: string}>;

That's important because some other rules depends on the AVA object to be named test. However, the change in that PR is still better than forcing users to disable the rules.

Implementing such validation is beyond my knowledge of ESLint aPI though...

@novemberborn
Copy link
Member

Implementing such validation is beyond my knowledge of ESLint aPI though...

I've opened #295 to track.

@novemberborn novemberborn changed the title Allow to import AVA as anyTest in TypeScript files Allow importing AVA as anyTest in TypeScript files Feb 16, 2020
@novemberborn novemberborn merged commit 524594d into avajs:master Feb 16, 2020
@turadg
Copy link

turadg commented Mar 31, 2022

JSDoc in .js files is an increasingly popular way to use TypeScript. e.g.,

import anyTest from 'ava';
/** @type {import('ava').TestInterface<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;

Any concerns with allowing anyTest in .js too? (i.e. removing the filename constraint)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule use-test conflicting with typing of t.context
3 participants