Skip to content

Commit 354e3e5

Browse files
committed
fix(no-hashbang-comment): error on files without comments
1 parent 2aa7169 commit 354e3e5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/rules/no-hashbang-comment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = (context, badBrowser) => {
55
return {
66
'Program:exit' (node) {
77
const [comment] = sourceCode.getAllComments();
8-
if (comment.type === 'Shebang') {
8+
if (comment && comment.type === 'Shebang') {
99
context.report(node, `Hashbang comments are not supported in ${badBrowser}`)
1010
}
1111
}

test/no-hashbang-comment.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ruleTester.run('no-hashbang-comment', rule, {
99
valid: [
1010
{code: '// Regular comment'},
1111
{code: '/* Regular comment */'},
12+
{code: 'noComment;'},
1213
],
1314
invalid: [
1415
{

0 commit comments

Comments
 (0)