Skip to content

Commit

Permalink
[patch] make TS happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 4, 2024
1 parent f05bd18 commit 380e32c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 60 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,
},
},
],
}
1 change: 1 addition & 0 deletions lib/rules/forbid-elements.js
Original file line number Diff line number Diff line change
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
4 changes: 3 additions & 1 deletion lib/rules/no-array-index-key.js
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
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

0 comments on commit 380e32c

Please sign in to comment.