diff --git a/CHANGELOG.md b/CHANGELOG.md index 911e1cfd8b..1bcef360dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 324d0e7642..b9e4bab2ad 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -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) { @@ -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); } diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index 5e55aa886e..96dfa78dc4 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -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(), @@ -80,7 +83,6 @@ module.exports = { function getNodeViolationType(node) { const nodeType = node.type; - if ( !configuration.allowBind && nodeType === 'CallExpression' @@ -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); }