Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not auto fix react/jsx-indent problem #628

Closed
rrandom opened this issue Jun 8, 2016 · 6 comments
Closed

Could not auto fix react/jsx-indent problem #628

rrandom opened this issue Jun 8, 2016 · 6 comments
Assignees

Comments

@rrandom
Copy link

rrandom commented Jun 8, 2016

144:17 error Expected indentation of 14 space characters but found 16 react/jsx-indent

code:

            <Breadcrumb.Item>
                <Link to="/">山西省</Link>
            </Breadcrumb.Item>

and: .eslintrc

{
  "extends": "eslint-config-airbnb",
  "parser": "babel-eslint",
  "rules": {
    "spaced-comment": [1],
    "no-unused-vars": [1],
    "no-empty": [1],
    "react/wrap-multilines": [1],
    "react/no-multi-comp": [1],
    "no-constant-condition": [1],
    "react/jsx-no-bind": [1],
    "react/prop-types": [1],
    "arrow-body-style": [0],
    "react/prefer-stateless-function": [1],
    "semi": [1],
    "no-param-reassign": 0,
  },
  "ecmaFeatures": {
    "experimentalObjectRestSpread": true
  }
}

package.json:

  "scripts": {
    "lint": "eslint --ext .js,.jsx src",
    "lintf": "eslint --ext .js,.jsx src --fix",
  }

All package related to eslint in devDependencies in package.json:

    "eslint": "^2.7.0",
    "eslint-config-airbnb": "^9.0.1",
    "eslint-plugin-import": "^1.8.1",
    "eslint-plugin-jsx-a11y": "^1.3.0",
    "eslint-plugin-react": "^5.1.1",

After running npm run lintf, the error shows and the code stays the same. --fix dit not auto fix react/jsx-indent.
Any Ideas?

@ljharb
Copy link
Member

ljharb commented Jun 8, 2016

Most rules in general don't have autofixers, so that's not a surprise.

This seems like it might be a bug with components referenced off an object (ie, with a dot).

@rrandom
Copy link
Author

rrandom commented Jun 8, 2016

Yes, but in https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md it says that could be fixable. Wich confuse me

@ljharb
Copy link
Member

ljharb commented Jun 8, 2016

Ah, good point.

@rrandom can you try the same example but use English (specifically, ASCII) text as the element contents? I'm wondering if it's a unicode code point issue (versus code units)

@rrandom
Copy link
Author

rrandom commented Jun 8, 2016

@ljharb Sadly, the same. Could not fix.

import React, { PropTypes } from 'react';

const Routes = ({ history }) => {
  return (
  <div>Hello, world! </div>
  );
};
export default Routes;

even with single file

.\node_modules\.bin\eslint src\routes\index.jsx --fix

  3:19  warning  'history' is defined but never used                     no-unused-vars
  5:3   error    Expected indentation of 4 space characters but found 2  react/jsx-indent

✖ 2 problems (1 error, 1 warning)

@yannickcr
Copy link
Member

It is the jsx-indent-props rule that is fixable, not the jsx-ident rule (yet)

@kentcdodds
Copy link
Contributor

This may be fixed now...

@ljharb ljharb closed this as completed Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants