From cc7de4af9f692d7b32c98ee1d6818b0965baacf5 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..4890984e32 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 "json-schema";', + parser, + }), + ], + invalid: [ + test({ + code: 'import { JSONSchema7Type } from "json-schema";', + errors: [ "Unable to resolve path to module 'json-schema'." ], + parser, + }), + ], + }); + } + } +});