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

update eslint config to use v6 and updated react rule options [PLAT-22391] #35

Merged
merged 1 commit into from
Jan 7, 2020

Conversation

jacobroufa
Copy link
Contributor

When updating our use of ESLint for the Dashboard there were several react rules that required an updated format -- this PR sets us up to use a much newer version of ESLint and updates those rule formats accordingly.

@jacobroufa
Copy link
Contributor Author

What is the process for version number increment and NPM release? I would like to integrate these changes once landed into a PLAT PR for the referenced Jira ticket.

@@ -40,7 +48,7 @@ module.exports = {
'react/jsx-max-props-per-line': [0, { 'maximum': 1 }],
// Prevent usage of .bind() and arrow functions in JSX props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': 2,
'react/jsx-no-bind': [2, { 'allowArrowFunctions': true }],
Copy link
Member

@dustinsoftware dustinsoftware Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is really outdated, we should consider disabling it in a future iteration. It's also not applicable to hooks-based components since they create functions every render. It's fine as-is for now.

https://reactjs.org/docs/faq-functions.html#is-it-ok-to-use-arrow-functions-in-render-methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our conversation this morning, this is a style preference, and where it would error prior if there was a this.memberFunction.bind(this) or () => doSomething() in a component callback property, the addition of allowArrowFunctions ensures that we can do the latter and still retain the safety of the reminder to bind a class method.

// Prevent variables used in JSX to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 2,
// Prevent missing parentheses around multilines JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
'react/jsx-wrap-multilines': [2, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this may conflict with Prettier, can we disable it in favor of using whatever Prettier outputs? prettier/prettier#1009 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this conflicts -- the issue is more than two years old and was inconclusive. In my current experience there is no problem. If we consider adding prettier to this javascript project, there might be a conversation we can have at that time about where to place an appropriate rule.

// Prevent usage of setState in componentDidMount
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
'react/no-did-mount-set-state': [2, 'allow-in-func'],
'react/no-did-mount-set-state': 2,
Copy link
Member

@dustinsoftware dustinsoftware Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing some context, this seems like a change that is more restrictive? It previously allowed callback functions... jsx-eslint/eslint-plugin-react@4c167eb#diff-7363406d1b2e67feb3b50cbde0fff1caR60

Edit: Nope, I linked to outdated documentation. The rule is equivalent now to the way it was previously.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule was changed to the inverse -- disallow-in-func -- so the removal of that configuration property is equivalent with the new version of eslint.

Copy link
Member

@dustinsoftware dustinsoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems fine, not sure about the publishing process.

Copy link
Contributor Author

@jacobroufa jacobroufa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billpull let me know please if there's any more I need to do for incrementing the version and creating a new NPM release.

@billpull
Copy link
Contributor

billpull commented Jan 7, 2020

@jacobroufa looks good to me. What are your thoughts on whether this should be a 0.1.3 vs a 0.2.0? Quick search in platform shows projects are pinned to specific versions rather than a range but still wanted to double check.

@shanewwarren shanewwarren merged commit 59b559e into master Jan 7, 2020
@shanewwarren shanewwarren deleted the update-eslint branch January 7, 2020 20:53
@jacobroufa
Copy link
Contributor Author

@billpull thanks, I don't have a preference. As long as the other projects are pinned to specific versions and I can likewise do the same for Dashboard moving forward, I think that either will do.

@billpull
Copy link
Contributor

billpull commented Jan 7, 2020

@jacobroufa opted for v0.2.0 since seems like a decent gap between eslint versions and the structure of properties. #36 also updated yarn.lock which I think was missing from this PR with the devDependencies change.

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

Successfully merging this pull request may close these issues.

None yet

4 participants