Fails when parser is babel-eslint and using ES6 import syntax
See original GitHub issuepackage.json:
{
"name": "eslint-test",
"version": "0.0.0",
"devDependencies": {
"babel-eslint": "^1.0.12",
"eslint": "^0.15.1",
"gulp": "^3.8.11",
"gulp-eslint": "^0.5.0"
}
}
.eslintrc:
---
parser: babel-eslint
gulpfile.js:
ar gulp = require('gulp');
var eslint = require('gulp-eslint');
gulp.task('lint', function() {
gulp.src(['index.js'])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('default', ['lint']);
index.js:
import gulp from 'gulp';
Using the eslint binary works as expected:
$ ./node_modules/.bin/eslint index.js
index.js
1:7 error gulp is defined but never used no-unused-vars
1:17 error Strings must use doublequote quotes
✖ 2 problems (2 errors, 0 warnings)
But using gulp task blows up:
$ gulp
[11:57:41] Using gulpfile ~/stuff/eslint-test/gulpfile.js
[11:57:41] Starting 'lint'...
[11:57:41] Finished 'lint' after 14 ms
[11:57:41] Starting 'default'...
[11:57:41] Finished 'default' after 12 μs
/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/escope.js:73
throw new Error(text);
^
Error
at assert (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/escope.js:73:19)
at Referencer.extend.ImportDeclaration (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/escope.js:1348:13)
at Referencer.Visitor.visit (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:109:34)
at Referencer.Visitor.visitChildren (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:88:38)
at Referencer.extend.Program (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/escope.js:1201:18)
at Referencer.Visitor.visit (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:109:34)
at Object.analyze (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/node_modules/escope/escope.js:1392:20)
at EventEmitter.module.exports.api.verify (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/node_modules/eslint/lib/eslint.js:623:35)
at verify (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/index.js:21:25)
at DestroyableTransform._transform (/Users/kentor/stuff/eslint-test/node_modules/gulp-eslint/index.js:44:18)
Issue Analytics
- State:
- Created 9 years ago
- Comments:7
Top Results From Across the Web
Error: Failed to load parser 'babel-eslint' declared in '.eslintrc'
This issue is regarding eslint not able to find babel-eslint package. But if you try to install it manually it will fix the...
Read more >ESLint - Error: Must use import to load ES Module
Run npm i from a terminal/command prompt in the folder; In .eslintrc, update the parser line "parser": "babel-eslint", to "parser": "@babel ...
Read more >babel/parser
The Babel parser (previously Babylon) is a JavaScript parser used in Babel. ... make @babel/parser attempt to guess, based on the presence of...
Read more >Language Options - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >babel-eslint
If there is an issue, first check if it can be reproduced with the regular parser or with the latest versions of eslint...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh hmm, I removed my
node_modules
directory and rannpm install
and it works now. Thanks for looking into this.for me
npm install -U -g babel-eslint
fixed it