eslint-plugin-react
Advanced tools
Comparing version 7.37.2 to 7.37.3
106
index.d.ts
@@ -28,23 +28,3 @@ export = plugin; | ||
'forbid-prop-types': import("eslint").Rule.RuleModule; | ||
'forward-ref-uses-ref': { | ||
meta: { | ||
docs: { | ||
description: string; | ||
category: string; | ||
recommended: boolean; | ||
url: string; | ||
}; | ||
messages: { | ||
missingRefParameter: string; | ||
addRefParameter: string; | ||
removeForwardRef: string; | ||
}; | ||
schema: undefined[]; | ||
type: string; | ||
hasSuggestions: boolean; | ||
}; | ||
create(context: any): { | ||
'FunctionExpression, ArrowFunctionExpression'(node: any): void; | ||
}; | ||
}; | ||
'forward-ref-uses-ref': import("eslint").Rule.RuleModule; | ||
'function-component-definition': import("eslint").Rule.RuleModule; | ||
@@ -74,19 +54,3 @@ 'hook-use-state': import("eslint").Rule.RuleModule; | ||
'jsx-no-leaked-render': import("eslint").Rule.RuleModule; | ||
'jsx-no-literals': { | ||
meta: import("eslint").Rule.RuleMetaData; | ||
create(context: any): (false & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}) | ({ | ||
ImportDeclaration(node: any): void; | ||
VariableDeclaration(node: any): void; | ||
} & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}); | ||
}; | ||
'jsx-no-literals': import("eslint").Rule.RuleModule; | ||
'jsx-no-script-url': import("eslint").Rule.RuleModule; | ||
@@ -102,19 +66,3 @@ 'jsx-no-target-blank': import("eslint").Rule.RuleModule; | ||
'jsx-props-no-spreading': import("eslint").Rule.RuleModule; | ||
'jsx-props-no-spread-multi': { | ||
meta: { | ||
docs: { | ||
description: string; /** @type {Record<keyof typeof activeRules, 2 | 'error'>} */ | ||
category: string; | ||
recommended: boolean; | ||
url: string; | ||
}; | ||
/** @type {Partial<typeof allRules>} */ | ||
messages: { | ||
noMultiSpreading: string; | ||
}; | ||
}; | ||
create(context: any): { | ||
JSXOpeningElement(node: any): void; | ||
}; | ||
}; | ||
'jsx-props-no-spread-multi': import("eslint").Rule.RuleModule; | ||
'jsx-sort-default-props': import("eslint").Rule.RuleModule; | ||
@@ -185,24 +133,24 @@ 'jsx-sort-props': import("eslint").Rule.RuleModule; | ||
rules: { | ||
'react/display-name': number; | ||
'react/jsx-key': number; | ||
'react/jsx-no-comment-textnodes': number; | ||
'react/jsx-no-duplicate-props': number; | ||
'react/jsx-no-target-blank': number; | ||
'react/jsx-no-undef': number; | ||
'react/jsx-uses-react': number; | ||
'react/jsx-uses-vars': number; | ||
'react/no-children-prop': number; | ||
'react/no-danger-with-children': number; | ||
'react/no-deprecated': number; | ||
'react/no-direct-mutation-state': number; | ||
'react/no-find-dom-node': number; | ||
'react/no-is-mounted': number; | ||
'react/no-render-return-value': number; | ||
'react/no-string-refs': number; | ||
'react/no-unescaped-entities': number; | ||
'react/no-unknown-property': number; | ||
'react/no-unsafe': number; | ||
'react/prop-types': number; | ||
'react/react-in-jsx-scope': number; | ||
'react/require-render-return': number; | ||
'react/display-name': 2; | ||
'react/jsx-key': 2; | ||
'react/jsx-no-comment-textnodes': 2; | ||
'react/jsx-no-duplicate-props': 2; | ||
'react/jsx-no-target-blank': 2; | ||
'react/jsx-no-undef': 2; | ||
'react/jsx-uses-react': 2; | ||
'react/jsx-uses-vars': 2; | ||
'react/no-children-prop': 2; | ||
'react/no-danger-with-children': 2; | ||
'react/no-deprecated': 2; | ||
'react/no-direct-mutation-state': 2; | ||
'react/no-find-dom-node': 2; | ||
'react/no-is-mounted': 2; | ||
'react/no-render-return-value': 2; | ||
'react/no-string-refs': 2; | ||
'react/no-unescaped-entities': 2; | ||
'react/no-unknown-property': 2; | ||
'react/no-unsafe': 0; | ||
'react/prop-types': 2; | ||
'react/react-in-jsx-scope': 2; | ||
'react/require-render-return': 2; | ||
}; | ||
@@ -228,4 +176,4 @@ }; | ||
rules: { | ||
'react/react-in-jsx-scope': number; | ||
'react/jsx-uses-react': number; | ||
'react/react-in-jsx-scope': 0; | ||
'react/jsx-uses-react': 0; | ||
}; | ||
@@ -232,0 +180,0 @@ }; |
54
index.js
@@ -14,3 +14,3 @@ 'use strict'; | ||
* @param {object} rules - rules object mapping rule name to rule module | ||
* @returns {Record<string, 2 | 'error'>} | ||
* @returns {Record<string, SEVERITY_ERROR | 'error'>} | ||
*/ | ||
@@ -35,2 +35,6 @@ function configureAsError(rules) { | ||
// TODO: with TS 4.5+, inline this | ||
const SEVERITY_ERROR = /** @type {2} */ (2); | ||
const SEVERITY_OFF = /** @type {0} */ (0); | ||
const configs = { | ||
@@ -45,24 +49,24 @@ recommended: { | ||
rules: { | ||
'react/display-name': 2, | ||
'react/jsx-key': 2, | ||
'react/jsx-no-comment-textnodes': 2, | ||
'react/jsx-no-duplicate-props': 2, | ||
'react/jsx-no-target-blank': 2, | ||
'react/jsx-no-undef': 2, | ||
'react/jsx-uses-react': 2, | ||
'react/jsx-uses-vars': 2, | ||
'react/no-children-prop': 2, | ||
'react/no-danger-with-children': 2, | ||
'react/no-deprecated': 2, | ||
'react/no-direct-mutation-state': 2, | ||
'react/no-find-dom-node': 2, | ||
'react/no-is-mounted': 2, | ||
'react/no-render-return-value': 2, | ||
'react/no-string-refs': 2, | ||
'react/no-unescaped-entities': 2, | ||
'react/no-unknown-property': 2, | ||
'react/no-unsafe': 0, | ||
'react/prop-types': 2, | ||
'react/react-in-jsx-scope': 2, | ||
'react/require-render-return': 2, | ||
'react/display-name': SEVERITY_ERROR, | ||
'react/jsx-key': SEVERITY_ERROR, | ||
'react/jsx-no-comment-textnodes': SEVERITY_ERROR, | ||
'react/jsx-no-duplicate-props': SEVERITY_ERROR, | ||
'react/jsx-no-target-blank': SEVERITY_ERROR, | ||
'react/jsx-no-undef': SEVERITY_ERROR, | ||
'react/jsx-uses-react': SEVERITY_ERROR, | ||
'react/jsx-uses-vars': SEVERITY_ERROR, | ||
'react/no-children-prop': SEVERITY_ERROR, | ||
'react/no-danger-with-children': SEVERITY_ERROR, | ||
'react/no-deprecated': SEVERITY_ERROR, | ||
'react/no-direct-mutation-state': SEVERITY_ERROR, | ||
'react/no-find-dom-node': SEVERITY_ERROR, | ||
'react/no-is-mounted': SEVERITY_ERROR, | ||
'react/no-render-return-value': SEVERITY_ERROR, | ||
'react/no-string-refs': SEVERITY_ERROR, | ||
'react/no-unescaped-entities': SEVERITY_ERROR, | ||
'react/no-unknown-property': SEVERITY_ERROR, | ||
'react/no-unsafe': SEVERITY_OFF, | ||
'react/prop-types': SEVERITY_ERROR, | ||
'react/react-in-jsx-scope': SEVERITY_ERROR, | ||
'react/require-render-return': SEVERITY_ERROR, | ||
}, | ||
@@ -88,4 +92,4 @@ }, | ||
rules: { | ||
'react/react-in-jsx-scope': 0, | ||
'react/jsx-uses-react': 0, | ||
'react/react-in-jsx-scope': SEVERITY_OFF, | ||
'react/jsx-uses-react': SEVERITY_OFF, | ||
}, | ||
@@ -92,0 +96,0 @@ }, |
@@ -112,3 +112,3 @@ /** | ||
)) || ( | ||
// @ts-expect-error The JSXText type is not present in the estree type definitions | ||
// @ts-expect-error: The JSXText type is not present in the estree type definitions | ||
(node.property.type === 'Literal' || node.property.type === 'JSXText') | ||
@@ -115,0 +115,0 @@ && 'value' in node.property |
@@ -198,2 +198,3 @@ /** | ||
&& specifier.imported | ||
&& 'name' in specifier.imported | ||
&& specifier.imported.name === 'PropTypes' | ||
@@ -200,0 +201,0 @@ )); |
@@ -1,23 +0,3 @@ | ||
export declare const meta: { | ||
docs: { | ||
description: string; | ||
category: string; | ||
recommended: boolean; | ||
url: string; | ||
}; | ||
messages: { | ||
missingRefParameter: string; | ||
addRefParameter: string; | ||
removeForwardRef: string; | ||
}; | ||
schema: any[]; | ||
type: string; | ||
hasSuggestions: boolean; | ||
}; | ||
export declare function create(context: any): { | ||
'FunctionExpression, ArrowFunctionExpression'(node: any): void; | ||
}; | ||
export declare function create(context: any): { | ||
'FunctionExpression, ArrowFunctionExpression'(node: any): void; | ||
}; | ||
declare const _exports: import('eslint').Rule.RuleModule; | ||
export = _exports; | ||
//# sourceMappingURL=forward-ref-uses-ref.d.ts.map |
@@ -44,2 +44,3 @@ /** | ||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
@@ -46,0 +47,0 @@ meta: { |
@@ -1,2 +0,4 @@ | ||
declare const _exports: { | ||
export = rules; | ||
/** @satisfies {Record<string, import('eslint').Rule.RuleModule>} */ | ||
declare const rules: { | ||
'boolean-prop-naming': import("eslint").Rule.RuleModule; | ||
@@ -13,23 +15,3 @@ 'button-has-type': import("eslint").Rule.RuleModule; | ||
'forbid-prop-types': import("eslint").Rule.RuleModule; | ||
'forward-ref-uses-ref': { | ||
meta: { | ||
docs: { | ||
description: string; | ||
category: string; | ||
recommended: boolean; | ||
url: string; | ||
}; | ||
messages: { | ||
missingRefParameter: string; | ||
addRefParameter: string; | ||
removeForwardRef: string; | ||
}; | ||
schema: undefined[]; | ||
type: string; | ||
hasSuggestions: boolean; | ||
}; | ||
create(context: any): { | ||
'FunctionExpression, ArrowFunctionExpression'(node: any): void; | ||
}; | ||
}; | ||
'forward-ref-uses-ref': import("eslint").Rule.RuleModule; | ||
'function-component-definition': import("eslint").Rule.RuleModule; | ||
@@ -59,19 +41,3 @@ 'hook-use-state': import("eslint").Rule.RuleModule; | ||
'jsx-no-leaked-render': import("eslint").Rule.RuleModule; | ||
'jsx-no-literals': { | ||
meta: import("eslint").Rule.RuleMetaData; | ||
create(context: any): (false & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}) | ({ | ||
ImportDeclaration(node: any): void; | ||
VariableDeclaration(node: any): void; | ||
} & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}); | ||
}; | ||
'jsx-no-literals': import("eslint").Rule.RuleModule; | ||
'jsx-no-script-url': import("eslint").Rule.RuleModule; | ||
@@ -87,18 +53,3 @@ 'jsx-no-target-blank': import("eslint").Rule.RuleModule; | ||
'jsx-props-no-spreading': import("eslint").Rule.RuleModule; | ||
'jsx-props-no-spread-multi': { | ||
meta: { | ||
docs: { | ||
description: string; | ||
category: string; | ||
recommended: boolean; | ||
url: string; | ||
}; | ||
messages: { | ||
noMultiSpreading: string; | ||
}; | ||
}; | ||
create(context: any): { | ||
JSXOpeningElement(node: any): void; | ||
}; | ||
}; | ||
'jsx-props-no-spread-multi': import("eslint").Rule.RuleModule; | ||
'jsx-sort-default-props': import("eslint").Rule.RuleModule; | ||
@@ -160,3 +111,2 @@ 'jsx-sort-props': import("eslint").Rule.RuleModule; | ||
}; | ||
export = _exports; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,3 +6,3 @@ 'use strict'; | ||
/** @satisfies {Record<string, import('eslint').Rule.RuleModule>} */ | ||
module.exports = { | ||
const rules = { | ||
'boolean-prop-naming': require('./boolean-prop-naming'), | ||
@@ -112,1 +112,3 @@ 'button-has-type': require('./button-has-type'), | ||
}; | ||
module.exports = rules; |
@@ -173,3 +173,8 @@ /** | ||
node.specifiers.forEach((spec) => { | ||
if ('imported' in spec && spec.imported && spec.imported.name === fragmentPragma) { | ||
if ( | ||
'imported' in spec | ||
&& spec.imported | ||
&& 'name' in spec.imported | ||
&& spec.imported.name === fragmentPragma | ||
) { | ||
if (spec.local) { | ||
@@ -176,0 +181,0 @@ fragmentNames.add(spec.local.name); |
@@ -22,2 +22,10 @@ /** | ||
function isPrefixDisabled(prefix) { | ||
return prefix === false; | ||
} | ||
function isInlineHandler(node) { | ||
return node.value.expression.type === 'ArrowFunctionExpression'; | ||
} | ||
/** @type {import('eslint').Rule.RuleModule} */ | ||
@@ -113,10 +121,2 @@ module.exports = { | ||
create(context) { | ||
function isPrefixDisabled(prefix) { | ||
return prefix === false; | ||
} | ||
function isInlineHandler(node) { | ||
return node.value.expression.type === 'ArrowFunctionExpression'; | ||
} | ||
const configuration = context.options[0] || {}; | ||
@@ -148,6 +148,6 @@ | ||
const isComponentNameIgnored = ignoreComponentNames.some((ignoredComponentNamePattern) => { | ||
const isIgnored = minimatch(componentName, ignoredComponentNamePattern); | ||
return isIgnored; | ||
}); | ||
const isComponentNameIgnored = ignoreComponentNames.some((ignoredComponentNamePattern) => minimatch( | ||
componentName, | ||
ignoredComponentNamePattern | ||
)); | ||
@@ -154,0 +154,0 @@ if ( |
@@ -1,81 +0,13 @@ | ||
export type RawElementConfigProperties = { | ||
noStrings?: boolean; | ||
allowedStrings?: string[]; | ||
ignoreProps?: boolean; | ||
noAttributeStrings?: boolean; | ||
}; | ||
export type RawOverrideConfigProperties = { | ||
allowElement?: boolean; | ||
applyToNestedElements?: boolean; | ||
}; | ||
export type RawElementConfig = { | ||
noStrings?: boolean; | ||
allowedStrings?: string[]; | ||
ignoreProps?: boolean; | ||
noAttributeStrings?: boolean; | ||
}; | ||
export type RawOverrideConfig = { | ||
noStrings?: boolean; | ||
allowedStrings?: string[]; | ||
ignoreProps?: boolean; | ||
noAttributeStrings?: boolean; | ||
}; | ||
export type RawElementOverrides = { | ||
elementOverrides?: Record<string, RawOverrideConfig>; | ||
}; | ||
/** | ||
* ---------------------------------------------------------------------- | ||
*/ | ||
export type RawConfig = RawElementConfigProperties & RawElementOverrides; | ||
export type ElementConfigType = { | ||
type: 'element'; | ||
}; | ||
export type ElementConfigProperties = { | ||
noStrings: boolean; | ||
allowedStrings: Set<string>; | ||
ignoreProps: boolean; | ||
noAttributeStrings: boolean; | ||
}; | ||
export type OverrideConfigProperties = { | ||
type: 'override'; | ||
name: string; | ||
allowElement: boolean; | ||
applyToNestedElements: boolean; | ||
}; | ||
export type ElementConfig = ElementConfigType & ElementConfigProperties; | ||
export type OverrideConfig = OverrideConfigProperties & ElementConfigProperties; | ||
export type ElementOverrides = { | ||
elementOverrides: Record<string, OverrideConfig>; | ||
}; | ||
export type Config = ElementConfigType & ElementConfigProperties & ElementOverrides; | ||
export type ResolvedConfig = (OverrideConfigProperties & ElementConfigProperties) | (ElementConfigType & ElementConfigProperties & ElementOverrides); | ||
export declare const meta: import('eslint').Rule.RuleModule["meta"]; | ||
export declare function create(context: any): (false & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}) | ({ | ||
ImportDeclaration(node: any): void; | ||
VariableDeclaration(node: any): void; | ||
} & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}); | ||
export declare function create(context: any): (false & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}) | ({ | ||
ImportDeclaration(node: any): void; | ||
VariableDeclaration(node: any): void; | ||
} & { | ||
Literal(node: any): void; | ||
JSXAttribute(node: any): void; | ||
JSXText(node: any): void; | ||
TemplateLiteral(node: any): void; | ||
}); | ||
declare const _exports: RuleModule; | ||
export = _exports; | ||
export type RuleModule = import("eslint").Rule.RuleModule; | ||
export type Config = { | ||
type: "element"; | ||
} & import("../../types/rules/jsx-no-literals").ElementConfigProperties & import("../../types/rules/jsx-no-literals").ElementOverrides; | ||
export type RawConfig = import("../../types/rules/jsx-no-literals").RawElementConfig & import("../../types/rules/jsx-no-literals").RawElementOverrides; | ||
export type ResolvedConfig = import("../../types/rules/jsx-no-literals").OverrideConfig | import("../../types/rules/jsx-no-literals").Config; | ||
export type OverrideConfig = import("../../types/rules/jsx-no-literals").OverrideConfigProperties & import("../../types/rules/jsx-no-literals").ElementConfigProperties; | ||
export type ElementConfig = { | ||
type: "element"; | ||
} & import("../../types/rules/jsx-no-literals").ElementConfigProperties; | ||
//# sourceMappingURL=jsx-no-literals.d.ts.map |
@@ -20,2 +20,10 @@ /** | ||
/** @typedef {import('eslint').Rule.RuleModule} RuleModule */ | ||
/** @typedef {import('../../types/rules/jsx-no-literals').Config} Config */ | ||
/** @typedef {import('../../types/rules/jsx-no-literals').RawConfig} RawConfig */ | ||
/** @typedef {import('../../types/rules/jsx-no-literals').ResolvedConfig} ResolvedConfig */ | ||
/** @typedef {import('../../types/rules/jsx-no-literals').OverrideConfig} OverrideConfig */ | ||
/** @typedef {import('../../types/rules/jsx-no-literals').ElementConfig} ElementConfig */ | ||
// ------------------------------------------------------------------------------ | ||
@@ -49,3 +57,3 @@ // Rule Definition | ||
/** @type {Exclude<import('eslint').Rule.RuleModule['meta']['schema'], unknown[]>['properties']} */ | ||
/** @type {Exclude<RuleModule['meta']['schema'], unknown[] | false>['properties']} */ | ||
const commonPropertiesSchema = { | ||
@@ -70,49 +78,4 @@ noStrings: { | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @typedef RawElementConfigProperties | ||
* @property {boolean} [noStrings] | ||
* @property {string[]} [allowedStrings] | ||
* @property {boolean} [ignoreProps] | ||
* @property {boolean} [noAttributeStrings] | ||
* | ||
* @typedef RawOverrideConfigProperties | ||
* @property {boolean} [allowElement] | ||
* @property {boolean} [applyToNestedElements=true] | ||
* | ||
* @typedef {RawElementConfigProperties} RawElementConfig | ||
* @typedef {RawElementConfigProperties & RawElementConfigProperties} RawOverrideConfig | ||
* | ||
* @typedef RawElementOverrides | ||
* @property {Record<string, RawOverrideConfig>} [elementOverrides] | ||
* | ||
* @typedef {RawElementConfig & RawElementOverrides} RawConfig | ||
* | ||
* ---------------------------------------------------------------------- | ||
* | ||
* @typedef ElementConfigType | ||
* @property {'element'} type | ||
* | ||
* @typedef ElementConfigProperties | ||
* @property {boolean} noStrings | ||
* @property {Set<string>} allowedStrings | ||
* @property {boolean} ignoreProps | ||
* @property {boolean} noAttributeStrings | ||
* | ||
* @typedef OverrideConfigProperties | ||
* @property {'override'} type | ||
* @property {string} name | ||
* @property {boolean} allowElement | ||
* @property {boolean} applyToNestedElements | ||
* | ||
* @typedef {ElementConfigType & ElementConfigProperties} ElementConfig | ||
* @typedef {OverrideConfigProperties & ElementConfigProperties} OverrideConfig | ||
* | ||
* @typedef ElementOverrides | ||
* @property {Record<string, OverrideConfig>} elementOverrides | ||
* | ||
* @typedef {ElementConfig & ElementOverrides} Config | ||
* @typedef {Config | OverrideConfig} ResolvedConfig | ||
*/ | ||
/** | ||
* Normalizes the element portion of the config | ||
@@ -134,2 +97,3 @@ * @param {RawConfig} config | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -189,4 +153,5 @@ * Normalizes the config and applies default values to all config options | ||
/** @type {RuleModule} */ | ||
module.exports = { | ||
meta: /** @type {import('eslint').Rule.RuleModule["meta"]} */ ({ | ||
meta: /** @type {RuleModule['meta']} */ ({ | ||
docs: { | ||
@@ -347,2 +312,3 @@ description: 'Disallow usage of string literals in JSX', | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -379,2 +345,3 @@ * Determines whether a given node's value and its immediate parent are | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -418,2 +385,3 @@ * Gets an override config for a given node. For any given node, we also | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -427,2 +395,3 @@ * @param {ResolvedConfig} resolvedConfig | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -445,2 +414,3 @@ * @param {boolean} ancestorIsJSXElement | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
@@ -447,0 +417,0 @@ * @param {ASTNode} node |
@@ -1,20 +0,3 @@ | ||
declare namespace messages { | ||
export const noMultiSpreading: string; | ||
} | ||
export declare namespace meta { | ||
export namespace docs { | ||
export const description: string; | ||
export const category: string; | ||
export const recommended: boolean; | ||
export const url: string; | ||
} | ||
export { messages }; | ||
} | ||
export declare function create(context: any): { | ||
JSXOpeningElement(node: any): void; | ||
}; | ||
export declare function create(context: any): { | ||
JSXOpeningElement(node: any): void; | ||
}; | ||
export {}; | ||
declare const _exports: import('eslint').Rule.RuleModule; | ||
export = _exports; | ||
//# sourceMappingURL=jsx-props-no-spread-multi.d.ts.map |
@@ -19,2 +19,3 @@ /** | ||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
@@ -21,0 +22,0 @@ meta: { |
@@ -62,3 +62,3 @@ /** | ||
const leftToken = getTokenBeforeClosingBracket(node); | ||
const closingSlash = /** @type {import("eslint").AST.Token} */ (sourceCode.getTokenAfter(leftToken)); | ||
const closingSlash = /** @type {import('eslint').AST.Token} */ (sourceCode.getTokenAfter(leftToken)); | ||
@@ -65,0 +65,0 @@ if (leftToken.loc.end.line !== closingSlash.loc.start.line) { |
@@ -119,3 +119,3 @@ /** | ||
) { | ||
/** @type {import("eslint").Rule.Node} */ | ||
/** @type {import('eslint').Rule.Node} */ | ||
let current = node; | ||
@@ -167,3 +167,3 @@ while (current.type !== 'Program') { | ||
// Checks if the identifier is a variable within an object | ||
/** @type {import("eslint").Rule.Node} */ | ||
/** @type {import('eslint').Rule.Node} */ | ||
let current = node; | ||
@@ -170,0 +170,0 @@ while (current.parent.type === 'BinaryExpression') { |
@@ -80,3 +80,4 @@ /** | ||
JSXAttribute(node) { | ||
const functionName = node.parent.name.name; | ||
const nodeName = node.parent.name; | ||
const functionName = nodeName.name || `${nodeName.object.name}.${nodeName.property.name}`; | ||
@@ -83,0 +84,0 @@ const enableCheckingCustomComponent = customComponentNames.some((name) => minimatch(functionName, name)); |
@@ -232,3 +232,3 @@ /** | ||
// TODO, semver-major: remove `in` check as part of jsdoc->tsdoc migration | ||
checkDeprecation(node, 'imported' in specifier && `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier); | ||
checkDeprecation(node, 'imported' in specifier && 'name' in specifier.imported && `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier); | ||
}); | ||
@@ -235,0 +235,0 @@ }, |
@@ -366,12 +366,20 @@ /** | ||
function getDOMPropertyNames(context) { | ||
const ALL_DOM_PROPERTY_NAMES = DOM_PROPERTY_NAMES_TWO_WORDS.concat(DOM_PROPERTY_NAMES_ONE_WORD); | ||
// this was removed in React v16.1+, see https://github.com/facebook/react/pull/10823 | ||
if (!testReactVersion(context, '>= 16.1.0')) { | ||
return ALL_DOM_PROPERTY_NAMES.concat('allowTransparency'); | ||
} | ||
// these were added in React v16.4.0, see https://reactjs.org/blog/2018/05/23/react-v-16-4.html and https://github.com/facebook/react/pull/12507 | ||
if (testReactVersion(context, '>= 16.4.0')) { | ||
return ALL_DOM_PROPERTY_NAMES.concat(REACT_ON_PROPS); | ||
} | ||
return ALL_DOM_PROPERTY_NAMES; | ||
return [].concat( | ||
DOM_PROPERTY_NAMES_TWO_WORDS, | ||
DOM_PROPERTY_NAMES_ONE_WORD, | ||
testReactVersion(context, '>= 16.1.0') ? [].concat( | ||
testReactVersion(context, '>= 16.4.0') ? [].concat( | ||
// these were added in React v16.4.0, see https://reactjs.org/blog/2018/05/23/react-v-16-4.html and https://github.com/facebook/react/pull/12507 | ||
REACT_ON_PROPS, | ||
testReactVersion(context, '>= 19') ? [ | ||
// precedence was added in React v19, see https://react.dev/blog/2024/04/25/react-19#support-for-stylesheets | ||
'precedence', | ||
] : [] | ||
) : [] | ||
) : [ | ||
// this was removed in React v16.1+, see https://github.com/facebook/react/pull/10823 | ||
'allowTransparency', | ||
] | ||
); | ||
} | ||
@@ -505,2 +513,3 @@ | ||
const names = getDOMPropertyNames(context); | ||
// Let's find a possible attribute match with a case-insensitive search. | ||
@@ -507,0 +516,0 @@ return names.find((element) => element.toLowerCase() === name.toLowerCase()); |
@@ -471,3 +471,3 @@ /** | ||
// Find the nearest function expression containing this assignment. | ||
/** @type {import("eslint").Rule.Node} */ | ||
/** @type {import('eslint').Rule.Node} */ | ||
let fn = node; | ||
@@ -474,0 +474,0 @@ while (fn.type !== 'FunctionExpression' && fn.parent) { |
@@ -110,4 +110,6 @@ /** | ||
const customValidators = configuration.customValidators; | ||
const allowedGenericTypes = new Set(['forwardRef', 'ForwardRefRenderFunction', 'VFC', 'VoidFunctionComponent', 'PropsWithChildren', 'SFC', 'StatelessComponent', 'FunctionComponent', 'FC']); | ||
const allowedGenericTypes = new Set(['ComponentProps', 'ComponentPropsWithoutRef', 'forwardRef', 'ForwardRefRenderFunction', 'VFC', 'VoidFunctionComponent', 'PropsWithChildren', 'SFC', 'StatelessComponent', 'FunctionComponent', 'FC']); | ||
const genericTypeParamIndexWherePropsArePresent = { | ||
ComponentProps: 0, | ||
ComponentPropsWithoutRef: 0, | ||
ForwardRefRenderFunction: 1, | ||
@@ -114,0 +116,0 @@ forwardRef: 1, |
@@ -65,4 +65,3 @@ /** | ||
if (typeof settingsDefaultVersion !== 'string') { | ||
error('Warning: default React version specified in eslint-pluigin-react-settings must be a string; ' | ||
+ `got "${typeof settingsDefaultVersion}"`); | ||
error(`Warning: default React version specified in eslint-pluigin-react-settings must be a string; got "${typeof settingsDefaultVersion}"`); | ||
} | ||
@@ -121,9 +120,7 @@ settingsDefaultVersion = String(settingsDefaultVersion); | ||
if (typeof settingsVersion !== 'string') { | ||
error('Warning: React version specified in eslint-plugin-react-settings must be a string; ' | ||
+ `got “${typeof settingsVersion}”`); | ||
error(`Warning: React version specified in eslint-plugin-react-settings must be a string; got “${typeof settingsVersion}”`); | ||
} | ||
confVer = String(settingsVersion); | ||
} else if (!warnedForMissingVersion) { | ||
error('Warning: React version not specified in eslint-plugin-react settings. ' | ||
+ 'See https://github.com/jsx-eslint/eslint-plugin-react#configuration .'); | ||
error('Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration .'); | ||
warnedForMissingVersion = true; | ||
@@ -130,0 +127,0 @@ } |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "7.37.2", | ||
"version": "7.37.3", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -29,2 +29,9 @@ "description": "React specific linting rules for ESLint", | ||
}, | ||
"directories": { | ||
"test": [ | ||
"test", | ||
"tests", | ||
"test-published-types" | ||
] | ||
}, | ||
"homepage": "https://github.com/jsx-eslint/eslint-plugin-react", | ||
@@ -35,6 +42,6 @@ "bugs": "https://github.com/jsx-eslint/eslint-plugin-react/issues", | ||
"array.prototype.findlast": "^1.2.5", | ||
"array.prototype.flatmap": "^1.3.2", | ||
"array.prototype.flatmap": "^1.3.3", | ||
"array.prototype.tosorted": "^1.1.4", | ||
"doctrine": "^2.1.0", | ||
"es-iterator-helpers": "^1.1.0", | ||
"es-iterator-helpers": "^1.2.1", | ||
"estraverse": "^5.3.0", | ||
@@ -46,11 +53,11 @@ "hasown": "^2.0.2", | ||
"object.fromentries": "^2.0.8", | ||
"object.values": "^1.2.0", | ||
"object.values": "^1.2.1", | ||
"prop-types": "^15.8.1", | ||
"resolve": "^2.0.0-next.5", | ||
"semver": "^6.3.1", | ||
"string.prototype.matchall": "^4.0.11", | ||
"string.prototype.matchall": "^4.0.12", | ||
"string.prototype.repeat": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.25.9", | ||
"@babel/core": "^7.26.0", | ||
"@babel/eslint-parser": "^7.25.9", | ||
@@ -60,7 +67,7 @@ "@babel/plugin-syntax-decorators": "^7.25.9", | ||
"@babel/plugin-syntax-function-bind": "^7.25.9", | ||
"@babel/preset-react": "^7.25.9", | ||
"@babel/preset-react": "^7.26.3", | ||
"@types/eslint": "=7.2.10", | ||
"@types/estree": "0.0.52", | ||
"@types/node": "^4.9.5", | ||
"@typescript-eslint/parser": "^2.34.0 || ^3.10.1 || ^4 || ^5 || ^6.20 || ^7.14.1 || ^8.4", | ||
"@typescript-eslint/parser": "^2.34.0 || ^3.10.1 || ^4 || ^5 || ^6.20 || ^7.14.1 || 8.4 - 8.17", | ||
"babel-eslint": "^8 || ^9 || ^10.1.0", | ||
@@ -67,0 +74,0 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
935863
24064
Updatedes-iterator-helpers@^1.2.1
Updatedobject.values@^1.2.1