Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] jsx-closing-bracket-location, jsx-no-bind: fix eslint issues #3351

Merged
merged 1 commit into from Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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