Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kimtaejin3 committed Jul 4, 2024
2 parents 7c36070 + b381547 commit c5c7494
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 90 deletions.
112 changes: 56 additions & 56 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,61 @@
"object-shorthand": [2, "always", {
"ignoreConstructors": false,
"avoidQuotes": false, // this is the override vs airbnb
}],
"max-len": [2, 120, {
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreComments": true,
}],
"consistent-return": 0,
}],
"max-len": [2, 140, {
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreComments": true,
}],
"consistent-return": 0,

"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
"prefer-object-spread": 0, // until node 8 is required
"prefer-rest-params": 0, // until node 6 is required
"prefer-spread": 0, // until node 6 is required
"function-call-argument-newline": 1, // TODO: enable
"function-paren-newline": 0,
"no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
"no-param-reassign": 1,
"no-restricted-syntax": [2, {
"selector": "ObjectPattern",
"message": "Object destructuring is not compatible with Node v4"
}],
"strict": [2, "safe"],
"valid-jsdoc": [2, {
"requireReturn": false,
"requireParamDescription": false,
"requireReturnDescription": false,
}],
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
"prefer-object-spread": 0, // until node 8 is required
"prefer-rest-params": 0, // until node 6 is required
"prefer-spread": 0, // until node 6 is required
"function-call-argument-newline": 1, // TODO: enable
"function-paren-newline": 0,
"no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
"no-param-reassign": 1,
"no-restricted-syntax": [2, {
"selector": "ObjectPattern",
"message": "Object destructuring is not compatible with Node v4"
}],
"strict": [2, "safe"],
"valid-jsdoc": [2, {
"requireReturn": false,
"requireParamDescription": false,
"requireReturnDescription": false,
}],

"eslint-plugin/consistent-output": 0,
"eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
"eslint-plugin/require-meta-schema": 0,
"eslint-plugin/require-meta-type": 0
},
"overrides": [
{
"files": "tests/**",
"rules": {
"no-template-curly-in-string": 1,
},
},
{
"files": "markdown.config.js",
"rules": {
"no-console": 0,
},
},
{
"files": ".github/workflows/*.js",
"parserOptions": {
"ecmaVersion": 2019,
},
"rules": {
"camelcase": 0,
"no-console": 0,
"no-restricted-syntax": 0,
},
},
],
}
"eslint-plugin/consistent-output": 0,
"eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
"eslint-plugin/require-meta-schema": 0,
"eslint-plugin/require-meta-type": 0
},
"overrides": [
{
"files": "tests/**",
"rules": {
"no-template-curly-in-string": 1,
},
},
{
"files": "markdown.config.js",
"rules": {
"no-console": 0,
},
},
{
"files": ".github/workflows/*.js",
"parserOptions": {
"ecmaVersion": 2019,
},
"rules": {
"camelcase": 0,
"no-console": 0,
"no-restricted-syntax": 0,
},
},
],
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## Unreleased

### Added

