Skip to content

Commit

Permalink
[Fix] jsx-closing-bracket-location: message shows {{details}} whe…
Browse files Browse the repository at this point in the history
…n there are no details
  • Loading branch information
mdjermanovic authored and ljharb committed May 20, 2024
1 parent fbb1e0f commit 23b0a49
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
* [`boolean-prop-naming`]: avoid a crash with a non-TSTypeReference type ([#3718][] @developer-bandi)
* [`jsx-no-leaked-render`]: invalid report if left side is boolean ([#3746][] @akulsr0)
* [`jsx-closing-bracket-location`]: message shows `{{details}}` when there are no details ([#3759][] @mdjermanovic)

[#3759]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3759
[#3746]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3746
[#3718]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3718

Expand Down
5 changes: 4 additions & 1 deletion lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ module.exports = {
return;
}

const data = { location: MESSAGE_LOCATION[expectedLocation] };
const data = {
location: MESSAGE_LOCATION[expectedLocation],
details: '',
};
const correctColumn = getCorrectColumn(tokens, expectedLocation);

if (correctColumn !== null) {
Expand Down
65 changes: 52 additions & 13 deletions tests/lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_TAG },
data: {
location: MESSAGE_AFTER_TAG,
details: '',
},
},
],
},
Expand All @@ -434,7 +437,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand All @@ -449,7 +455,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -536,7 +545,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -578,7 +590,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -644,7 +659,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -686,7 +704,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1098,7 +1119,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_TAG },
data: {
location: MESSAGE_AFTER_TAG,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1216,7 +1240,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1258,7 +1285,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1324,7 +1354,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1366,7 +1399,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_PROPS },
data: {
location: MESSAGE_AFTER_PROPS,
details: '',
},
},
],
},
Expand Down Expand Up @@ -1778,7 +1814,10 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
errors: [
{
messageId: 'bracketLocation',
data: { location: MESSAGE_AFTER_TAG },
data: {
location: MESSAGE_AFTER_TAG,
details: '',
},
},
],
},
Expand Down

0 comments on commit 23b0a49

Please sign in to comment.