Skip to content

Commit d000f8c

Browse files
caroline223ljharb
authored andcommitted
[Refactor] jsx-closing-bracket-location, jsx-no-bind: fix eslint issues
1 parent cac3838 commit d000f8c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
3333
* [Docs] [`jsx-boolean-value`]: add jsdoc types for helper functions ([#3344][] @caroline223)
3434
* [readme] remove dead codeclimate badge, add actions badge (@ljharb)
3535
* [readme] Remove dead david-dm badge ([#3262][] @ddzz)
36+
* [Refactor] [`jsx-closing-bracket-location`], [`jsx-no-bind`]: fix eslint issues ([#3351][] @caroline223)
3637

3738
[#3353]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3353
39+
[#3351]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3351
3840
[#3350]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3350
3941
[#3349]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3349
4042
[#3347]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3347

lib/rules/jsx-closing-bracket-location.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ module.exports = {
165165
* @return {String} The characters used for indentation
166166
*/
167167
function getIndentation(tokens, expectedLocation, correctColumn) {
168-
correctColumn = correctColumn || 0;
168+
const newColumn = correctColumn || 0;
169169
let indentation;
170170
let spaces = [];
171171
switch (expectedLocation) {
@@ -179,7 +179,7 @@ module.exports = {
179179
default:
180180
indentation = '';
181181
}
182-
if (indentation.length + 1 < correctColumn) {
182+
if (indentation.length + 1 < newColumn) {
183183
// Non-whitespace characters were included in the column offset
184184
spaces = new Array(+correctColumn + 1 - indentation.length);
185185
}

lib/rules/jsx-no-bind.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ module.exports = {
6969
// bind expression or an arrow function in different block statements
7070
const blockVariableNameSets = {};
7171

72+
/**
73+
* @param {string | number} blockStart
74+
*/
7275
function setBlockVariableNameSet(blockStart) {
7376
blockVariableNameSets[blockStart] = {
7477
arrowFunc: new Set(),
@@ -80,7 +83,6 @@ module.exports = {
8083

8184
function getNodeViolationType(node) {
8285
const nodeType = node.type;
83-
8486
if (
8587
!configuration.allowBind
8688
&& nodeType === 'CallExpression'
@@ -111,6 +113,11 @@ module.exports = {
111113
return null;
112114
}
113115

116+
/**
117+
* @param {string | number} violationType
118+
* @param {any} variableName
119+
* @param {string | number} blockStart
120+
*/
114121
function addVariableNameToSet(violationType, variableName, blockStart) {
115122
blockVariableNameSets[blockStart][violationType].add(variableName);
116123
}

0 commit comments

Comments
 (0)