Linter is not correctly using .eslintrc.js files
See original GitHub issueTell us about your environment
- ESLint Version: 4.19.1
- Node Version: 8.11.2
- npm Version: 6.1.0
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint
Please show your full configuration:
.eslintrc.js
module.export = {
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
jsx: true,
modules: true,
experimentalObjectRestSpread: true
}
},
extends: ["plugin:prettier/recommended", "airbnb"],
plugins: ["react", "jsx-a11y", "import", "prettier"],
env: {
es6: true,
browser: true,
node: true,
jest: true
},
rules: {
"react/jsx-filename-extension": [1, { extensions: [".js", ".jsx"] }]
}
};
.eslintrc
(pure json)
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
}
},
"extends": ["airbnb", "plugin:prettier/recommended"],
"plugins": ["react", "jsx-a11y", "import", "prettier"],
"env": {
"browser": true,
"node": true,
"jest": true
},
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
}
}
Configuration
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
}
},
"extends": ["airbnb", "plugin:prettier/recommended"],
"plugins": ["react", "jsx-a11y", "import", "prettier"],
"env": {
"browser": true,
"node": true,
"jest": true
},
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint. This can be reproduced by
$ create-react-app my-app
The error is showing within Visual Studio Code with the ESLint plugin and via the cli through the
$ yarn eslint src/**
where in the package.json
the eslint command is
eslint: "eslint"
What did you expect to happen? Display actual eslint errors
- no-unused-vars
- no-undef (etc…)
What actually happened? Please include the actual, raw output from ESLint. Displaying errors: Parsing error: The keyword ‘import’ is reserved Parsing error: The keyword ‘const’ is reserved
Note that this error only happened for the eslintrc.js
file and the .eslintrc
file works.
Took me a lot of trial and error to isolate that.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Hi @MFry, thanks for the issue.
When working with JS configuration files, ESLint expects the configuration to be exported according to the CommonJS specification.
This means that instead of assigning to
module.export
, you need to assign tomodule.exports
.Correct configuration:
Hope this helps!
not a contributor but i feel like taking a stab, its probably easier to just sniff all .* files and eslintrc and filter out any not supported