eslint parser flags import (in import.meta.url) as an error
See original GitHub issueTell us about your environment
vscode information Version: 1.39.2 Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390 Date: 2019-10-15T15:33:40.634Z Electron: 4.2.10 Chrome: 69.0.3497.128 Node.js: 10.11.0 (vscode is apparently running a different node than the shell) V8: 6.9.427.31-electron.0 OS: Linux x64 4.15.0-66-generic
eslint is executed via: Dirk Baeumer’s vscode eslint extension: https://github.com/Microsoft/vscode-eslint
System configuration: Node version: v12.11.1 npm version: v6.12.1 Local ESLint version: Not found Global ESLint version: v6.6.0 (Currently used)
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
env:
node: true
es6: true
mocha: true # NOTE: Not all tests pass eslint.
parserOptions:
ecmaVersion: 2018
rules:
# Possible Errors
# http://eslint.org/docs/rules/#possible-errors
comma-dangle: [2, "only-multiline"]
no-control-regex: 2
no-debugger: 2
no-console: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast : 2
no-extra-parens: [2, "functions"]
no-extra-semi: 2
no-func-assign: 2
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-negated-in-lhs: 2
no-obj-calls: 2
no-proto: 2
no-unexpected-multiline: 2
no-unreachable: 2
use-isnan: 2
valid-typeof: 2
no-var: 2
object-curly-spacing: [2, "never"]
# Best Practices
# http://eslint.org/docs/rules/#best-practices
no-fallthrough: 2
no-octal: 2
no-redeclare: 2
no-self-assign: 2
no-unused-labels: 2
# Strict Mode
# http://eslint.org/docs/rules/#strict-mode
strict: [2, "global"]
# Variables
# http://eslint.org/docs/rules/#variables
no-delete-var: 2
no-undef: 2
#no-unused-vars: [2, {"args": "after-used"}]
no-unused-vars: [2, {"args": "none"}] # don't complain about unused args
# Node.js and CommonJS
# http://eslint.org/docs/rules/#nodejs-and-commonjs
no-mixed-requires: 2
no-new-require: 2
no-path-concat: 2
no-restricted-modules: [2, "sys", "_linklist"]
# Stylistic Issues
# http://eslint.org/docs/rules/#stylistic-issues
comma-spacing: 2
eol-last: 2
indent: [2, 2, {SwitchCase: 1}]
keyword-spacing: 2
max-len: [2, 100, 2, {ignoreComments: true, ignoreStrings: true, ignoreTemplateLiterals: true}]
new-parens: 2
no-mixed-spaces-and-tabs: 2
no-multiple-empty-lines: [2, {max: 2}]
no-trailing-spaces: 2
quotes: [2, "single", "avoid-escape"]
# semi: 2
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "always"]
# space-in-parens: [2, "never"]
space-infix-ops: 2
space-unary-ops: 2
# ECMAScript 6
# http://eslint.org/docs/rules/#ecmascript-6
# arrow-parens: [2, "always"]
arrow-spacing: [2, {"before": true, "after": true}]
constructor-super: 2
no-class-assign: 2
# no-confusing-arrow: [2, {"allowParens": true}]
no-const-assign: 2
no-dupe-class-members: 2
no-new-symbol: 2
no-this-before-super: 2
prefer-const: 2
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import {createRequire} from 'module';
const require = createRequire(import.meta.url);
What did you expect to happen?
no error flagged from referring to import.meta.url
What actually happened? Please include the actual, raw output from ESLint. (parsing error unexpected token: import)
Are you willing to submit a pull request to fix this bug? if someone points me at the appropriate parsing code i’ll give it a try.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
import.meta
is already in stage 3 and is implemented by all modern browsers except edge as well as node.It notably replaces
__dirname
and__filename
in native es modules in node. Meaning that if you want to get these values in a module you must useimport.meta
.It is indeed annoying that the only reason to pull in babel as a dev dependency is because eslint is unable to parse
import.meta
.I do want to note that our policy is to update core rules to not crash. Parser errors are not included in this.