Skip to content

Commit cbccbc3

Browse files
committed
chore: obey to the eslint rules
1 parent 177095c commit cbccbc3

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

rules/from-map.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,46 @@ module.exports = {
4141
const OMIT_ITEM = 1,
4242
[
4343
mapCallback,
44-
mapThisArg
44+
mapThisArgument
4545
] = node.arguments,
4646
[
4747
_, // eslint-disable-line no-unused-vars
4848
callback,
49-
thisArg
49+
thisArgument
5050
] = parent.arguments,
5151
// Get the params names from the callback that has the most params (since the signature is identical).
52-
params = callback.params.length > mapCallback.params.length ? callback.params : mapCallback.params,
53-
paramString = params.map((p) => p.name).join(PARAM_SEPARATOR),
52+
parameters = callback.params.length > mapCallback.params.length ? callback.params : mapCallback.params,
53+
parameterString = parameters.map((p) => p.name).join(PARAM_SEPARATOR),
5454
getCallback = (cbk, targ, ps) => {
5555
const source = `(${sourceCode.getText(cbk)})`;
5656
if(targ && cbk.type !== ARROW_FUNCTION_EXPRESSION) {
5757
return `${source}.call(${targ.name}${PARAM_SEPARATOR}${ps})`;
5858
}
5959
return `${source}(${ps})`;
6060
},
61-
firstCallback = getCallback(callback, { name: 'this' }, paramString);
61+
firstCallback = getCallback(callback, { name: 'this' }, parameterString);
6262

6363
// Try to use an arrow function for the wrapping function, fall back to a function expression if a this is specified.
64-
let functionStart = `(${paramString}) => `,
64+
let functionStart = `(${parameterString}) => `,
6565
functionEnd = "",
66-
restParamString = '';
67-
if(thisArg && callback.type !== ARROW_FUNCTION_EXPRESSION) {
68-
functionStart = `function(${paramString}) { return `;
66+
restParameterString = '';
67+
if(thisArgument && callback.type !== ARROW_FUNCTION_EXPRESSION) {
68+
functionStart = `function(${parameterString}) { return `;
6969
functionEnd = "; }";
7070
}
71-
if(params.length > OMIT_ITEM) {
72-
const restParams = params
71+
if(parameters.length > OMIT_ITEM) {
72+
const restParameters_ = parameters
7373
.slice(OMIT_ITEM)
7474
.map((p) => p.name);
75-
restParamString = PARAM_SEPARATOR + restParams.join(PARAM_SEPARATOR);
75+
restParameterString = PARAM_SEPARATOR + restParameters_.join(PARAM_SEPARATOR);
7676
}
7777
// The original map callback from Array.from gets nested as a parameter to the callback from map.
78-
const lastCallback = getCallback(mapCallback, mapThisArg, `${firstCallback}${restParamString}`),
79-
restParams = sourceCode.getText().slice(callback.end, parent.end);
78+
const lastCallback = getCallback(mapCallback, mapThisArgument, `${firstCallback}${restParameterString}`),
79+
restParameters = sourceCode.getText().slice(callback.end, parent.end);
8080
return fixer.replaceTextRange([
8181
callback.start,
8282
node.end
83-
], `${functionStart}${lastCallback}${functionEnd}${restParams}`);
83+
], `${functionStart}${lastCallback}${functionEnd}${restParameters}`);
8484
}
8585

8686
// Move the map arguments to from.

rules/no-unnecessary-this-arg.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const {
2828
FUNC_POS = -2,
2929
//TODO should also check if the identifier is not an arrow function expression. Similar problem to array detection.
3030
checkFunction = (node, functionName, argumentPosition) => !isMethod(node, functionName) || node.arguments.length < argumentPosition || node.arguments[argumentPosition + FUNC_POS].type !== ARROW_FUNCTION_EXPRESSION,
31-
checkArrayFunction = (functionName, paramPosition, node, context) => {
32-
if(checkFunction(node, functionName, paramPosition) || !isOnObject(node, "Array")) {
31+
checkArrayFunction = (functionName, parameterPosition, node, context) => {
32+
if(checkFunction(node, functionName, parameterPosition) || !isOnObject(node, "Array")) {
3333
return;
3434
}
35-
const argument = node.arguments[paramPosition - POS_TO_ARRAY];
35+
const argument = node.arguments[parameterPosition - POS_TO_ARRAY];
3636
context.report({
3737
node: argument,
3838
loc: argument.loc,
@@ -42,9 +42,9 @@ const {
4242
argument: argument.name
4343
},
4444
fix(fixer) {
45-
const prevArgumentEnd = node.arguments[paramPosition + FUNC_POS].end;
45+
const previousArgumentEnd = node.arguments[parameterPosition + FUNC_POS].end;
4646
return fixer.removeRange([
47-
prevArgumentEnd,
47+
previousArgumentEnd,
4848
argument.end
4949
]);
5050
}

rules/prefer-array-from.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55
"use strict";
66

7-
const firstElement = (arr) => {
8-
const [ el ] = arr;
9-
return el;
7+
const firstElement = (array) => {
8+
const [ element ] = array;
9+
return element;
1010
};
1111

1212
module.exports = {

rules/prefer-flat.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ module.exports = {
3737
});
3838
},
3939
'CallExpression[callee.type="MemberExpression"][callee.property.name="reduce"][arguments.length=2][arguments.1.type=ArrayExpression][arguments.1.elements.length=0] > *:function[params.length=2][params.0.type=Identifier][params.1.type=Identifier] > CallExpression[callee.type="MemberExpression"][callee.property.name="concat"][arguments.length=1][arguments.0.type=Identifier]'(node) {
40-
const reduceCallbackParams = node.parent.params;
40+
const reduceCallbackParameters = node.parent.params;
4141

4242
// arr.reducer((a, b) => a.concat(b), [])
4343
// "concat" function must be called on "a" and concat argument must be "b".
4444
if(
45-
firstElement(node.arguments).name === secondElement(reduceCallbackParams).name &&
46-
node.callee.object.name === firstElement(reduceCallbackParams).name
45+
firstElement(node.arguments).name === secondElement(reduceCallbackParameters).name &&
46+
node.callee.object.name === firstElement(reduceCallbackParameters).name
4747
) {
4848
context.report({
4949
node: node.parent.parent,

0 commit comments

Comments
 (0)