-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add eslint and use ES6 #33
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
665b101
Add basic eslint and fix code
a4f438c
Use airbnb-base config, fix code
4e74ad1
Remove empty lines
d68250d
Add linting to npm scripts and test task
b507093
Use strict
7288895
Remove redundant settings in .eslintrc.js
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
mocha: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
rules: { | ||
'func-names': 0, | ||
'no-use-before-define': 0, | ||
'no-plusplus': 0, | ||
'strict': 0, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
'use strict'; | ||
|
||
var resolve = require('path').resolve; | ||
var requireIndex = require('requireindex'); | ||
const resolve = require('path').resolve; | ||
const requireIndex = require('requireindex'); | ||
|
||
var rules = requireIndex(resolve(__dirname, 'lib/rules')); | ||
var configs = requireIndex(resolve(__dirname, 'config')); | ||
const rules = requireIndex(resolve(__dirname, 'lib/rules')); | ||
const configs = requireIndex(resolve(__dirname, 'config')); | ||
|
||
var ember = require(resolve(__dirname, 'lib/utils/ember')); | ||
var utils = require(resolve(__dirname, 'lib/utils/utils')); | ||
/* eslint-disable import/no-dynamic-require */ | ||
const ember = require(resolve(__dirname, 'lib/utils/ember')); | ||
const utils = require(resolve(__dirname, 'lib/utils/utils')); | ||
|
||
module.exports = { | ||
rules: rules, | ||
configs: configs, | ||
rules, | ||
configs, | ||
utils: { | ||
ember: ember, | ||
utils: utils | ||
} | ||
ember, | ||
utils, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
'use strict'; | ||
|
||
var utils = require('../utils/utils'); | ||
const utils = require('../utils/utils'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Components - Closure actions | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(context) { | ||
module.exports = function (context) { | ||
const message = 'Use closure actions, unless you need bubbling'; | ||
|
||
var message = 'Use closure actions, unless you need bubbling'; | ||
|
||
var report = function(node) { | ||
const report = function (node) { | ||
context.report(node, message); | ||
}; | ||
|
||
return { | ||
MemberExpression: function(node) { | ||
var isSendAction = utils.isThisExpression(node.object) && | ||
MemberExpression(node) { | ||
const isSendAction = utils.isThisExpression(node.object) && | ||
utils.isIdentifier(node.property) && | ||
node.property.name === 'sendAction'; | ||
|
||
if (isSendAction) { | ||
report(node); | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
'use strict'; | ||
|
||
var utils = require('../utils/utils'); | ||
var ember = require('../utils/ember'); | ||
const utils = require('../utils/utils'); | ||
const ember = require('../utils/ember'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// General rule - Don’t use jQuery without Ember Run Loop | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(context) { | ||
module.exports = function (context) { | ||
const message = 'Don\'t use jQuery without Ember Run Loop'; | ||
|
||
var message = 'Don\'t use jQuery without Ember Run Loop'; | ||
|
||
var report = function(node) { | ||
const report = function (node) { | ||
context.report(node, message); | ||
}; | ||
|
||
var isJqueryUsed = function(node) { | ||
const isJqueryUsed = function (node) { | ||
return utils.isMemberExpression(node) && | ||
utils.isCallExpression(node.object) && | ||
ember.isModule(node.object, '$'); | ||
}; | ||
|
||
var isRunUsed = function(node) { | ||
const isRunUsed = function (node) { | ||
return ember.isModule(node, 'run'); | ||
}; | ||
|
||
return { | ||
CallExpression: function(node) { | ||
var callee = node.callee; | ||
var fnNodes = utils.findNodes(node.arguments, 'ArrowFunctionExpression'); | ||
CallExpression(node) { | ||
const callee = node.callee; | ||
const fnNodes = utils.findNodes(node.arguments, 'ArrowFunctionExpression'); | ||
|
||
if (isJqueryUsed(callee) && fnNodes.length) { | ||
fnNodes.forEach(function(fnNode) { | ||
var fnBody = fnNode.body.body; | ||
var fnExpressions = utils.findNodes(fnBody, 'ExpressionStatement'); | ||
fnNodes.forEach((fnNode) => { | ||
const fnBody = fnNode.body.body; | ||
const fnExpressions = utils.findNodes(fnBody, 'ExpressionStatement'); | ||
|
||
fnExpressions.forEach(function(fnExpression) { | ||
fnExpression = fnExpression.expression; | ||
fnExpressions.forEach((fnExpression) => { | ||
const expression = fnExpression.expression; | ||
|
||
if ( | ||
utils.isCallExpression(fnExpression) && | ||
utils.isMemberExpression(fnExpression.callee) && | ||
!isRunUsed(fnExpression) | ||
utils.isCallExpression(expression) && | ||
utils.isMemberExpression(expression.callee) && | ||
!isRunUsed(expression) | ||
) { | ||
report(fnExpression.callee); | ||
report(expression.callee); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to disable it globally, in our case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is literally the only place with dynamic requires, and for a clear reason. In other places we'd rather want to be explicit about this.