Skip to content

jsx-indent with tabs fails to error/fix #1057

Closed
@kentcdodds

Description

Here's a repo that demonstrates this issue.

Versions:

  • eslint: 3.14.1
  • eslint-plugin-react: 6.9.0

Config:

{
  "plugins": [
    "react"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "react/jsx-indent": ["error", "tab"],
    "indent": ["error", "tab"],
  }
}

Input:

const React = require('react')
module.exports = MyComponent

function MyComponent(props) {
  return (
    <div
      className="foo-bar"
      id="thing"
    >
      Hello world!
    </div>
  )
}

lint output:

<path>/jsx-indent-bug/index.js
  5:3  error  Expected indentation of 1 tab but found 2 spaces     indent
  6:5  error  Expected indentation of 1 tab character but found 0  react/jsx-indent

--fixed file:

const React = require('react')
module.exports = MyComponent

function MyComponent(props) {
	return (
		<div
      className="foo-bar"
      id="thing"
    >
      Hello world!
    </div>
	)
}

After the --fix, there are no more linting errors. However this is clearly not indenting lines 7-11 properly.

I'll start working on a PR. I'm pretty sure I can make a failing test, but I'm not certain how I'd fix the issue. Any tips appreciated!

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions