Skip to content

Commit 5d51b5b

Browse files
feat(hashbang): Fix undefined path passed with eslint version < 8.40
1 parent 6dca24c commit 5d51b5b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- os: ubuntu-latest
3939
node: "18.18.0"
4040
eslint: "8.x"
41+
- os: ubuntu-latest
42+
node: "18.18.0"
43+
eslint: "8.39.0"
4144
- os: ubuntu-latest
4245
node: "20.9.0"
4346
eslint: "8.x"

lib/rules/hashbang.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ function isNodeShebang(shebang, executableName) {
4646
}
4747

4848
/**
49+
* @param {string} filePath
4950
* @param {import('eslint').Rule.RuleContext} context The rule context.
5051
* @returns {string}
5152
*/
52-
function getExpectedExecutableName(context) {
53-
const extension = path.extname(context.filename)
53+
function getExpectedExecutableName(filePath, context) {
54+
const extension = path.extname(filePath)
5455
/** @type {{ executableMap: Record<string, string> }} */
5556
const { executableMap = {} } = context.options?.[0] ?? {}
5657

@@ -166,7 +167,7 @@ module.exports = {
166167
const needsShebang =
167168
isExecutable.ignored === true ||
168169
isBinFile(convertedAbsolutePath, packageJson?.bin, packageDirectory)
169-
const executableName = getExpectedExecutableName(context)
170+
const executableName = getExpectedExecutableName(filePath, context)
170171
const info = getShebangInfo(sourceCode)
171172

172173
return {

0 commit comments

Comments
 (0)