Skip to content

Commit

Permalink
Assign parameters to variables defined within the jsx-no-bind.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
caroline223 committed Aug 12, 2022
1 parent a3ad878 commit be4eb34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-closing-bracket-location.js
Expand Up @@ -165,7 +165,7 @@ module.exports = {
* @return {String} The characters used for indentation
*/
function getIndentation(tokens, expectedLocation, correctColumn) {
correctColumn = correctColumn || 0;
const newColumn = correctColumn || 0;
let indentation;
let spaces = [];
switch (expectedLocation) {
Expand All @@ -179,7 +179,7 @@ module.exports = {
default:
indentation = '';
}
if (indentation.length + 1 < correctColumn) {
if (indentation.length + 1 < newColumn) {
// Non-whitespace characters were included in the column offset
spaces = new Array(+correctColumn + 1 - indentation.length);
}
Expand Down
9 changes: 8 additions & 1 deletion lib/rules/jsx-no-bind.js
Expand Up @@ -69,6 +69,9 @@ module.exports = {
// bind expression or an arrow function in different block statements
const blockVariableNameSets = {};

/**
* @param {string | number} blockStart
*/
function setBlockVariableNameSet(blockStart) {
blockVariableNameSets[blockStart] = {
arrowFunc: new Set(),
Expand All @@ -80,7 +83,6 @@ module.exports = {

function getNodeViolationType(node) {
const nodeType = node.type;

if (
!configuration.allowBind
&& nodeType === 'CallExpression'
Expand Down Expand Up @@ -111,6 +113,11 @@ module.exports = {
return null;
}

/**
* @param {string | number} violationType
* @param {any} variableName
* @param {string | number} blockStart
*/
function addVariableNameToSet(violationType, variableName, blockStart) {
blockVariableNameSets[blockStart][violationType].add(variableName);
}
Expand Down

0 comments on commit be4eb34

Please sign in to comment.