Skip to content

Commit c5c7494

Browse files
committed
resolve conflicts
2 parents 7c36070 + b381547 commit c5c7494

20 files changed

+122
-90
lines changed

.eslintrc

+56-56
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,61 @@
2222
"object-shorthand": [2, "always", {
2323
"ignoreConstructors": false,
2424
"avoidQuotes": false, // this is the override vs airbnb
25-
}],
26-
"max-len": [2, 120, {
27-
"ignoreStrings": true,
28-
"ignoreTemplateLiterals": true,
29-
"ignoreComments": true,
30-
}],
31-
"consistent-return": 0,
25+
}],
26+
"max-len": [2, 140, {
27+
"ignoreStrings": true,
28+
"ignoreTemplateLiterals": true,
29+
"ignoreComments": true,
30+
}],
31+
"consistent-return": 0,
3232

33-
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
34-
"prefer-object-spread": 0, // until node 8 is required
35-
"prefer-rest-params": 0, // until node 6 is required
36-
"prefer-spread": 0, // until node 6 is required
37-
"function-call-argument-newline": 1, // TODO: enable
38-
"function-paren-newline": 0,
39-
"no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
40-
"no-param-reassign": 1,
41-
"no-restricted-syntax": [2, {
42-
"selector": "ObjectPattern",
43-
"message": "Object destructuring is not compatible with Node v4"
44-
}],
45-
"strict": [2, "safe"],
46-
"valid-jsdoc": [2, {
47-
"requireReturn": false,
48-
"requireParamDescription": false,
49-
"requireReturnDescription": false,
50-
}],
33+
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
34+
"prefer-object-spread": 0, // until node 8 is required
35+
"prefer-rest-params": 0, // until node 6 is required
36+
"prefer-spread": 0, // until node 6 is required
37+
"function-call-argument-newline": 1, // TODO: enable
38+
"function-paren-newline": 0,
39+
"no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
40+
"no-param-reassign": 1,
41+
"no-restricted-syntax": [2, {
42+
"selector": "ObjectPattern",
43+
"message": "Object destructuring is not compatible with Node v4"
44+
}],
45+
"strict": [2, "safe"],
46+
"valid-jsdoc": [2, {
47+
"requireReturn": false,
48+
"requireParamDescription": false,
49+
"requireReturnDescription": false,
50+
}],
5151

52-
"eslint-plugin/consistent-output": 0,
53-
"eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
54-
"eslint-plugin/require-meta-schema": 0,
55-
"eslint-plugin/require-meta-type": 0
56-
},
57-
"overrides": [
58-
{
59-
"files": "tests/**",
60-
"rules": {
61-
"no-template-curly-in-string": 1,
62-
},
63-
},
64-
{
65-
"files": "markdown.config.js",
66-
"rules": {
67-
"no-console": 0,
68-
},
69-
},
70-
{
71-
"files": ".github/workflows/*.js",
72-
"parserOptions": {
73-
"ecmaVersion": 2019,
74-
},
75-
"rules": {
76-
"camelcase": 0,
77-
"no-console": 0,
78-
"no-restricted-syntax": 0,
79-
},
80-
},
81-
],
82-
}
52+
"eslint-plugin/consistent-output": 0,
53+
"eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
54+
"eslint-plugin/require-meta-schema": 0,
55+
"eslint-plugin/require-meta-type": 0
56+
},
57+
"overrides": [
58+
{
59+
"files": "tests/**",
60+
"rules": {
61+
"no-template-curly-in-string": 1,
62+
},
63+
},
64+
{
65+
"files": "markdown.config.js",
66+
"rules": {
67+
"no-console": 0,
68+
},
69+
},
70+
{
71+
"files": ".github/workflows/*.js",
72+
"parserOptions": {
73+
"ecmaVersion": 2019,
74+
},
75+
"rules": {
76+
"camelcase": 0,
77+
"no-console": 0,
78+
"no-restricted-syntax": 0,
79+
},
80+
},
81+
],
82+
}

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
55

66
## Unreleased
77

