Skip to content

Commit 9c6f98e

Browse files
authored
chore(dev-infra): enable eslint rule @typescript-eslint/prefer-ts-expect-error (#1677)
1 parent be32e7b commit 9c6f98e

5 files changed

Lines changed: 48 additions & 46 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ module.exports = {
155155
default: 'array',
156156
},
157157
],
158-
'@typescript-eslint/ban-ts-ignore': 'off',
159158
'@typescript-eslint/ban-types': [
160159
'error',
161160
{
@@ -229,6 +228,7 @@ module.exports = {
229228
'@typescript-eslint/prefer-function-type': 'error',
230229
'@typescript-eslint/prefer-namespace-keyword': 'error',
231230
'@typescript-eslint/prefer-readonly': 'error',
231+
'@typescript-eslint/prefer-ts-expect-error': 'error',
232232
'@typescript-eslint/restrict-template-expressions': 'off',
233233
'@typescript-eslint/require-await': 'off',
234234
'@typescript-eslint/triple-slash-reference': [

e2e/__cases__/hoisting/enable-automock/enable-automock.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import hello from './enable-automock'
44

55
test('original implementation', () => {
66
// now we have the mocked implementation,
7-
// @ts-ignore
7+
// @ts-expect-error
88
expect(hello._isMockFunction).toBeTruthy()
99
})

e2e/__tests__/__snapshots__/hoisting.test.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ exports[`Hoisting jest.enableAutomock() should pass using template "default": io
191191
var enable_automock_1 = require("./enable-automock");
192192
test('original implementation', function () {
193193
// now we have the mocked implementation,
194-
// @ts-ignore
194+
// @ts-expect-error
195195
expect(enable_automock_1.default._isMockFunction).toBeTruthy();
196196
});
197-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vZW5hYmxlLWF1dG9tb2NrLnNwZWMudHMiLCJtYXBwaW5ncyI6Ijs7QUFBQSxJQUFJLENBQUMsY0FBYyxFQUFFLENBQUE7QUF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vY2soKVxuXG5pbXBvcnQgaGVsbG8gZnJvbSAnLi9lbmFibGUtYXV0b21vY2snXG5cbnRlc3QoJ29yaWdpbmFsIGltcGxlbWVudGF0aW9uJywgKCkgPT4ge1xuICAvLyBub3cgd2UgaGF2ZSB0aGUgbW9ja2VkIGltcGxlbWVudGF0aW9uLFxuICAvLyBAdHMtZXhwZWN0LWVycm9yXG4gIGV4cGVjdChoZWxsby5faXNNb2NrRnVuY3Rpb24pLnRvQmVUcnV0aHkoKVxufSlcbiJdLCJ2ZXJzaW9uIjozfQ==
198198
===[ INLINE SOURCE MAPS ]=======================================================
199199
file: <cwd>/enable-automock.spec.ts
200200
mappings: >-
201-
;;AAAA,IAAI,CAAC,cAAc,EAAE,CAAA;AAErB,qDAAqC;AAErC,IAAI,CAAC,yBAAyB,EAAE;IAC9B,yCAAyC;IACzC,aAAa;IACb,MAAM,CAAC,yBAAK,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,CAAA;AAC5C,CAAC,CAAC,CAAA
201+
;;AAAA,IAAI,CAAC,cAAc,EAAE,CAAA;AAErB,qDAAqC;AAErC,IAAI,CAAC,yBAAyB,EAAE;IAC9B,yCAAyC;IACzC,mBAAmB;IACnB,MAAM,CAAC,yBAAK,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,CAAA;AAC5C,CAAC,CAAC,CAAA
202202
names: []
203203
sources:
204204
- <cwd>/enable-automock.spec.ts
@@ -210,7 +210,7 @@ exports[`Hoisting jest.enableAutomock() should pass using template "default": io
210210
211211
test('original implementation', () => {
212212
// now we have the mocked implementation,
213-
// @ts-ignore
213+
// @ts-expect-error
214214
expect(hello._isMockFunction).toBeTruthy()
215215
})
216216
version: 3
@@ -258,10 +258,10 @@ exports[`Hoisting jest.enableAutomock() should pass using template "with-babel-7
258258
259259
test('original implementation', function () {
260260
// now we have the mocked implementation,
261-
// @ts-ignore
261+
// @ts-expect-error
262262
expect(enable_automock_1.default._isMockFunction).toBeTruthy();
263263
});
264-
//# source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wic291cmNlcyI6WyI8Y3dkPi9lbmFibGUtYXV0b21vY2suc3BlYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJqZXN0LmVuYWJsZUF1dG9tb2NrKClcblxuaW1wb3J0IGhlbGxvIGZyb20gJy4vZW5hYmxlLWF1dG9tb2NrJ1xuXG50ZXN0KCdvcmlnaW5hbCBpbXBsZW1lbnRhdGlvbicsICgpID0+IHtcbiAgLy8gbm93IHdlIGhhdmUgdGhlIG1vY2tlZCBpbXBsZW1lbnRhdGlvbixcbiAgLy8gQHRzLWV4cGVjdC1lcnJvclxuICBleHBlY3QoaGVsbG8uX2lzTW9ja0Z1bmN0aW9uKS50b0JlVHJ1dGh5KClcbn0pXG4iXSwidmVyc2lvbiI6M30=
265265
===[ INLINE SOURCE MAPS ]=======================================================
266266
mappings: >-
267267
;;AAAA,cAAK,cAAL;;;;;;;;;;;;;;;;AAEA,IAAA,iBAAA,GAAA,OAAA,CAAA,mBAAA,CAAA;;AAEA,IAAI,CAAC,yBAAD,EAA4B,YAAA;AAC9B;AACA;AACA,EAAA,MAAM,CAAC,iBAAA,CAAA,OAAA,CAAM,eAAP,CAAN,CAA8B,UAA9B;AACD,CAJG,CAAJ
@@ -276,7 +276,7 @@ exports[`Hoisting jest.enableAutomock() should pass using template "with-babel-7
276276
277277
test('original implementation', () => {
278278
// now we have the mocked implementation,
279-
// @ts-ignore
279+
// @ts-expect-error
280280
expect(hello._isMockFunction).toBeTruthy()
281281
})
282282
version: 3
@@ -324,10 +324,10 @@ exports[`Hoisting jest.enableAutomock() should pass using template "with-babel-7
324324
325325
test('original implementation', function () {
326326
// now we have the mocked implementation,
327-
// @ts-ignore
327+
// @ts-expect-error
328328
expect(enable_automock_1.default._isMockFunction).toBeTruthy();
329329
});
330-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6Ijs7QUFBQSxjQUFLLGNBQUw7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFQSxJQUFBLGlCQUF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aW1wb3J0IGhlbGxvIGZyb20gJy4vZW5hYmxlLWF1dG9tb2NrJ1xuXG50ZXN0KCdvcmlnaW5hbCBpbXBsZW1lbnRhdGlvbicsICgpID0+IHtcbiAgLy8gbm93IHdlIGhhdmUgdGhlIG1vY2tlZCBpbXBsZW1lbnRhdGlvbixcbiAgLy8gQHRzLWV4cGVjdC1lcnJvclxuICBleHBlY3QoaGVsbG8uX2lzTW9ja0Z1bmN0aW9uKS50b0JlVHJ1dGh5KClcbn0pXG4iXSwidmVyc2lvbiI6M30=
331331
===[ INLINE SOURCE MAPS ]=======================================================
332332
mappings: >-
333333
;;AAAA,cAAK,cAAL;;;;;;;;;;;;;;;;AAEA,IAAA,iBAAA,GAAA,OAAA,CAAA,mBAAA,CAAA;;AAEA,IAAI,CAAC,yBAAD,EAA4B,YAAA;AAC9B;AACA;AACA,EAAA,MAAM,CAAC,iBAAA,CAAA,OAAA,CAAM,eAAP,CAAN,CAA8B,UAA9B;AACD,CAJG,CAAJ
@@ -342,7 +342,7 @@ exports[`Hoisting jest.enableAutomock() should pass using template "with-babel-7
342342
343343
test('original implementation', () => {
344344
// now we have the mocked implementation,
345-
// @ts-ignore
345+
// @ts-expect-error
346346
expect(hello._isMockFunction).toBeTruthy()
347347
})
348348
version: 3

e2e/__tests__/hoisting.test.ts

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
import { allValidPackageSets } from '../__helpers__/templates'
22
import { configureTestCase } from '../__helpers__/test-case'
33

4-
describe('Hoisting jest.mock() & jest.unmock()', () => {
5-
const testCase = configureTestCase('hoisting/mock-unmock', {
6-
writeIo: true,
7-
})
4+
describe('Hoisting', () => {
5+
describe('jest.mock() & jest.unmock()', () => {
6+
const testCase = configureTestCase('hoisting/mock-unmock', {
7+
writeIo: true,
8+
})
89

9-
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
10-
it(testLabel, () => {
11-
const result = runTest()
12-
expect(result.status).toBe(0)
13-
expect(result).toMatchSnapshot('output-mockUnmock')
14-
expect(result.ioFor('mock-unmock.spec.ts')).toMatchSnapshot('io-mockUnmock')
10+
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
11+
it(testLabel, () => {
12+
const result = runTest()
13+
expect(result.status).toBe(0)
14+
expect(result).toMatchSnapshot('output-mockUnmock')
15+
expect(result.ioFor('mock-unmock.spec.ts')).toMatchSnapshot('io-mockUnmock')
16+
})
1517
})
1618
})
17-
})
1819

19-
describe('Hoisting jest.enableAutomock()', () => {
20-
const testCase = configureTestCase('hoisting/enable-automock', { writeIo: true })
20+
describe('jest.enableAutomock()', () => {
21+
const testCase = configureTestCase('hoisting/enable-automock', { writeIo: true })
2122

22-
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
23-
it(testLabel, () => {
24-
const result = runTest()
25-
expect(result.status).toBe(0)
26-
expect(result).toMatchSnapshot('output-enableAutomock')
27-
expect(result.ioFor('enable-automock.spec.ts')).toMatchSnapshot('io-enableAutomock')
23+
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
24+
it(testLabel, () => {
25+
const result = runTest()
26+
expect(result.status).toBe(0)
27+
expect(result).toMatchSnapshot('output-enableAutomock')
28+
expect(result.ioFor('enable-automock.spec.ts')).toMatchSnapshot('io-enableAutomock')
29+
})
2830
})
2931
})
30-
})
3132

32-
describe('Hoisting jest.disableAutomock()', () => {
33-
const testCase = configureTestCase('hoisting/disable-automock', {
34-
writeIo: true,
35-
jestConfig: {
36-
automock: true,
37-
}
38-
})
33+
describe('jest.disableAutomock()', () => {
34+
const testCase = configureTestCase('hoisting/disable-automock', {
35+
writeIo: true,
36+
jestConfig: {
37+
automock: true,
38+
}
39+
})
3940

40-
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
41-
it(testLabel, () => {
42-
const result = runTest()
43-
expect(result.status).toBe(0)
44-
expect(result).toMatchSnapshot('output-disableAutomock')
45-
expect(result.ioFor('disable-automock.spec.ts')).toMatchSnapshot('io-disableAutomock')
41+
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
42+
it(testLabel, () => {
43+
const result = runTest()
44+
expect(result.status).toBe(0)
45+
expect(result).toMatchSnapshot('output-disableAutomock')
46+
expect(result.ioFor('disable-automock.spec.ts')).toMatchSnapshot('io-disableAutomock')
47+
})
4648
})
4749
})
4850
})

src/compiler/compiler-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function cacheResolvedModules(
2828
logger: Logger,
2929
): void {
3030
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
31-
// @ts-ignore
31+
// @ts-expect-error
3232
const importReferences = program.getSourceFile(fileName)!.imports
3333
/**
3434
* Ugly trick while waiting for https://github.com/microsoft/TypeScript/issues/33994

0 commit comments

Comments
 (0)