Skip to content

Parser should ignore lines with hashbangs #161

Closed as not planned
Closed as not planned
@silverwind

Description

@silverwind

Parsing a file with hashbang/shebang (#! in the first line) like

#!/usr/bin/env node
console.info('hello world');

results in a parser error with this parser:

Error while parsing /file.js

Line 1, column 2: Unexpected character '!'
`parseForESLint` from parser `/file.js` is invalid and will just be ignored

eslint's own parser handles this by ignoring files starting with hashbang:

https://github.com/eslint/eslint/blob/b93af98b3c417225a027cabc964c38e779adb945/lib/linter/linter.js#L779

Also, FWIW, there is a stage 3 ECMAScript proposal to make hashbangs part of the language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions