Skip to content

Commit

Permalink
🐛 fix file-extension-in-import for scoped packages (fixes #160)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 4, 2019
1 parent 11d2d41 commit 2f756ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/file-extension-in-import.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/file-extension-in-import.js
Expand Up @@ -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'",
Expand Down

0 comments on commit 2f756ec

Please sign in to comment.