8+
### Added
9+
10+
* [`jsx-closing-tag-location`]: add `line-aligned` option ([#3777] @kimtaejin3)
11+
812
### Fixed
913

1014
* [`prop-types`]: fix `className` missing in prop validation false negative ([#3749] @akulsr0)
1115

16+
[#3777]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3777
1217
[#3749]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3749
1318

1419
## [7.34.3] - 2024.06.18

docs/rules/jsx-closing-tag-location.md

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ const App = <Bar>
109109
Foo
110110
</Bar>;
111111

112+
<<<<<<< HEAD
113+
=======
114+
115+
>>>>>>> b381547982addc145bd58a184a18e4e6665d2b03
112116
```
113117

114118
## When Not To Use It

lib/rules/forbid-elements.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const docsUrl = require('../util/docsUrl');
1010
const getText = require('../util/eslint').getText;
1111
const isCreateElement = require('../util/isCreateElement');
@@ -60,6 +60,7 @@ module.exports = {
6060
const configuration = context.options[0] || {};
6161
const forbidConfiguration = configuration.forbid || [];
6262

63+
/** @type {Record<string, { element: string, message?: string }>} */
6364
const indexedForbidConfigs = {};
6465

6566
forbidConfiguration.forEach((item) => {

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
9+
const repeat = require('string.prototype.repeat');
10+
911
const docsUrl = require('../util/docsUrl');
1012
const getSourceCode = require('../util/eslint').getSourceCode;
1113
const report = require('../util/report');
@@ -168,7 +170,7 @@ module.exports = {
168170
function getIndentation(tokens, expectedLocation, correctColumn) {
169171
const newColumn = correctColumn || 0;
170172
let indentation;
171-
let spaces = [];
173+
let spaces = '';
172174
switch (expectedLocation) {
173175
case 'props-aligned':
174176
indentation = /^\s*/.exec(getSourceCode(context).lines[tokens.lastProp.firstLine - 1])[0];
@@ -182,9 +184,9 @@ module.exports = {
182184
}
183185
if (indentation.length + 1 < newColumn) {
184186
// Non-whitespace characters were included in the column offset
185-
spaces = new Array(+correctColumn + 1 - indentation.length);
187+
spaces = repeat(' ', +correctColumn + 1 - indentation.length);
186188
}
187-
return indentation + spaces.join(' ');
189+
return indentation + spaces;
188190
}
189191

190192
/**

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const repeat = require('string.prototype.repeat');
9+
const has = require('hasown');
10+
911
const astUtil = require('../util/ast');
1012
const docsUrl = require('../util/docsUrl');
1113
const getSourceCode = require('../util/eslint').getSourceCode;
@@ -109,7 +111,7 @@ module.exports = {
109111
node,
110112
loc: node.loc,
111113
fix(fixer) {
112-
const indent = Array(getIndentation(openingStartOfLine, opening)).join(' ');
114+
const indent = repeat(' ', getIndentation(openingStartOfLine, opening));
113115

114116
if (astUtil.isNodeFirstInLine(context, node)) {
115117
return fixer.replaceTextRange(

lib/rules/jsx-curly-spacing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
'use strict';
1313

14-
const has = require('object.hasown/polyfill')();
14+
const has = require('hasown');
1515
const docsUrl = require('../util/docsUrl');
1616
const getSourceCode = require('../util/eslint').getSourceCode;
1717
const report = require('../util/report');

lib/rules/jsx-indent-props.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
'use strict';
3232

33+
const repeat = require('string.prototype.repeat');
34+
3335
const astUtil = require('../util/ast');
3436
const docsUrl = require('../util/docsUrl');
3537
const getText = require('../util/eslint').getText;
@@ -130,7 +132,8 @@ module.exports = {
130132
data: msgContext,
131133
fix(fixer) {
132134
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]],
133-
Array(needed + 1).join(indentType === 'space' ? ' ' : '\t'));
135+
repeat(indentType === 'space' ? ' ' : '\t', needed + 1)
136+
);
134137
},
135138
});
136139
}

lib/rules/jsx-indent.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'use strict';
3232

3333
const matchAll = require('string.prototype.matchall');
34+
const repeat = require('string.prototype.repeat');
3435

3536
const astUtil = require('../util/ast');
3637
const docsUrl = require('../util/docsUrl');
@@ -109,7 +110,7 @@ module.exports = {
109110
* @private
110111
*/
111112
function getFixerFunction(node, needed) {
112-
const indent = Array(needed + 1).join(indentChar);
113+
const indent = repeat(indentChar, needed + 1);
113114

114115
if (node.type === 'JSXText' || node.type === 'Literal') {
115116
return function fix(fixer) {

lib/rules/jsx-max-depth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const includes = require('array-includes');
1010
const variableUtil = require('../util/variable');
1111
const jsxUtil = require('../util/jsx');

lib/rules/jsx-no-duplicate-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const docsUrl = require('../util/docsUrl');
1010
const report = require('../util/report');
1111

lib/rules/jsx-wrap-multilines.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const docsUrl = require('../util/docsUrl');
1010
const eslintUtil = require('../util/eslint');
1111
const jsxUtil = require('../util/jsx');

lib/rules/no-array-index-key.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const astUtil = require('../util/ast');
1010
const docsUrl = require('../util/docsUrl');
1111
const pragma = require('../util/pragma');
@@ -117,6 +117,8 @@ module.exports = {
117117
return null;
118118
}
119119

120+
const name = /** @type {keyof iteratorFunctionsToIndexParamPosition} */ (callee.property.name);
121+
120122
const callbackArg = isUsingReactChildren(node)
121123
? node.arguments[1]
122124
: node.arguments[0];
@@ -131,7 +133,7 @@ module.exports = {
131133

132134
const params = callbackArg.params;
133135

134-
const indexParamPosition = iteratorFunctionsToIndexParamPosition[callee.property.name];
136+
const indexParamPosition = iteratorFunctionsToIndexParamPosition[name];
135137
if (params.length < indexParamPosition + 1) {
136138
return null;
137139
}

lib/rules/no-danger.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const fromEntries = require('object.fromentries/polyfill')();
1010

1111
const docsUrl = require('../util/docsUrl');

lib/rules/no-unknown-property.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const docsUrl = require('../util/docsUrl');
1010
const getText = require('../util/eslint').getText;
1111
const testReactVersion = require('../util/version').testReactVersion;
@@ -491,10 +491,10 @@ function tagNameHasDot(node) {
491491
*/
492492
function getStandardName(name, context) {
493493
if (has(DOM_ATTRIBUTE_NAMES, name)) {
494-
return DOM_ATTRIBUTE_NAMES[name];
494+
return DOM_ATTRIBUTE_NAMES[/** @type {keyof DOM_ATTRIBUTE_NAMES} */ (name)];
495495
}
496496
if (has(SVGDOM_ATTRIBUTE_NAMES, name)) {
497-
return SVGDOM_ATTRIBUTE_NAMES[name];
497+
return SVGDOM_ATTRIBUTE_NAMES[/** @type {keyof SVGDOM_ATTRIBUTE_NAMES} */ (name)];
498498
}
499499
const names = getDOMPropertyNames(context);
500500
// Let's find a possible attribute match with a case-insensitive search.
@@ -592,7 +592,7 @@ module.exports = {
592592
// Let's dive deeper into tags that are HTML/DOM elements (`<button>`), and not React components (`<Button />`)
593593

594594
// Some attributes are allowed on some tags only
595-
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[name] : null;
595+
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[/** @type {keyof ATTRIBUTE_TAGS_MAP} */ (name)] : null;
596596
if (tagName && allowedTags) {
597597
// Scenario 1A: Allowed attribute found where not supposed to, report it
598598
if (allowedTags.indexOf(tagName) === -1) {

lib/rules/sort-comp.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const has = require('object.hasown/polyfill')();
8+
const has = require('hasown');
99
const entries = require('object.entries');
1010
const values = require('object.values');
1111
const arrayIncludes = require('array-includes');
@@ -124,6 +124,7 @@ module.exports = {
124124
},
125125

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

@@ -287,15 +288,13 @@ module.exports = {
287288
* Dedupe errors, only keep the ones with the highest score and delete the others
288289
*/
289290
function dedupeErrors() {
290-
for (const i in errors) {
291-
if (has(errors, i)) {
292-
const index = errors[i].closest.ref.index;
293-
if (errors[index]) {
294-
if (errors[i].score > errors[index].score) {
295-
delete errors[index];
296-
} else {
297-
delete errors[i];
298-
}
291+
for (let i = 0; i < errors.length; i += 1) {
292+
const index = errors[i].closest.ref.index;
293+
if (errors[index]) {
294+
if (errors[i].score > errors[index].score) {
295+
delete errors[index];
296+
} else {
297+
delete errors[i];
299298
}
300299
}
301300
}

0 commit comments

Comments
 (0)