From caec28797f1b6ffa2b026c3df3adc57e97bbdd3a Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Sat, 11 Sep 2021 11:46:12 -0700 Subject: [PATCH] Add tests --- tests/src/rules/no-unresolved.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/src/rules/no-unresolved.js b/tests/src/rules/no-unresolved.js index 19203074e1..28f1259e44 100644 --- a/tests/src/rules/no-unresolved.js +++ b/tests/src/rules/no-unresolved.js @@ -1,6 +1,6 @@ import * as path from 'path'; -import { test, SYNTAX_CASES, testVersion } from '../utils'; +import { getTSParsers, test, SYNTAX_CASES, testVersion } from '../utils'; import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'; @@ -441,3 +441,25 @@ ruleTester.run('import() with built-in parser', rule, { })) || [], ), }); + +context('TypeScript', () => { + for (const parser of getTSParsers()) { + if (parser !== require.resolve('typescript-eslint-parser')) { + ruleTester.run('no-unresolved ignore type-only', rule, { + valid: [ + test({ + code: 'import type { JSONSchema7Type } from "@types/json-schema";', + parser, + }), + ], + invalid: [ + test({ + code: 'import { JSONSchema7Type } from "@types/json-schema";', + errors: [ "Unable to resolve path to module '@types/json-schema'." ], + parser, + }), + ], + }); + } + } +});