Skip to content

Commit

Permalink
[Refactor] jsx-closing-bracket-location, jsx-no-bind: fix eslint …
Browse files Browse the repository at this point in the history
…issues
  • Loading branch information
caroline223 authored and ljharb committed Aug 12, 2022
1 parent cac3838 commit d000f8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -33,8 +33,10 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [Docs] [`jsx-boolean-value`]: add jsdoc types for helper functions ([#3344][] @caroline223)
* [readme] remove dead codeclimate badge, add actions badge (@ljharb)
* [readme] Remove dead david-dm badge ([#3262][] @ddzz)
* [Refactor] [`jsx-closing-bracket-location`], [`jsx-no-bind`]: fix eslint issues ([#3351][] @caroline223)

[#3353]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3353
[#3351]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3351
[#3350]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3350
[#3349]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3349
[#3347]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3347
Expand Down
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 d000f8c

Please sign in to comment.