I'm attempting to use optional chaining syntax in my JavaScript code like this:
let foo = bar?.property;
When I run eslint directly on my JS files, it works without any issues.
However, when I run gulp-eslint with the same configuration, I encounter a linting error:
Parsing error: Unexpected token .
My configuration in .eslintrc.json looks like this:
{
"parserOptions": {
"ecmaVersion": 2020
}
}
This is the Gulp task I am using:
const eslint = require('gulp-eslint');
return gulp.src(['src/**/*.js'])
.pipe(eslint({ configFile: '.eslintrc.json' }))
.pipe(eslint.formatEach('compact', process.stderr))
.pipe(eslint.failAfterError());
The devDependencies I have installed are:
"devDependencies": {
"eslint": "^8.2.0",
"gulp": "4.0.2",
"gulp-eslint": "^6.0.0",
}
Is there something I'm overlooking, or is there a workaround for this issue?