Skip to content

Commit

Permalink
[eslint] enable and manually fix array-callback-return
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 19, 2019
1 parent 28914aa commit 2508066
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"no-void": 1,
"no-continue": 1,
"global-require": 1,
"array-callback-return": 1,
"no-restricted-syntax": 1,
"implicit-arrow-linebreak": 1,
"valid-jsdoc": 1,
Expand Down
10 changes: 4 additions & 6 deletions lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ function validateReservedFirstConfig(context, reservedFirst) {
if (reservedFirst) {
if (Array.isArray(reservedFirst)) {
// Only allow a subset of reserved words in customized lists
// eslint-disable-next-line consistent-return
const nonReservedWords = reservedFirst.filter((word) => {
if (!isReservedPropName(word, RESERVED_PROPS_LIST)) {
return true;
}
});
const nonReservedWords = reservedFirst.filter(word => !isReservedPropName(
word,
RESERVED_PROPS_LIST
));

if (reservedFirst.length === 0) {
return function (decl) {
Expand Down
14 changes: 8 additions & 6 deletions lib/rules/no-access-state-in-setstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
CallExpression(node) {
// Appends all the methods that are calling another
// method containing this.state to the methods array
methods.map((method) => {
methods.forEach((method) => {
if (node.callee.name === method.methodName) {
let current = node.parent;
while (current.type !== 'Program') {
Expand All @@ -70,7 +70,7 @@ module.exports = {
while (current.type !== 'Program') {
if (isFirstArgumentInSetStateCall(current, node)) {
const methodName = node.callee.name;
methods.map((method) => {
methods.forEach((method) => {
if (method.methodName === methodName) {
context.report(
method.node,
Expand Down Expand Up @@ -145,10 +145,12 @@ module.exports = {
if (isFirstArgumentInSetStateCall(current, node)) {
vars
.filter(v => v.scope === context.getScope() && v.variableName === node.name)
.map(v => context.report(
v.node,
'Use callback in setState when referencing the previous state.'
));
.forEach((v) => {
context.report(
v.node,
'Use callback in setState when referencing the previous state.'
);
});
}
current = current.parent;
}
Expand Down

0 comments on commit 2508066

Please sign in to comment.