Skip to content

Commit 4290504

Browse files
committed
[Fix] correct generated type declaration
1 parent 63aceff commit 4290504

File tree

9 files changed

+38
-30
lines changed

9 files changed

+38
-30
lines changed

index.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const plugins = [
2727
'react',
2828
];
2929

30+
const SEVERITY_ERROR = /** @type {2} */ (2);
31+
const SEVERITY_OFF = /** @type {0} */ (0);
32+
3033
const plugin = {
3134
deprecatedRules,
3235
rules: allRules,
@@ -39,28 +42,28 @@ const plugin = {
3942
},
4043
},
4144
rules: {
42-
'react/display-name': 2,
43-
'react/jsx-key': 2,
44-
'react/jsx-no-comment-textnodes': 2,
45-
'react/jsx-no-duplicate-props': 2,
46-
'react/jsx-no-target-blank': 2,
47-
'react/jsx-no-undef': 2,
48-
'react/jsx-uses-react': 2,
49-
'react/jsx-uses-vars': 2,
50-
'react/no-children-prop': 2,
51-
'react/no-danger-with-children': 2,
52-
'react/no-deprecated': 2,
53-
'react/no-direct-mutation-state': 2,
54-
'react/no-find-dom-node': 2,
55-
'react/no-is-mounted': 2,
56-
'react/no-render-return-value': 2,
57-
'react/no-string-refs': 2,
58-
'react/no-unescaped-entities': 2,
59-
'react/no-unknown-property': 2,
60-
'react/no-unsafe': 0,
61-
'react/prop-types': 2,
62-
'react/react-in-jsx-scope': 2,
63-
'react/require-render-return': 2,
45+
'react/display-name': SEVERITY_ERROR,
46+
'react/jsx-key': SEVERITY_ERROR,
47+
'react/jsx-no-comment-textnodes': SEVERITY_ERROR,
48+
'react/jsx-no-duplicate-props': SEVERITY_ERROR,
49+
'react/jsx-no-target-blank': SEVERITY_ERROR,
50+
'react/jsx-no-undef': SEVERITY_ERROR,
51+
'react/jsx-uses-react': SEVERITY_ERROR,
52+
'react/jsx-uses-vars': SEVERITY_ERROR,
53+
'react/no-children-prop': SEVERITY_ERROR,
54+
'react/no-danger-with-children': SEVERITY_ERROR,
55+
'react/no-deprecated': SEVERITY_ERROR,
56+
'react/no-direct-mutation-state': SEVERITY_ERROR,
57+
'react/no-find-dom-node': SEVERITY_ERROR,
58+
'react/no-is-mounted': SEVERITY_ERROR,
59+
'react/no-render-return-value': SEVERITY_ERROR,
60+
'react/no-string-refs': SEVERITY_ERROR,
61+
'react/no-unescaped-entities': SEVERITY_ERROR,
62+
'react/no-unknown-property': SEVERITY_ERROR,
63+
'react/no-unsafe': SEVERITY_OFF,
64+
'react/prop-types': SEVERITY_ERROR,
65+
'react/react-in-jsx-scope': SEVERITY_ERROR,
66+
'react/require-render-return': SEVERITY_ERROR,
6467
},
6568
},
6669
all: {
@@ -81,8 +84,8 @@ const plugin = {
8184
jsxPragma: null, // for @typescript/eslint-parser
8285
},
8386
rules: {
84-
'react/react-in-jsx-scope': 0,
85-
'react/jsx-uses-react': 0,
87+
'react/react-in-jsx-scope': SEVERITY_OFF,
88+
'react/jsx-uses-react': SEVERITY_OFF,
8689
},
8790
},
8891
},

