@@ -8,6 +8,8 @@
const fs = require("fs")
const getImportExportTargets = require("../util/get-import-export-targets")
const getTryExtensions = require("../util/get-try-extensions")
+const packageNamePattern = /^(?:@[^/\\]+[/\\])?[^/\\]+$/u
+const corePackageOverridePattern = /^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)[/\\]$/u
/**
* Get all file extensions of the files which have the same basename.
@@ -37,7 +39,7 @@
category: "Stylistic Issues",
recommended: false,
url:
- "https://github.com/mysticatea/eslint-plugin-node/blob/v9.0.0/docs/rules/file-extension-in-import.md",
+ "https://github.com/mysticatea/eslint-plugin-node/blob/v9.0.1/docs/rules/file-extension-in-import.md",
},
fixable: "code",
messages: {
@@ -69,7 +71,11 @@
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) ||
+ corePackageOverridePattern.test(name)
+ ) {
return
}