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-plugins and drop eslint@6 support #210

Merged
merged 10 commits into from
Feb 12, 2021
Merged

Conversation

vsumner
Copy link
Contributor

@vsumner vsumner commented Feb 11, 2021

Description

This PR updates the eslint-plugins and drops support for eslint@6.

Package Old version New version
eslint-config-prettier 6.14.0 7.2.0
eslint-plugin-jest-formatting 2.0.0 2.0.1
eslint-plugin-promise 4.2.1 4.3.1
eslint-plugin-jest 24.1.0 24.1.3
eslint-plugin-react 7.21.5 7.22.0
eslint-plugin-sort-class-members 1.8.0 1.9.0
@typescript-eslint/eslint-plugin 4.1.0 4.15.0
@typescript-eslint/parser 4.1.0 4.15.0
change-case 4.1.0 4.1.2

This PR also enables and disables new rules.

I disabled arrow-body-style and prefer-arrow-callback, because they defaulted to off before and are turned off by default in prettier-config/recommended

Changed: arrow-body-style and prefer-arrow-callback are no longer turned off by default. They only need to be turned off if you use eslint-plugin-prettier.

I 🎩 ed this by using tophat eslint-plugin ../web.
Note web has a package resolution for eslint-plugin-react that you will need to remove first.

Then I ran

dev cd web
yarn run sewing-kit lint './app/!(sections)/**/*.{ts,graphql,tsx,js}' --no-styles --no-markdown --no-graphql-fixtures --no-json --no-graphql

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • @shopify/eslint-plugin Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above (Documentation fix and Test update does not need a changelog as we do not publish a new version for these changes)

Copy link
Member

@GoodForOneFare GoodForOneFare left a comment

Choose a reason for hiding this comment

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

Added notes on potential additions / tweaks. I don't recall what our convention is for shipping without integrating new rules so I'll leave it to a proper Web Foundation dev to approve.

"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
Copy link
Member

Choose a reason for hiding this comment

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

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 turned on the ones that work out of the box. There are a few that require the project option to be set on typescript-eslint/parser that I will need to figure out in another PR.

The sort-type-union-intersection-members will need more thought. It rejects a large amount of code, but it's not clear how to "fix" it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could code mod? Example on how to fix: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md That being said could this work be done in a follow PR?

packages/eslint-plugin/package.json Show resolved Hide resolved
@@ -10,5 +10,6 @@ module.exports = {
rules: merge(require('./rules/node'), {
'no-process-env': 'off',
'no-console': 'off',
'no-useless-token-range': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

We are turning this off as stuff will break? This will make rules less performant...
https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-useless-token-range.md

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 forgot I turned this off. Nice catch.

@@ -10,6 +10,8 @@ module.exports = {
'@shopify/class-property-semi': 'off',
'@shopify/binary-assignment-parens': 'off',
'babel/semi': 'off',
'prefer-arrow-callback': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

We are doing this to support function Foo(){} over const I assume? Or as things well break?

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 documentation recommended following the defaults which is off, because we have the prettier plugin.

// Prevent usage of javascript: in URLs
'react/jsx-no-script-url': 'error',
// Prevent react contexts from taking non-stable values
'react/jsx-no-constructed-context-values': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

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

🎖️

'error',
{
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

We want people to override keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to prevent them from overriding a key. To prevent createElement fallback as seen here:
facebook/react#20031 (comment)

Copy link
Contributor

@dahukish dahukish left a comment

Choose a reason for hiding this comment

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

✅ I think as long as this passes a sweeping 🎩 in our most important consumer web then I think its gtg. Any new rules might be broken out into new PRs. 🤷

@vsumner
Copy link
Contributor Author

vsumner commented Feb 12, 2021

✅ I think as long as this passes a sweeping 🎩 in our most important consumer web then I think its gtg. Any new rules might be broken out into new PRs. 🤷

This is a major release (breaking change). Which is why I thought the new rules were ok in this.

@vsumner vsumner merged commit 8cedf8a into main Feb 12, 2021
@vsumner vsumner deleted the update-eslint-plugin-7 branch February 12, 2021 17:29
@vsumner vsumner temporarily deployed to production February 12, 2021 17:38 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants