-
Notifications
You must be signed in to change notification settings - Fork 322
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
Updated Babel, Webpack, React, Eslint, etc to latest & Clean up linting errors #719
Open
ryank311
wants to merge
21
commits into
goatslacker:master
Choose a base branch
from
ryank311:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,036
−2,545
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dd607db
Update yarn build to fix babel
i-r-n00b e51c658
Fix issues with old version of react causing tests to fail
i-r-n00b 5ba6705
Update to use correct react test utils
i-r-n00b 29e5edd
Modernize babel, tests, eslint, etc
i-r-n00b 7d9bec0
Update readme
i-r-n00b d091162
Update readme and such
i-r-n00b 83b9e65
Bring back bower, update package json
i-r-n00b 83b37ec
Revert package json message for pull request
i-r-n00b b9c80f8
Eslint fix all the test cases
i-r-n00b 7119e2e
Update flux version to latest
i-r-n00b c2c611e
Eslint fix for web app
i-r-n00b 408c5af
Fix for eslint errors
i-r-n00b ad3f1c2
Update to make prop types a dev dep
i-r-n00b 35c439a
Update eslint to use two spaces
i-r-n00b 4e0863f
Update to fix a few other files that were touched.
i-r-n00b ab703cf
Update lint to remove semicolons.
i-r-n00b 2535c95
Update to fix some non-linted files
i-r-n00b ea92aca
Fix a few missed files
i-r-n00b f00268c
Fix lint on configs
i-r-n00b 0fc08d4
Fix dependency warning, remove internal registry
i-r-n00b bf941c8
Update to fix travis command and eslint errors
i-r-n00b 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
Update eslint to use two spaces
commit 35c439a93411a3ab1b766b50307904907b99dd37
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
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 |
---|---|---|
|
@@ -64,7 +64,7 @@ | |
"clean": "rimraf lib", | ||
"coverage": "npm run transpile-cover && babel-node node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -u exports -R tap --require test/babel test", | ||
"lint": "eslint src components", | ||
"lint-fix": "eslint --fix src components", | ||
"lint-fix": "eslint --fix src test scripts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! 👍 |
||
"postversion": "git push && git push --tags", | ||
"prepublish": "npm run lint && npm run build", | ||
"pretest": "npm run clean && npm run transpile", | ||
|
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,110 +1,110 @@ | ||
const isDispatch = (path) => { | ||
return ( | ||
path.value.type === 'CallExpression' && | ||
return ( | ||
path.value.type === 'CallExpression' && | ||
path.value.callee.type === 'MemberExpression' && | ||
// path.value.callee.object.type === 'ThisExpression' && | ||
// commented out so we support var self = this; self.dispatch(); | ||
path.value.callee.property.type === 'Identifier' && | ||
path.value.callee.property.name === 'dispatch' | ||
); | ||
); | ||
}; | ||
|
||
const isThisActions = (path) => { | ||
return ( | ||
path.value.type === 'MemberExpression' && | ||
return ( | ||
path.value.type === 'MemberExpression' && | ||
path.value.object.type === 'MemberExpression' && | ||
path.value.object.property.type === 'Identifier' && | ||
path.value.object.property.name === 'actions' | ||
); | ||
); | ||
}; | ||
|
||
const updateDispatchToReturn = (j) => { | ||
return (p) => { | ||
j(p).replaceWith(j.returnStatement(p.value.arguments[0] || null)); | ||
}; | ||
return (p) => { | ||
j(p).replaceWith(j.returnStatement(p.value.arguments[0] || null)); | ||
}; | ||
}; | ||
|
||
const updateDispatchToCall = (j) => { | ||
return (p) => { | ||
j(p).replaceWith(j.callExpression(j.identifier('dispatch'), p.value.arguments)); | ||
}; | ||
return (p) => { | ||
j(p).replaceWith(j.callExpression(j.identifier('dispatch'), p.value.arguments)); | ||
}; | ||
}; | ||
|
||
const updateToJustThis = (j) => { | ||
return (p) => { | ||
j(p).replaceWith(j.memberExpression(p.value.object.object, p.value.property)); | ||
}; | ||
return (p) => { | ||
j(p).replaceWith(j.memberExpression(p.value.object.object, p.value.property)); | ||
}; | ||
}; | ||
|
||
const findDispatches = (j, p) => { | ||
return j(p).find(j.CallExpression).filter(isDispatch); | ||
return j(p).find(j.CallExpression).filter(isDispatch); | ||
}; | ||
|
||
const findThisActionReferences = (j, p) => { | ||
return j(p).find(j.MemberExpression).filter(isThisActions); | ||
return j(p).find(j.MemberExpression).filter(isThisActions); | ||
}; | ||
|
||
const replaceFunction = (j, p) => { | ||
j(p).replaceWith(j.functionExpression( | ||
null, | ||
p.value.params, | ||
j.blockStatement([ | ||
j.returnStatement( | ||
j.functionExpression( | ||
null, | ||
[j.identifier('dispatch')], | ||
j.blockStatement(p.value.body.body) | ||
) | ||
) | ||
]) | ||
)); | ||
j(p).replaceWith(j.functionExpression( | ||
null, | ||
p.value.params, | ||
j.blockStatement([ | ||
j.returnStatement( | ||
j.functionExpression( | ||
null, | ||
[j.identifier('dispatch')], | ||
j.blockStatement(p.value.body.body) | ||
) | ||
) | ||
]) | ||
)); | ||
}; | ||
|
||
module.exports = (file, api) => { | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
|
||
root.find(j.FunctionExpression).forEach((p) => { | ||
root.find(j.FunctionExpression).forEach((p) => { | ||
// ignore constructors | ||
if (p.parent.value.type === 'MethodDefinition' && p.parent.value.kind === 'constructor') { | ||
return; | ||
} | ||
if (p.parent.value.type === 'MethodDefinition' && p.parent.value.kind === 'constructor') { | ||
return; | ||
} | ||
|
||
// find all dispatches that are inside the function | ||
const dispatches = findDispatches(j, p).size(); | ||
const withinParent = findDispatches(j, p).filter((x) => { | ||
return x.parent.parent.parent.value === p.value; | ||
}).size(); | ||
// find all dispatches that are inside the function | ||
const dispatches = findDispatches(j, p).size(); | ||
const withinParent = findDispatches(j, p).filter((x) => { | ||
return x.parent.parent.parent.value === p.value; | ||
}).size(); | ||
|
||
if (withinParent === 0 && dispatches > 0) { | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
} else if (dispatches === 0) { | ||
const hasReturn = j(p).find(j.ReturnStatement).size() > 0; | ||
if (hasReturn) { | ||
console.warn('Could not transform function because it returned', 'at line', p.parent.value.loc.start.line); | ||
} else { | ||
console.warn('This function does not dispatch?', 'at line', p.parent.value.loc.start.line); | ||
} | ||
if (withinParent === 0 && dispatches > 0) { | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
} else if (dispatches === 0) { | ||
const hasReturn = j(p).find(j.ReturnStatement).size() > 0; | ||
if (hasReturn) { | ||
console.warn('Could not transform function because it returned', 'at line', p.parent.value.loc.start.line); | ||
} else { | ||
console.warn('This function does not dispatch?', 'at line', p.parent.value.loc.start.line); | ||
} | ||
|
||
// if there are multiple dispatches happening then we'll need to return a | ||
// dispatch function and update this.dispatch to a dispatch call | ||
} else if (dispatches > 1) { | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
// if there's a single dispatch then it's ok to return to dispatch | ||
} else if (p.value.body.body.length === 1) { | ||
// if its the only statement within the function | ||
findDispatches(j, p).forEach(updateDispatchToReturn(j)); | ||
} else { | ||
// otherwise lets run the function | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
} | ||
// if there are multiple dispatches happening then we'll need to return a | ||
// dispatch function and update this.dispatch to a dispatch call | ||
} else if (dispatches > 1) { | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
// if there's a single dispatch then it's ok to return to dispatch | ||
} else if (p.value.body.body.length === 1) { | ||
// if its the only statement within the function | ||
findDispatches(j, p).forEach(updateDispatchToReturn(j)); | ||
} else { | ||
// otherwise lets run the function | ||
replaceFunction(j, p); | ||
findDispatches(j, p).forEach(updateDispatchToCall(j)); | ||
} | ||
|
||
// Also find any mentions to `this.actions` | ||
findThisActionReferences(j, p).forEach(updateToJustThis(j)); | ||
}); | ||
// Also find any mentions to `this.actions` | ||
findThisActionReferences(j, p).forEach(updateToJustThis(j)); | ||
}); | ||
|
||
return root.toSource({ quote: 'single' }); | ||
return root.toSource({ quote: 'single' }); | ||
}; |
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.
same here, can we revert this file to include only the single rule. We can perhaps add individual overrides per line.
no-param-reassign
can be easily fixed by renaming all the reducers fromobj
toacc
(acc
is whitelisted as an acceptable param that can be reassigned)