Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Upgrade eslint to 4.7.0 & update rules #41

Merged
merged 12 commits into from
Sep 19, 2017
Merged

Upgrade eslint to 4.7.0 & update rules #41

merged 12 commits into from
Sep 19, 2017

Conversation

ismail-syed
Copy link
Contributor

@ismail-syed ismail-syed commented Sep 18, 2017

  • Updated eslint to 4.7.0
  • Added missing rules from previous eslint releases
  • Updated out of date plugins as per david-dm listing

Rules descriptions tagged with <FEEDBACK> could use some discussion/feedback.

@@ -75,4 +75,6 @@ module.exports = {
'import/max-dependencies': 'off',
// Forbid unassigned imports
'import/no-unassigned-import': 'off',
// Forbid anonymous values as default exports <FEEDBACK>
'import/no-anonymous-default-export': 'off',
Copy link
Contributor Author

@ismail-syed ismail-syed Sep 18, 2017

Choose a reason for hiding this comment

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

Rule docs

Thoughts on this, IIRC I've seen our code export defaults before. Are there any specific types we should explicitly error?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can turn this on, we prefer named functions anyways, and exporting literals is a pretty uncommon case.

@@ -7,6 +7,8 @@ module.exports = {
'global-require': 'off',
// Enforces error handling in callbacks
'handle-callback-err': ['warn', '^.*(e|E)rr(or)?$'],
// disallow use of the Buffer() constructor
'no-buffer-constructor': 'error',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1,8 +1,12 @@
module.exports = {
// General

// Enforces consistent naming for boolean props <FEEDBACK>
'react/boolean-prop-naming': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems useful but could cause some frustrations adopting in a large code base. Doesn't seem to have a fixer either.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md

Copy link
Member

Choose a reason for hiding this comment

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

It would be cool if we could do the opposite of the default (never start with is/ has), as this is our standard.

Copy link
Contributor Author

@ismail-syed ismail-syed Sep 18, 2017

Choose a reason for hiding this comment

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

What the reasoning behind that being our standard?

Copy link
Member

Choose a reason for hiding this comment

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

🤷‍♂️ it's just kind of what we landed on, it's consistent with our Ruby components and it avoids some kind of unnecessary duplication from my perspective

@@ -129,6 +135,8 @@ module.exports = {
'operator-linebreak': ['warn', 'after', {overrides: {'?': 'before', ':': 'before'}}],
// Enforce padding within blocks
'padded-blocks': 'off',
// require or disallow padding lines between statements <FEEDBACK>
'padding-line-between-statements': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rule has lots of config options: https://eslint.org/docs/rules/padding-line-between-statements
I'd say just keep it off.

Copy link
Member

@lemonmade lemonmade left a comment

Choose a reason for hiding this comment

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

Looks great, left some comments but Im in agreement on almost everything

@@ -75,4 +75,6 @@ module.exports = {
'import/max-dependencies': 'off',
// Forbid unassigned imports
'import/no-unassigned-import': 'off',
// Forbid anonymous values as default exports <FEEDBACK>
'import/no-anonymous-default-export': 'off',
Copy link
Member

Choose a reason for hiding this comment

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

I think we can turn this on, we prefer named functions anyways, and exporting literals is a pretty uncommon case.

// enforce “for” loop update clause moving the counter in the right direction.
'for-direction': 'error',
// enforce return statements in getters <FEEDBACK>
'getter-return': ['error', {'allowImplicit': true}],
Copy link
Member

Choose a reason for hiding this comment

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

No need for the quotes on allowImplicit, and 👍

@@ -1,8 +1,12 @@
module.exports = {
// General

// Enforces consistent naming for boolean props <FEEDBACK>
'react/boolean-prop-naming': 'off',
Copy link
Member

Choose a reason for hiding this comment

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

It would be cool if we could do the opposite of the default (never start with is/ has), as this is our standard.

@@ -78,6 +88,8 @@ module.exports = {
'react/jsx-boolean-value': 'warn',
// Validate closing bracket location in JSX
'react/jsx-closing-bracket-location': ['warn', {location: 'tag-aligned'}],
// Validate closing tag location in JSX
'react/jsx-closing-tag-location': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

I think we want line-aligned for the option here

@@ -1,8 +1,12 @@
// see http://eslint.org/docs/rules/#stylistic-issues

module.exports = {
// enforce linebreaks after opening and before closing array brackets <FEEDBACK>
'array-bracket-newline': ['error', {'multiline': true}],
Copy link
Member

Choose a reason for hiding this comment

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

No need for quotes when names are valid identifiers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disabling this rule, it's not behaving as expected, or maybe I'm misunderstanding it.

Lint errors show that there should be no linebreak when we specify multiline: true.
https://circleci.com/gh/Shopify/eslint-plugin-shopify/144

package.json Outdated
@@ -58,18 +58,18 @@
"eslint": "<5 >=4.3.0"
Copy link
Member

Choose a reason for hiding this comment

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

I think we need this to be >=4.7.0 now

@@ -1,8 +1,12 @@
// see http://eslint.org/docs/rules/#stylistic-issues

module.exports = {
// enforce linebreaks after opening and before closing array brackets
'array-bracket-newline': 'off',
Copy link
Contributor Author

@ismail-syed ismail-syed Sep 18, 2017

Choose a reason for hiding this comment

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

Disabled this, I misunderstood what the multiline option meant.

Perhaps multiline should be renamed to multiline-element to avoid confusion.
eslint/eslint#8981 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

👍

I kinda like this one, but don't like some of the edge cases that it forbids/allows. Ultimately, I don't see anyone violating this rule so ¯\(ツ)

Copy link
Member

Choose a reason for hiding this comment

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

Boo, what a terrible option :/

// Enforce spacing inside array brackets
'array-bracket-spacing': ['warn', 'never'],
// enforce line breaks after each array element
'array-element-newline': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
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.

Couple of minor changes and LGTM. This is a pro PR 👍

@@ -75,4 +75,6 @@ module.exports = {
'import/max-dependencies': 'off',
// Forbid unassigned imports
'import/no-unassigned-import': 'off',
// Forbid anonymous values as default exports
'import/no-anonymous-default-export': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

👍

// enforce “for” loop update clause moving the counter in the right direction.
'for-direction': 'error',
// enforce return statements in getters
'getter-return': ['error', {allowImplicit: true}],
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -1,6 +1,10 @@
// see http://eslint.org/docs/rules/#possible-errors

module.exports = {
// enforce “for” loop update clause moving the counter in the right direction.
'for-direction': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -1,8 +1,12 @@
module.exports = {
// General

// Enforces consistent naming for boolean props
'react/boolean-prop-naming': 'off',
Copy link
Member

Choose a reason for hiding this comment

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

👍

// Prevent missing displayName in a React component definition
'react/display-name': ['warn', {ignoreTranspilerName: false}],
// Prevent extraneous defaultProps on components
'react/default-props-match-prop-types': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

👍

I assume we'll have to turn this off in the TS config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup.

@@ -129,6 +135,8 @@ module.exports = {
'operator-linebreak': ['warn', 'after', {overrides: {'?': 'before', ':': 'before'}}],
// Enforce padding within blocks
'padded-blocks': 'off',
// require or disallow padding lines between statements
'padding-line-between-statements': 'off',
Copy link
Member

Choose a reason for hiding this comment

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

👍

Yeesh. I'm sure there are useful permutations of this, but who would be able to read the config? 😕

@@ -137,6 +145,8 @@ module.exports = {
'require-jsdoc': 'off',
// Enforce spacing before and after semicolons
'semi-spacing': ['warn', {before: false, after: true}],
// enforce location of semicolons
'semi-style': ['error', 'last'],
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -155,6 +165,8 @@ module.exports = {
'space-unary-ops': ['warn', {words: true, nonwords: false}],
// Require or disallow a space immediately following the // or /* in a comment
'spaced-comment': ['warn', 'always', {markers: ['=']}],
// enforce spacing around colons of switch statements
'switch-colon-spacing': ['error', {'after': true, 'before': false}],
Copy link
Member

Choose a reason for hiding this comment

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

👍

package.json Outdated
@@ -45,7 +45,7 @@
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-preset-shopify": "^16.1.0",
"eslint": "^4.3.0",
"eslint": "^4.7.0",
Copy link
Member

Choose a reason for hiding this comment

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

4.7.1 😛

@@ -7,6 +7,8 @@ module.exports = {
'jsx-a11y/alt-text': 'error',
// Enforce all anchors to contain accessible content.
'jsx-a11y/anchor-has-content': 'error',
// Enforce all anchors are valid, navigable elements.
'jsx-a11y/anchor-is-valid': 'error',
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
Member

Choose a reason for hiding this comment

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

This replaces jsx-a11y/href-no-hash. The old rule's config should be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, nice catch!

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

Successfully merging this pull request may close these issues.

3 participants