Eslint-plugin-react: Unexpected error comes out when everything is ok (related to jsx-indent)

Created on 20 Mar 2017  路  7Comments  路  Source: yannickcr/eslint-plugin-react

This is ok and no error comes out.

    return (
      <p>
        I'm {this.state.name}
      </p>
    )

when I add any character after this like:

    return (
      <p>
        I'm {this.state.name} any string here
      </p>
    )

and the error comes out:

Expected indentation of 8 space characters but found 1. (react/jsx-indent)

my eslint config :

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true
    }
  },
  env: {
    es6: true,
    commonjs: true,
    browser: true,
  },
  extends: [
      'standard',
      'standard-react'
  ],
  plugins: [
    'react',
    'babel',
    'promise'
  ],
  'rules': {
    'arrow-parens': 0,
    'generator-star-spacing': 0,
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}

Is it a bug or something wrong with my config?

Most helpful comment

@megapctr it is not working for me

All 7 comments

Same for me, failing e.g. on the following line:
<Time fromNumber={this.state.value}/>&nbsp;<Translate for="shortHours"/>

Not sure from which version it start happening.

The version I used: ^6.10.2

Yep, seems to be counting the first group of space after a react element. (6.10.2)

<Icon name="tasks" fixedWidth /> Create Order

Gives 1

<Icon name="tasks" fixedWidth />   Create Order

Gives 3

<Icon name="tasks" fixedWidth />Create Order

Gives 0

Temporary fix: use a fixed version until the bug is fixed. 6.10.0 works fine

@megapctr it is not working for me

I have 6.10.2 version and it doesn't work

          <div className="PageCampaignEditSettingsAdExample__headRating">
            <Rating rating={rating} />
            ( {reviews} )
          </div>

Expected indentation of 12 space characters but found 1 react/jsx-indent

This is a duplicate of #1117 - thanks for the extra test cases!

Was this page helpful?
0 / 5 - 0 ratings