ESLint configuration for JSX

SaroVin picture SaroVin · May 20, 2016 · Viewed 10.9k times · Source

I want configure ESLint for check my JSX files but my configuration doesn't work. What is the correct way?

.eslintrc.js:

module.exports = {
  extends: 'airbnb',
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    }
  },
  plugins: [
    'react',
  ],
  parser: 'babel-eslint'
};

Answer

Ilya Volodin picture Ilya Volodin · May 21, 2016

In order to lint JSX files configuration alone is not enough. Your configuration looks fine (although you probably don't need babel-eslint, unless you are using features that are lower than stage 4 proposal). By default ESLint will only process .js files. You have to tell it that you want to process .jsx files as well by using --ext flag on command line: eslint --ext .jsx .