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

react/no-arrow-function-lifecycle creating invalid code #3337

Closed
devinrhode2 opened this issue Jul 14, 2022 · 4 comments
Closed

react/no-arrow-function-lifecycle creating invalid code #3337

devinrhode2 opened this issue Jul 14, 2022 · 4 comments

Comments

@devinrhode2
Copy link

Please see this comment: prettier/eslint-plugin-prettier#65 (comment)

@devinrhode2
Copy link
Author

input:

export default class Root extends Component {
  getInitialState = () => ({
    errorImporting: null,
    errorParsing: null,
    errorUploading: null,
    file: null,
    fromExtension: false,
    importSuccess: false,
    isImporting: false,
    isParsing: false,
    isUploading: false,
    parsedResults: null,
    showLongRunningMessage: false,
  });
}

invalid output:

export default class Root extends Component {
  getInitialState() { return {
    errorImporting: null,
    errorParsing: null,
    errorUploading: null,
    file: null,
    fromExtension: false,
    importSuccess: false,
    isImporting: false,
    isParsing: false,
    isUploading: false,
    parsedResults: null,
    showLongRunningMessage: false,
  }; }); // Extra trailing paren
}

@devinrhode2
Copy link
Author

THANK YOU @ljharb this was driving me bonkers, I was convinced it was a bug related to prettier/eslint integration, but it seems isolated to eslint.

@ljharb
Copy link
Member

ljharb commented Jul 14, 2022

cc @ngtan

ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Sep 29, 2022
@ljharb ljharb closed this as completed in 2575bba Sep 30, 2022
@ljharb
Copy link
Member

ljharb commented Sep 30, 2022

The solution I came up with is a bit quick and dirty, so it probably won't work reliably for atypical forms of semicolon usage, but this should be a start, and will fix the reported issue at least :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants