Skip to content

Commit a06900c

Browse files
committed
Fix type-tests and lint
1 parent 46658ec commit a06900c

File tree

12 files changed

+98
-87
lines changed

12 files changed

+98
-87
lines changed

.eslintrc.js

+36-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
'use strict';
22

3+
const sharedTSOptions = {
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
8+
'plugin:@typescript-eslint/strict',
9+
],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['@typescript-eslint'],
12+
rules: {
13+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
14+
'@typescript-eslint/consistent-type-exports': 'error',
15+
'@typescript-eslint/consistent-type-imports': 'error',
16+
'@typescript-eslint/explicit-function-return-type': 'error',
17+
'@typescript-eslint/method-signature-style': 'error',
18+
'@typescript-eslint/no-confusing-void-expression': 'error',
19+
'@typescript-eslint/no-redundant-type-constituents': 'error',
20+
'@typescript-eslint/prefer-enum-initializers': 'error',
21+
'@typescript-eslint/prefer-readonly': 'error',
22+
'@typescript-eslint/promise-function-async': 'error',
23+
},
24+
};
25+
326
module.exports = {
427
root: true,
528
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
@@ -48,29 +71,24 @@ module.exports = {
4871
// ts files
4972
{
5073
files: ['**/*.ts'],
51-
extends: [
52-
'eslint:recommended',
53-
'plugin:@typescript-eslint/recommended',
54-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
55-
'plugin:@typescript-eslint/strict',
56-
],
57-
parser: '@typescript-eslint/parser',
5874
parserOptions: {
5975
tsconfigRootDir: __dirname,
6076
project: ['./tsconfig.json'],
6177
},
62-
plugins: ['@typescript-eslint'],
78+
...sharedTSOptions,
79+
},
80+
81+
// ts-tests files
82+
{
83+
files: ['type-tests/**/*.ts'],
84+
parserOptions: {
85+
tsconfigRootDir: __dirname,
86+
project: ['./type-tests/tsconfig.json'],
87+
},
88+
...sharedTSOptions,
6389
rules: {
64-
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
65-
'@typescript-eslint/consistent-type-exports': 'error',
66-
'@typescript-eslint/consistent-type-imports': 'error',
67-
'@typescript-eslint/explicit-function-return-type': 'error',
68-
'@typescript-eslint/method-signature-style': 'error',
69-
'@typescript-eslint/no-confusing-void-expression': 'error',
70-
'@typescript-eslint/no-redundant-type-constituents': 'error',
71-
'@typescript-eslint/prefer-enum-initializers': 'error',
72-
'@typescript-eslint/prefer-readonly': 'error',
73-
'@typescript-eslint/promise-function-async': 'error',
90+
'@typescript-eslint/no-empty-function': 'off',
91+
'@typescript-eslint/no-unused-vars': 'off',
7492
},
7593
},
7694

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ It will setup your test context the same way as `setupTest()`, and additionally:
129129
import { module, test } from 'qunit';
130130
import { setupRenderingTest } from 'ember-qunit';
131131
import { render } from '@ember/test-helpers';
132-
import hbs from 'htmlbars-inline-precompile';
132+
import { hbs } from 'ember-cli-htmlbars';
133133

134134
module('GravatarImageComponent', function(hooks) {
135135
setupRenderingTest(hooks);

addon-test-support/adapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Ember from 'ember';
55

66
import * as QUnit from 'qunit';
77

8-
import { isRecord, isTest } from 'ember-qunit/test-support/types/util';
8+
import { isRecord, isTest } from './types/util';
99

1010
function unhandledRejectionAssertion(current: unknown, error: unknown): void {
1111
let message: string;

addon-test-support/index.ts

+25-14
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,9 @@ export function setupTest(
112112
* Once invoked, all subsequent hooks.beforeEach and test invocations will
113113
* have access to the following:
114114
* * All of the methods / properties listed for `setupTest`
115-
* * this.render(...) - Renders the provided template snippet returning a
116-
* promise that resolves once rendering has completed
117-
* * An importable render function that de-sugars into this.render will be
118-
* the default output of blueprints
115+
* * An importable render function
119116
* * this.element - Returns the native DOM element representing the element
120117
* that was rendered via this.render
121-
* * this.$(...) - When jQuery is present, executes a jQuery selector with
122-
* the current this.element as its root
123118
*/
124119
export function setupRenderingTest(
125120
hooks: NestedHooks,
@@ -364,30 +359,38 @@ declare global {
364359
* module's queue has emptied, it will not run this hook again.
365360
*/
366361
after<TC extends TestContext>(
367-
fn: (this: TC, assert: Assert) => void | Promise<void>
362+
fn:
363+
| ((this: TC, assert: Assert) => void)
364+
| ((this: TC, assert: Assert) => Promise<void>)
368365
): void;
369366

370367
/**
371368
* Runs after each test.
372369
*/
373370
afterEach<TC extends TestContext>(
374-
fn: (this: TC, assert: Assert) => void | Promise<void>
371+
fn:
372+
| ((this: TC, assert: Assert) => void)
373+
| ((this: TC, assert: Assert) => Promise<void>)
375374
): void;
376375

377376
/**
378377
* Runs before the first test.
379378
*/
380379
// SAFETY: this is just wildly, impossibly unsafe. QUnit cannot -- ever! --
381380
before<TC extends TestContext>(
382-
fn: (this: TC, assert: Assert) => void | Promise<void>
381+
fn:
382+
| ((this: TC, assert: Assert) => void)
383+
| ((this: TC, assert: Assert) => Promise<void>)
383384
): void;
384385

385386
/**
386387
* Runs before each test.
387388
*/
388389
// SAFETY: this is just wildly, impossibly unsafe. QUnit cannot -- ever! --
389390
beforeEach<TC extends TestContext>(
390-
fn: (this: TC, assert: Assert) => void | Promise<void>
391+
fn:
392+
| ((this: TC, assert: Assert) => void)
393+
| ((this: TC, assert: Assert) => Promise<void>)
391394
): void;
392395
}
393396

@@ -413,7 +416,9 @@ declare global {
413416
// `<template>` and local scope.
414417
test<TC extends TestContext>(
415418
name: string,
416-
callback: (this: TC, assert: Assert) => void | Promise<unknown>
419+
callback:
420+
| ((this: TC, assert: Assert) => void)
421+
| ((this: TC, assert: Assert) => Promise<void>)
417422
): void;
418423

419424
/**
@@ -438,7 +443,9 @@ declare global {
438443
// `<template>` and local scope.
439444
only<TC extends TestContext>(
440445
name: string,
441-
callback: (this: TC, assert: Assert) => void | Promise<unknown>
446+
callback:
447+
| ((this: TC, assert: Assert) => void)
448+
| ((this: TC, assert: Assert) => Promise<void>)
442449
): void;
443450

444451
/**
@@ -457,7 +464,9 @@ declare global {
457464
// `<template>` and local scope.
458465
todo<TC extends TestContext>(
459466
name: string,
460-
callback: (this: TC, assert: Assert) => void | Promise<unknown>
467+
callback:
468+
| ((this: TC, assert: Assert) => void)
469+
| ((this: TC, assert: Assert) => Promise<void>)
461470
): void;
462471

463472
/**
@@ -479,7 +488,9 @@ declare global {
479488
// `<template>` and local scope.
480489
skip<TC extends TestContext>(
481490
name: string,
482-
callback?: (this: TC, assert: Assert) => void | Promise<unknown>
491+
callback?:
492+
| ((this: TC, assert: Assert) => void)
493+
| ((this: TC, assert: Assert) => Promise<void>)
483494
): void;
484495
}
485496
}

addon-test-support/test-isolation-validation.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212

1313
import * as QUnit from 'qunit';
1414

15-
import type { Test } from 'ember-qunit/test-support/types/util';
16-
import { isTest } from 'ember-qunit/test-support/types/util';
15+
import type { Test } from './types/util';
16+
import { isTest } from './types/util';
1717

1818
/**
1919
* Detects if a specific test isn't isolated. A test is considered
@@ -34,7 +34,7 @@ export function detectIfTestNotIsolated(test: Test, message = ''): void {
3434
const { debugInfo } = getSettledState();
3535

3636
console.group(`${test.module.name}: ${test.testName}`);
37-
debugInfo?.toConsole();
37+
debugInfo.toConsole();
3838
console.groupEnd();
3939

4040
assert('detectIfTestNotIsolated called on skipped test', !test.skip);

docs/legacy.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and
1818
### Component Integration Tests
1919

2020
```js
21-
import hbs from 'htmlbars-inline-precompile';
21+
import { hbs } from 'ember-cli-htmlbars';
2222
import { test, moduleForComponent } from 'ember-qunit';
2323

2424
moduleForComponent('x-foo', {
@@ -143,8 +143,6 @@ test('It can set its child', function(assert) {
143143
## Advanced Usage
144144
### Setting the resolver
145145

146-
<!-- FIXME: setResolver is not actually exported from ember-qunit. It comes from @ember/test-helpers -->
147-
148146
```js
149147
// if you don't have a custom resolver, do it like this:
150148
setResolver(Ember.DefaultResolver.create({ namespace: App }));

docs/migration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Before:
208208

209209
```javascript
210210
import { test, moduleForComponent } from 'ember-qunit';
211-
import hbs from 'htmlbars-inline-precompile';
211+
import { hbs } from 'ember-cli-htmlbars';
212212

213213
moduleForComponent('GravatarImageComponent', {
214214
integration: true
@@ -226,7 +226,7 @@ After:
226226
import { module, test } from 'qunit';
227227
import { setupRenderingTest } from 'ember-qunit';
228228
import { render } from '@ember/test-helpers';
229-
import hbs from 'htmlbars-inline-precompile';
229+
import { hbs } from 'ember-cli-htmlbars';
230230

231231
module('GravatarImageComponent', function(hooks) {
232232
setupRenderingTest(hooks);

tests/acceptance/basic-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { module, test } from 'qunit';
22
import EmberRouter from '@ember/routing/router';
33
import Route from '@ember/routing/route';
4-
import hbs from 'htmlbars-inline-precompile';
4+
import { hbs } from 'ember-cli-htmlbars';
55
import { setupApplicationTest } from 'ember-qunit';
66
import {
77
visit,

tests/integration/setup-rendering-test-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { module, test } from 'qunit';
22
import Component from '@ember/component';
33
import { helper } from '@ember/component/helper';
4-
import hbs from 'htmlbars-inline-precompile';
4+
import { hbs } from 'ember-cli-htmlbars';
55
import { setupRenderingTest } from 'ember-qunit';
66
import { render } from '@ember/test-helpers';
77
import { setResolverRegistry } from '../helpers/resolver';

tsconfig.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
"paths": {
99
"dummy/tests/*": ["tests/*"],
1010
"dummy/*": ["tests/dummy/app/*", "app/*"],
11-
"ember-qunit": ["addon"],
12-
"ember-qunit/*": ["addon/*"],
13-
"ember-qunit/test-support": ["addon-test-support"],
14-
"ember-qunit/test-support/*": ["addon-test-support/*"],
11+
"ember-qunit": ["addon-test-support"],
12+
"ember-qunit/*": ["addon-test-support/*"],
1513
"*": ["types/*"]
1614
}
1715
},

0 commit comments

Comments
 (0)