lib/rules/forbid-prop-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ module.exports = {
195195
const propTypesSpecifier = node.specifiers.find((specifier) => (
196196
'imported' in specifier
197197
&& specifier.imported
198+
&& 'name' in specifier.imported
198199
&& specifier.imported.name === 'PropTypes'
199200
));
200201
if (propTypesSpecifier) {

lib/rules/forward-ref-uses-ref.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const messages = {
4141
removeForwardRef: 'Remove forwardRef wrapper',
4242
};
4343

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

lib/rules/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* eslint global-require: 0 */
44

55
/** @satisfies {Record<string, import('eslint').Rule.RuleModule>} */
6-
module.exports = {
6+
const rules = {
77
'boolean-prop-naming': require('./boolean-prop-naming'),
88
'button-has-type': require('./button-has-type'),
99
'checked-requires-onchange-or-readonly': require('./checked-requires-onchange-or-readonly'),
@@ -108,3 +108,5 @@ module.exports = {
108108
'style-prop-object': require('./style-prop-object'),
109109
'void-dom-elements-no-children': require('./void-dom-elements-no-children'),
110110
};
111+
112+
module.exports = rules;

lib/rules/jsx-fragments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module.exports = {
170170
ImportDeclaration(node) {
171171
if (node.source && node.source.value === 'react') {
172172
node.specifiers.forEach((spec) => {
173-
if ('imported' in spec && spec.imported && spec.imported.name === fragmentPragma) {
173+
if ('imported' in spec && spec.imported && 'name' in spec.imported && spec.imported.name === fragmentPragma) {
174174
if (spec.local) {
175175
fragmentNames.add(spec.local.name);
176176
}

lib/rules/jsx-no-literals.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const messages = {
4545
literalNotInJSXExpressionInElement: 'Missing JSX expression container around literal string: "{{text}}" in {{element}}',
4646
};
4747

48-
/** @type {Exclude<import('eslint').Rule.RuleModule['meta']['schema'], unknown[]>['properties']} */
48+
/** @type {Exclude<import('eslint').Rule.RuleModule['meta']['schema'], unknown[] | false>['properties']} */
4949
const commonPropertiesSchema = {
5050
noStrings: {
5151
type: 'boolean',
@@ -182,6 +182,7 @@ const elementOverrides = {
182182
},
183183
};
184184

185+
/** @type {import('eslint').Rule.RuleModule} */
185186
module.exports = {
186187
meta: /** @type {import('eslint').Rule.RuleModule["meta"]} */ ({
187188
docs: {

lib/rules/jsx-props-no-spread-multi.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const messages = {
1616
noMultiSpreading: 'Spreading the same expression multiple times is forbidden',
1717
};
1818

19+
/** @type {import('eslint').Rule.RuleModule} */
1920
module.exports = {
2021
meta: {
2122
docs: {

lib/rules/no-deprecated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module.exports = {
229229
}
230230
node.specifiers.filter(((s) => 'imported' in s && s.imported)).forEach((specifier) => {
231231
// TODO, semver-major: remove `in` check as part of jsdoc->tsdoc migration
232-
checkDeprecation(node, 'imported' in specifier && `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);
232+
checkDeprecation(node, 'imported' in specifier && 'name' in specifier.imported && `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);
233233
});
234234
},
235235

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@
5555
"@babel/plugin-syntax-do-expressions": "^7.24.7",
5656
"@babel/plugin-syntax-function-bind": "^7.24.7",
5757
"@babel/preset-react": "^7.24.7",
58-
"@types/eslint": "=7.2.10",
5958
"@types/estree": "0.0.52",
6059
"@types/node": "^4.9.5",
6160
"@typescript-eslint/parser": "^2.34.0 || ^3.10.1 || ^4 || ^5 || ^6.20 || ^7.14.1 || ^8.4",
6261
"babel-eslint": "^8 || ^9 || ^10.1.0",
63-
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7",
62+
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.10",
6463
"eslint-config-airbnb-base": "^15.0.0",
6564
"eslint-doc-generator": "^1.7.1",
6665
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.5.3 || ^4.0.1 || ^5.0.5",

0 commit comments

Comments
 (0)