Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jsx-eslint/eslint-plugin-react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 380e32c8e50cd29130a5e27fccd77295efd6f80e
Choose a base ref
..
head repository: jsx-eslint/eslint-plugin-react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51d342ba350ae7d7dabce1caa648e71926ef283f
Choose a head ref
Showing with 12 additions and 9 deletions.
  1. +1 −1 lib/rules/jsx-closing-bracket-location.js
  2. +1 −1 lib/rules/jsx-closing-tag-location.js
  3. +1 −1 lib/rules/jsx-indent-props.js
  4. +1 −1 lib/rules/jsx-indent.js
  5. +8 −5 lib/rules/sort-comp.js
2 changes: 1 addition & 1 deletion lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ module.exports = {
}
if (indentation.length + 1 < newColumn) {
// Non-whitespace characters were included in the column offset
spaces = repeat(' ', +correctColumn + 1 - indentation.length);
spaces = repeat(' ', +correctColumn - indentation.length);
}
return indentation + spaces;
}
2 changes: 1 addition & 1 deletion lib/rules/jsx-closing-tag-location.js
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ module.exports = {
node,
loc: node.loc,
fix(fixer) {
const indent = repeat(' ', opening.loc.start.column + 1);
const indent = repeat(' ', opening.loc.start.column);
if (astUtil.isNodeFirstInLine(context, node)) {
return fixer.replaceTextRange(
[node.range[0] - node.loc.start.column, node.range[0]],
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent-props.js
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ module.exports = {
data: msgContext,
fix(fixer) {
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]],
repeat(indentType === 'space' ? ' ' : '\t', needed + 1)
repeat(indentType === 'space' ? ' ' : '\t', needed)
);
},
});
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ module.exports = {
* @private
*/
function getFixerFunction(node, needed) {
const indent = repeat(indentChar, needed + 1);
const indent = repeat(indentChar, needed);

if (node.type === 'JSXText' || node.type === 'Literal') {
return function fix(fixer) {
13 changes: 8 additions & 5 deletions lib/rules/sort-comp.js
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ module.exports = {
},

create: Components.detect((context, components) => {
/** @satisfies {{ node: ASTNode, score: number, closest: { distance: number, ref: { node: null | ASTNode, index: number } } }[]} */
/** @satisfies {Record<string, { node: ASTNode, score: number, closest: { distance: number, ref: { node: null | ASTNode, index: number } } }>} */
const errors = {};
const methodsOrder = getMethodsOrder(context.options[0]);

@@ -288,16 +288,19 @@ module.exports = {
* Dedupe errors, only keep the ones with the highest score and delete the others
*/
function dedupeErrors() {
for (let i = 0; i < errors.length; i += 1) {
const index = errors[i].closest.ref.index;
entries(errors).forEach((entry) => {
const i = entry[0];
const error = entry[1];

const index = error.closest.ref.index;
if (errors[index]) {
if (errors[i].score > errors[index].score) {
if (error.score > errors[index].score) {
delete errors[index];
} else {
delete errors[i];
}
}
}
});
}

/**