diff --git a/lib/rules/file-extension-in-import.js b/lib/rules/file-extension-in-import.js index defb0904..623893c4 100644 --- a/lib/rules/file-extension-in-import.js +++ b/lib/rules/file-extension-in-import.js @@ -8,6 +8,7 @@ const path = require("path") const fs = require("fs") const getImportExportTargets = require("../util/get-import-export-targets") const getTryExtensions = require("../util/get-try-extensions") +const packageNamePattern = /^(?:@[^/]+\/)?[^/]+$/u /** * Get all file extensions of the files which have the same basename. @@ -69,7 +70,7 @@ module.exports = { function verify({ filePath, name, node }) { // Ignore if it's not resolved to a file or it's a bare module. - if (!filePath || !/[/\\]/u.test(name)) { + if (!filePath || packageNamePattern.test(name)) { return } diff --git a/tests/lib/rules/file-extension-in-import.js b/tests/lib/rules/file-extension-in-import.js index b7ab5a09..bc3cd551 100644 --- a/tests/lib/rules/file-extension-in-import.js +++ b/tests/lib/rules/file-extension-in-import.js @@ -32,6 +32,10 @@ new RuleTester({ filename: fixture("test.js"), code: "import 'eslint'", }, + { + filename: fixture("test.js"), + code: "import '@typescript-eslint/parser'", + }, { filename: fixture("test.js"), code: "import 'xxx'",