From 3a13ee52696dffabf9f34824ee102fcd193e95ca 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 d21ee2fd8c..a57bade343 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'; @@ -414,3 +414,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, + }), + ], + }); + } + } +});