diff --git a/package.json b/package.json index c31e349088..c041fbeee8 100644 --- a/package.json +++ b/package.json @@ -80,8 +80,8 @@ "@babel/eslint-parser": "^7.28.5", "@eslint/eslintrc": "^3.3.1", "@lubien/fixture-beta-package": "^1.0.0-beta.1", - "@typescript-eslint/parser": "^8.46.2", - "@typescript-eslint/types": "^8.46.2", + "@typescript-eslint/parser": "^8.48.0", + "@typescript-eslint/types": "^8.48.0", "ava": "^6.4.1", "c8": "^10.1.3", "enquirer": "^2.4.1", diff --git a/rules/prefer-node-protocol.js b/rules/prefer-node-protocol.js index d373c4070c..8b96b384f4 100644 --- a/rules/prefer-node-protocol.js +++ b/rules/prefer-node-protocol.js @@ -21,6 +21,7 @@ const create = context => { node.parent.type === 'ImportDeclaration' || node.parent.type === 'ExportNamedDeclaration' || node.parent.type === 'ImportExpression' + || node.parent.type === 'TSImportType' ) && node.parent.source === node ) @@ -37,12 +38,6 @@ const create = context => { ) && node.parent.arguments[0] === node ) - || ( - node.parent.type === 'TSLiteralType' - && node.parent.literal === node - && node.parent.parent.type === 'TSImportType' - && node.parent.parent.argument === node.parent - ) )) { return; } diff --git a/rules/prefer-string-raw.js b/rules/prefer-string-raw.js index b200ff4ab4..3e9acabf12 100644 --- a/rules/prefer-string-raw.js +++ b/rules/prefer-string-raw.js @@ -67,6 +67,8 @@ function isStringRawRestricted(node) { || (type === 'TSExternalModuleReference' && parent.expression === node) // (TypeScript) Literal type || (type === 'TSLiteralType' && parent.literal === node) + // (TypeScript) Import type + || (type === 'TSImportType' && parent.source === node) ); } diff --git a/test/prefer-string-raw.js b/test/prefer-string-raw.js index c60274c367..0e3ceec39b 100644 --- a/test/prefer-string-raw.js +++ b/test/prefer-string-raw.js @@ -139,6 +139,8 @@ test.snapshot({ String.raw`import type T = require('${TEST_STRING}');`, // (TypeScript) Literal type String.raw`type T = '${TEST_STRING}';`, + // (TypeScript) Import type + String.raw`type T = import('${TEST_STRING}');`, ...keyTestsComputedIsInvalid, ...keyTestsComputedIsValid.flatMap(code => [code, toComputed(code)]), `expect(foo).toMatchInlineSnapshot('${TEST_STRING}')`,