zeKoko
zeKoko

Reputation: 437

ESLint Parsing Error via Webpack as a preLoader: The keyword 'import' is reserved

I know this has been asked before, and suggestions have been to use babel to transpile code, but I am running eslint to lint my code before transpilation via webpack, but I am getting:

Parsing error: The keyword 'import' is reserved

Does anyone know of a way in which I can use the import/export syntax and run eslint?

The following is my webpack config, and eslintrc.json file:

preLoaders: [
   {
   test: /\.jsx?$/,
   loader: 'eslint-loader',
   exclude: /node_modules/
   }
],

{
  "parser": "babel-eslint",
  "plugins": ["react"],
  "extends": ["standard", "standard-react"]
}

Thank you

Upvotes: 1

Views: 2902

Answers (1)

zeKoko
zeKoko

Reputation: 437

Got it working, had to add the following to my webpack config:

eslint: {
    configFile: './.eslintrc'
  }

And the .eslintrc:

{
  "parser": "babel-eslint",

  "env": {
    "browser": true,
    "node": true,
    "es6": true
  },

  "plugins": ["react"],

  "extends": ["standard", "standard-react"],

  "ecmaFeatures": { "jsx": true }
}

Upvotes: 1

Related Questions