* [`jsx-closing-tag-location`]: add `line-aligned` option ([#3777] @kimtaejin3)

### Fixed

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

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

## [7.34.3] - 2024.06.18
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/jsx-closing-tag-location.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ const App = <Bar>
Foo
</Bar>;

<<<<<<< HEAD
=======

>>>>>>> b381547982addc145bd58a184a18e4e6665d2b03
```

## When Not To Use It
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/forbid-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const docsUrl = require('../util/docsUrl');
const getText = require('../util/eslint').getText;
const isCreateElement = require('../util/isCreateElement');
Expand Down Expand Up @@ -60,6 +60,7 @@ module.exports = {
const configuration = context.options[0] || {};
const forbidConfiguration = configuration.forbid || [];

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

forbidConfiguration.forEach((item) => {
Expand Down
10 changes: 6 additions & 4 deletions lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const repeat = require('string.prototype.repeat');

const docsUrl = require('../util/docsUrl');
const getSourceCode = require('../util/eslint').getSourceCode;
const report = require('../util/report');
Expand Down Expand Up @@ -168,7 +170,7 @@ module.exports = {
function getIndentation(tokens, expectedLocation, correctColumn) {
const newColumn = correctColumn || 0;
let indentation;
let spaces = [];
let spaces = '';
switch (expectedLocation) {
case 'props-aligned':
indentation = /^\s*/.exec(getSourceCode(context).lines[tokens.lastProp.firstLine - 1])[0];
Expand All @@ -182,9 +184,9 @@ module.exports = {
}
if (indentation.length + 1 < newColumn) {
// Non-whitespace characters were included in the column offset
spaces = new Array(+correctColumn + 1 - indentation.length);
spaces = repeat(' ', +correctColumn + 1 - indentation.length);
}
return indentation + spaces.join(' ');
return indentation + spaces;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/jsx-closing-tag-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

'use strict';

const has = require('object.hasown/polyfill')();
const repeat = require('string.prototype.repeat');
const has = require('hasown');

const astUtil = require('../util/ast');
const docsUrl = require('../util/docsUrl');
const getSourceCode = require('../util/eslint').getSourceCode;
Expand Down Expand Up @@ -109,7 +111,7 @@ module.exports = {
node,
loc: node.loc,
fix(fixer) {
const indent = Array(getIndentation(openingStartOfLine, opening)).join(' ');
const indent = repeat(' ', getIndentation(openingStartOfLine, opening));

if (astUtil.isNodeFirstInLine(context, node)) {
return fixer.replaceTextRange(
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-curly-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const docsUrl = require('../util/docsUrl');
const getSourceCode = require('../util/eslint').getSourceCode;
const report = require('../util/report');
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/jsx-indent-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

'use strict';

const repeat = require('string.prototype.repeat');

const astUtil = require('../util/ast');
const docsUrl = require('../util/docsUrl');
const getText = require('../util/eslint').getText;
Expand Down Expand Up @@ -130,7 +132,8 @@ module.exports = {
data: msgContext,
fix(fixer) {
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]],
Array(needed + 1).join(indentType === 'space' ? ' ' : '\t'));
repeat(indentType === 'space' ? ' ' : '\t', needed + 1)
);
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'use strict';

const matchAll = require('string.prototype.matchall');
const repeat = require('string.prototype.repeat');

const astUtil = require('../util/ast');
const docsUrl = require('../util/docsUrl');
Expand Down Expand Up @@ -109,7 +110,7 @@ module.exports = {
* @private
*/
function getFixerFunction(node, needed) {
const indent = Array(needed + 1).join(indentChar);
const indent = repeat(indentChar, needed + 1);

if (node.type === 'JSXText' || node.type === 'Literal') {
return function fix(fixer) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-max-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const includes = require('array-includes');
const variableUtil = require('../util/variable');
const jsxUtil = require('../util/jsx');
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-duplicate-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const docsUrl = require('../util/docsUrl');
const report = require('../util/report');

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-wrap-multilines.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const docsUrl = require('../util/docsUrl');
const eslintUtil = require('../util/eslint');
const jsxUtil = require('../util/jsx');
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-array-index-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const astUtil = require('../util/ast');
const docsUrl = require('../util/docsUrl');
const pragma = require('../util/pragma');
Expand Down Expand Up @@ -117,6 +117,8 @@ module.exports = {
return null;
}

const name = /** @type {keyof iteratorFunctionsToIndexParamPosition} */ (callee.property.name);

const callbackArg = isUsingReactChildren(node)
? node.arguments[1]
: node.arguments[0];
Expand All @@ -131,7 +133,7 @@ module.exports = {

const params = callbackArg.params;

const indexParamPosition = iteratorFunctionsToIndexParamPosition[callee.property.name];
const indexParamPosition = iteratorFunctionsToIndexParamPosition[name];
if (params.length < indexParamPosition + 1) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-danger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const fromEntries = require('object.fromentries/polyfill')();

const docsUrl = require('../util/docsUrl');
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

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

// Some attributes are allowed on some tags only
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[name] : null;
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[/** @type {keyof ATTRIBUTE_TAGS_MAP} */ (name)] : null;
if (tagName && allowedTags) {
// Scenario 1A: Allowed attribute found where not supposed to, report it
if (allowedTags.indexOf(tagName) === -1) {
Expand Down
19 changes: 9 additions & 10 deletions lib/rules/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const has = require('object.hasown/polyfill')();
const has = require('hasown');
const entries = require('object.entries');
const values = require('object.values');
const arrayIncludes = require('array-includes');
Expand Down Expand Up @@ -124,6 +124,7 @@ module.exports = {
},

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

Expand Down Expand Up @@ -287,15 +288,13 @@ module.exports = {
* Dedupe errors, only keep the ones with the highest score and delete the others
*/
function dedupeErrors() {
for (const i in errors) {
if (has(errors, i)) {
const index = errors[i].closest.ref.index;
if (errors[index]) {
if (errors[i].score > errors[index].score) {
delete errors[index];
} else {
delete errors[i];
}
for (let i = 0; i < errors.length; i += 1) {
const index = errors[i].closest.ref.index;
if (errors[index]) {
if (errors[i].score > errors[index].score) {
delete errors[index];
} else {
delete errors[i];
}
}
}
Expand Down
Loading

0 comments on commit c5c7494

Please sign in to comment.