Skip to content

Commit

Permalink
fix: fixes #1851
Browse files Browse the repository at this point in the history
  • Loading branch information
wenfangdu committed Oct 14, 2020
1 parent a00727e commit 873cfce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rules/extensions.js
@@ -1,7 +1,7 @@
import path from 'path'

import resolve from 'eslint-module-utils/resolve'
import { isBuiltIn, isExternalModule, isScoped, isScopedModule } from '../core/importType'
import { isBuiltIn, isExternalModule, isScopedModule } from '../core/importType'
import docsUrl from '../docsUrl'

const enumValues = { enum: [ 'always', 'ignorePackages', 'never' ] }
Expand Down Expand Up @@ -159,7 +159,7 @@ module.exports = {

// determine if this is a module
const isPackage = isExternalModule(importPath, context.settings)
|| isScoped(importPath)
|| isScopedModule(importPath)

if (!extension || !importPath.endsWith(`.${extension}`)) {
const extensionRequired = isUseOfExtensionRequired(extension, isPackage)
Expand Down
6 changes: 6 additions & 0 deletions tests/src/rules/extensions.js
Expand Up @@ -358,6 +358,7 @@ ruleTester.run('extensions', rule, {
import Component from './Component'
import baz from 'foo/baz'
import baw from '@scoped/baw/import'
import bav from '@/scoped/bav/import'
import express from 'express'
`,
options: [ 'ignorePackages' ],
Expand All @@ -367,6 +368,11 @@ ruleTester.run('extensions', rule, {
line: 4,
column: 31,
},
{
message: 'Missing file extension for "@/scoped/bav/import"',
line: 7,
column: 25,
},
],
}),

Expand Down

0 comments on commit 873cfce

Please sign in to comment.