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

Fix: eslint #385

Merged
merged 1 commit into from
Oct 24, 2016
Merged

Fix: eslint #385

merged 1 commit into from
Oct 24, 2016

Conversation

omgaz
Copy link
Contributor

@omgaz omgaz commented Oct 21, 2016

ESLint has been broken for a few months now.

Problem has existed since we migrated from .js to ,jsx for our jsx files as per airbnb eslint rules.

  • Update pre-commit hooks to only check staged files
  • Updated messages when running pre-commit
  • Added magnifying glass 🔍 when checking things out
  • Added broken hearts 💔 when something goes wrong
  • Renamed lint script to eslint
  • Added new lint script that lints everything (not just eslint)
  • Mapped posttesttolint`
  • Fix broken lint

@omgaz omgaz changed the title Fix eslint Fix: eslint Oct 21, 2016
@@ -56,7 +56,7 @@ npm run dist

# Lint all files in src (also automatically run after tests)

npm run lint
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 should still be lint

Copy link
Member

@vinteo vinteo left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -50,7 +50,7 @@ class PagedGridComponent extends React.Component {
{totalPages > 1 ?
<div className="pagedgrid-component-pagination">
<span className="pagedgrid-component-pagination-info">
{(activePage - 1) * perPage + 1}–{Math.min(activePage * perPage, items.length)} of {items.length}
{((activePage - 1) * perPage) + 1}–{Math.min(activePage * perPage, items.length)} of {items.length}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this necessary?

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 lint rules comlain about mixed * and +. I'd have assumed bodmas would take precedence.

ESLint defines the benefit as:

Enclosing complex expressions by parentheses clarifies the developer’s intention, which makes the code more readable. This rule warns when different operators are used consecutively without parentheses in an expression.

Copy link
Contributor

@OndrejCholeva OndrejCholeva Oct 21, 2016

Choose a reason for hiding this comment

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

Seriously ESLint? I thought that this is only for Facebook kids, not devs...
img

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe can use the rule with groups: http://eslint.org/docs/rules/no-mixed-operators#groups which makes much more sense (only forcing parens around logical and bitwise operators).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, sounds good :)

.map('label')
.join(', ')
}
</span> : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be:

    </span> 
 :
    null;

but I don't think putting semicolons on own line improves anything...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Null is kinda the exception I think; @patrick-ivers?

@codecov-io
Copy link

codecov-io commented Oct 21, 2016

Current coverage is 100% (diff: 100%)

Merging #385 into master will not change coverage

@@           master   #385   diff @@
====================================
  Files          24     24          
  Lines         401    402     +1   
  Methods        62     64     +2   
  Messages        0      0          
  Branches       73     72     -1   
====================================
+ Hits          401    402     +1   
  Misses          0      0          
  Partials        0      0          

Powered by Codecov. Last update 1a800a4...a2a307d


echo "…done."
echo "🐨 Checking commit message.";
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to show koalas with informative messages? Checking commit message. is neither good nor bad.

@omgaz omgaz force-pushed the fix-eslint branch 2 times, most recently from cf1f173 to 74df50e Compare October 24, 2016 00:02
const pathElement = !(_.isEmpty(node.path) && _.isEmpty(node.ancestors)) ?
<span className={`${baseClass}-path`}>
{ !_.isEmpty(node.path) ? printPathText(node) : printAncestorText(node) }
Copy link
Contributor

Choose a reason for hiding this comment

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

This was definitely more descriptive/readable. What was the reason for the change/what's wrong with arrow functions http://eslint.org/docs/rules/func-style#allowarrowfunctions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot, I meant to move these further up :)

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 issue here was the added complexity of defining functions inside the render method and re-using the component-scope node variable.

@omgaz
Copy link
Contributor Author

omgaz commented Oct 24, 2016

Ran direct-web e2e: https://ci.adslot.com/view/Direct/job/ui-test-direct/5328/ all passing
Tested in IE, all good :)

expect(itemInfoPropertyElements.at(2).find(GridCell).last().children().text()).to.equal('21');
expect(itemInfoPropertyElements.at(2).find(GridCell).last().prop('dts')).to.equal('age');
expect(itemInfoPropertyElements.at(1).find(GridCell)
.first()
Copy link
Contributor

Choose a reason for hiding this comment

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

are we forcing chains in tests as well or is this due to length constraint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Length here, I believe; although in this instance the accessors are being repeated. I'll clean it up; but what are your thoughts on the chaining?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think multi-line chains are easier to read/simplify especially when there is any nesting. However with exception of chains like selecting().one().particular().element.property (i.e. no mutating or complex set of dynamic rules to get the result, but just a simple way to navigate a relatively static object).

Also in this case I don't like the partial wrapping.

 - Update pre-commit hooks to only check staged files
 - Updated messages when running pre-commit
 - Added magnifying glass 🔍 when checking things out
 - Added broken hearts 💔 when something goes wrong
 - Renamed `lint` script to `eslint`
 - Added new `lint` script that lints everything (not just eslint)
 - Mapped `post`test` to `lint`
 - Update eslint mixed-operators rules to only enforce for groups of bitwise and logical operators
@vinteo
Copy link
Member

vinteo commented Oct 24, 2016

Merging...

@vinteo vinteo merged commit 09d9e7e into master Oct 24, 2016
@vinteo vinteo deleted the fix-eslint branch October 24, 2016 03:30
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.

4 participants