Skip to content

Commit

Permalink
fix(no-hashbang-comment): error on files without comments (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 authored Aug 3, 2024
1 parent 2aa7169 commit a2c3992
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-hashbang-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = (context, badBrowser) => {
return {
'Program:exit' (node) {
const [comment] = sourceCode.getAllComments();
if (comment.type === 'Shebang') {
if (comment && comment.type === 'Shebang') {
context.report(node, `Hashbang comments are not supported in ${badBrowser}`)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/no-hashbang-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ruleTester.run('no-hashbang-comment', rule, {
valid: [
{code: '// Regular comment'},
{code: '/* Regular comment */'},
{code: 'noComment;'},
],
invalid: [
{
Expand Down

0 comments on commit a2c3992

Please sign in to comment.