Skip to content

Commit f2c6548

Browse files
committed
Add annotations
1 parent e4ecbcf commit f2c6548

File tree

92 files changed

+171
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+171
-27
lines changed

lib/rules/boolean-prop-naming.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const messages = {
2222
patternMismatch: 'Prop name `{{propName}}` doesn’t match rule `{{pattern}}`',
2323
};
2424

25+
26+
/** @type { import('eslint').Rule.RuleModule } */
2527
module.exports = {
2628
meta: {
2729
docs: {

lib/rules/button-has-type.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const messages = {
2828
forbiddenValue: '"{{value}}" is an invalid value for button type attribute',
2929
};
3030

31+
/** @type { import('eslint').Rule.RuleModule } */
3132
module.exports = {
3233
meta: {
3334
docs: {
@@ -149,9 +150,11 @@ module.exports = {
149150
}
150151

151152
const props = node.arguments[1].properties;
152-
const typeProp = props.find((prop) => prop.key && prop.key.name === 'type');
153+
const typeProp = props.find(
154+
(prop) => prop.type === "Property" && prop.key && prop.key.type === "PrivateIdentifier" && prop.key.name === 'type'
155+
);
153156

154-
if (!typeProp) {
157+
if (typeProp.type !== "Property") {
155158
reportMissing(node);
156159
return;
157160
}

lib/rules/checked-requires-onchange-or-readonly.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const defaultOptions = {
2424
};
2525

2626
/**
27-
* @param {string[]} properties
27+
* @param {Array} properties
2828
* @param {string} keyName
2929
* @returns {Set<string>}
3030
*/
@@ -41,6 +41,7 @@ function extractTargetProps(properties, keyName) {
4141
);
4242
}
4343

44+
/** @type { import('eslint').Rule.RuleModule } */
4445
module.exports = {
4546
meta: {
4647
docs: {

lib/rules/default-props-match-prop-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const messages = {
2121
defaultHasNoType: 'defaultProp "{{name}}" has no corresponding propTypes declaration.',
2222
};
2323

24+
/** @type { import('eslint').Rule.RuleModule } */
2425
module.exports = {
2526
meta: {
2627
docs: {

lib/rules/destructuring-assignment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const messages = {
5353
destructureInSignature: 'Must destructure props in the function signature.',
5454
};
5555

56+
/** @type { import('eslint').Rule.RuleModule } */
5657
module.exports = {
5758
meta: {
5859
docs: {

lib/rules/display-name.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const messages = {
2727
noContextDisplayName: 'Context definition is missing display name',
2828
};
2929

30+
/** @type { import('eslint').Rule.RuleModule } */
3031
module.exports = {
3132
meta: {
3233
docs: {

lib/rules/forbid-component-props.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const messages = {
2222
propIsForbidden: 'Prop "{{prop}}" is forbidden on Components',
2323
};
2424

25+
/** @type { import('eslint').Rule.RuleModule } */
2526
module.exports = {
2627
meta: {
2728
docs: {

lib/rules/forbid-dom-props.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const messages = {
3737
propIsForbidden: 'Prop "{{prop}}" is forbidden on DOM Nodes',
3838
};
3939

40+
/** @type { import('eslint').Rule.RuleModule } */
4041
module.exports = {
4142
meta: {
4243
docs: {

lib/rules/forbid-elements.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const messages = {
1919
forbiddenElement_message: '<{{element}}> is forbidden, {{message}}',
2020
};
2121

22+
/** @type { import('eslint').Rule.RuleModule } */
2223
module.exports = {
2324
meta: {
2425
docs: {
@@ -103,13 +104,11 @@ module.exports = {
103104
return;
104105
}
105106

106-
const argType = argument.type;
107-
108-
if (argType === 'Identifier' && /^[A-Z_]/.test(argument.name)) {
107+
if (argument.type === 'Identifier' && /^[A-Z_]/.test(argument.name)) {
109108
reportIfForbidden(argument.name, argument);
110-
} else if (argType === 'Literal' && /^[a-z][^.]*$/.test(argument.value)) {
109+
} else if (argument.type === 'Literal' && /^[a-z][^.]*$/.test(argument.value.toString())) {
111110
reportIfForbidden(argument.value, argument);
112-
} else if (argType === 'MemberExpression') {
111+
} else if (argument.type === 'MemberExpression') {
113112
reportIfForbidden(context.getSourceCode().getText(argument), argument);
114113
}
115114
},

lib/rules/forbid-foreign-prop-types.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const messages = {
1313
forbiddenPropType: 'Using propTypes from another component is not safe because they may be removed in production builds',
1414
};
1515

16+
/** @type { import('eslint').Rule.RuleModule } */
1617
module.exports = {
1718
meta: {
1819
docs: {
@@ -108,7 +109,7 @@ module.exports = {
108109
&& !ast.isAssignmentLHS(node)
109110
&& !isAllowedAssignment(node)
110111
)) || (
111-
(node.property.type === 'Literal' || node.property.type === 'JSXText')
112+
node.property.type === 'Literal'
112113
&& node.property.value === 'propTypes'
113114
&& !ast.isAssignmentLHS(node)
114115
&& !isAllowedAssignment(node)
@@ -121,7 +122,9 @@ module.exports = {
121122
},
122123

123124
ObjectPattern(node) {
124-
const propTypesNode = node.properties.find((property) => property.type === 'Property' && property.key.name === 'propTypes');
125+
const propTypesNode = node.properties.find(
126+
(property) => property.type === 'Property' && property.key.type === "PrivateIdentifier" && property.key.name === 'propTypes'
127+
);
125128

126129
if (propTypesNode) {
127130
report(context, messages.forbiddenPropType, 'forbiddenPropType', {

0 commit comments

Comments
 (0)