Not planned
Description
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:
Also, FWIW, there is a stage 3 ECMAScript proposal to make hashbangs part of the language.
Activity
[-]Parser should ignore files with hashbangs[/-][+]Parser should ignore lines with hashbangs[/+]ota-meshi commentedon Jun 23, 2022
I don't think it makes sense to use hashbangs in vue files.
silverwind commentedon Jun 23, 2022
It doesn't and I'd actually like to restrict the parser to just
.vue
files, but through the invasive way in which eslint-plugin-vue re-configures the eslint parser, this parser is used for all files including node scripts with hashbang, not just.vue
and I haven't found a way yet on how to restrict this parser.ota-meshi commentedon Jun 23, 2022
Please provide a minimal repository to reproduce the problem.
silverwind commentedon Jun 23, 2022
I already worked around the issue:
Arguably, this is how
eslint-plugin-vue
should probably do it as well, not replace the parser for all files, but only those that need it.silverwind commentedon Jun 23, 2022
If you want to reproduce:
This will reproduce until go-gitea/gitea#20113 is merged.
ota-meshi commentedon Jun 24, 2022
Your problem is with
eslint-module-utils
(eslint-plugin-import
rules).Adding
import/no-unused-modules: [0]
will work.You need to report the issue to
eslint-plugin-import
.ota-meshi commentedon Jun 24, 2022
You seem to be aware of it already.
import-js/eslint-plugin-import#1369
silverwind commentedon Jul 11, 2022
Yeah, import-js/eslint-plugin-import#2431 will fix it in
eslint-module-utils
, but I don't see that module in the dependencies ofvue-eslint-parser
, so I have my doubts whether that PR will fix the issue.