Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 5e0578a

Browse files
azat-ioShinigami92
andauthored
Add support for React (#193)
Co-authored-by: Shinigami92 <[email protected]>
1 parent 5092ede commit 5e0578a

File tree

112 files changed

+3792
-0
lines changed

Some content is hidden

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

112 files changed

+3792
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"eslint-plugin-node": "~11.1.0",
7676
"eslint-plugin-prettier": "~4.2.1",
7777
"eslint-plugin-promise": "~6.1.1",
78+
"eslint-plugin-react": "~7.32.2",
7879
"eslint-plugin-sonarjs": "~0.19.0",
7980
"eslint-plugin-spellcheck": "~0.0.20",
8081
"eslint-plugin-unicorn": "~46.0.0",

pnpm-lock.yaml

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/src/rules/react/jsx-no-constructed-context-values.d.ts b/src/rules/react/jsx-no-constructed-context-values.d.ts
2+
index 410f060..e356693 100644
3+
--- a/src/rules/react/jsx-no-constructed-context-values.d.ts
4+
+++ b/src/rules/react/jsx-no-constructed-context-values.d.ts
5+
@@ -1,17 +1,9 @@
6+
import type { RuleConfig } from '../rule-config';
7+
8+
-/**
9+
- * Option.
10+
- */
11+
-export interface JsxNoConstructedContextValuesOption {
12+
- [k: string]: any;
13+
-}
14+
-
15+
/**
16+
* Options.
17+
*/
18+
-export type JsxNoConstructedContextValuesOptions =
19+
- JsxNoConstructedContextValuesOption;
20+
+export type JsxNoConstructedContextValuesOptions = [];
21+
22+
/**
23+
* Disallows JSX context provider values from taking values that will cause needless rerenders.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/rules/react/jsx-props-no-spreading.d.ts b/src/rules/react/jsx-props-no-spreading.d.ts
2+
index c1e0069..ba1e1bc 100644
3+
--- a/src/rules/react/jsx-props-no-spreading.d.ts
4+
+++ b/src/rules/react/jsx-props-no-spreading.d.ts
5+
@@ -8,8 +8,6 @@ export type JsxPropsNoSpreadingOption = {
6+
custom?: 'enforce' | 'ignore';
7+
exceptions?: string[];
8+
[k: string]: any;
9+
-} & {
10+
- [k: string]: any;
11+
};
12+
13+
/**

scripts/generate-rule-files/src/plugins-map.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
5555
name: 'Promise',
5656
module: 'eslint-plugin-promise',
5757
},
58+
react: {
59+
name: 'React',
60+
module: 'eslint-plugin-react',
61+
},
5862
sonarjs: {
5963
name: 'SonarJS',
6064
prefix: 'sonarjs',
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Eslint React extensions.
3+
*
4+
* @see [Eslint React extensions](https://github.com/jsx-eslint/eslint-plugin-react)
5+
*/
6+
export type ReactExtensions =
7+
| 'plugin:react/all'
8+
| 'plugin:react/jsx-runtime'
9+
| 'plugin:react/recommended';

src/config/extends/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { NExtensions } from './eslint-plugin-n';
1010
import type { NodeExtensions } from './eslint-plugin-node';
1111
import type { PrettierExtensions } from './eslint-plugin-prettier';
1212
import type { PromiseExtensions } from './eslint-plugin-promise';
13+
import type { ReactExtensions } from './eslint-plugin-react';
1314
import type { SonarjsExtensions } from './eslint-plugin-sonarjs';
1415
import type { UnicornExtensions } from './eslint-plugin-unicorn';
1516
import type { VitestExtensions } from './eslint-plugin-vitest';
@@ -34,6 +35,7 @@ export type KnownExtensions = LiteralUnion<
3435
| NodeExtensions
3536
| PrettierExtensions
3637
| PromiseExtensions
38+
| ReactExtensions
3739
| SonarjsExtensions
3840
| TypescriptEslintExtensions
3941
| UnicornExtensions

src/config/plugin.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type Plugin = LiteralUnion<
1111
| 'mdx'
1212
| 'prettier'
1313
| 'promise'
14+
| 'react'
1415
| 'sonarjs'
1516
| 'spellcheck'
1617
| 'unicorn'

src/config/settings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ImportSettings } from './import';
22
import type { JSDocSettings } from './jsdoc';
33
import type { MdxSettings } from './mdx';
44
import type { NodeSettings } from './node';
5+
import type { ReactSettings } from './react';
56

67
/**
78
* Settings.
@@ -11,4 +12,5 @@ export interface Settings
1112
JSDocSettings,
1213
MdxSettings,
1314
NodeSettings,
15+
ReactSettings,
1416
Partial<Record<string, unknown>> {}

src/config/settings/react.d.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import type { LiteralUnion } from '../../utility-types';
2+
3+
/**
4+
* React settings.
5+
*
6+
* @see [React settings](https://github.com/jsx-eslint/eslint-plugin-react)
7+
*/
8+
export interface ReactSettings extends Partial<Record<string, unknown>> {
9+
react?: {
10+
/**
11+
* Regex for Component Factory to use.
12+
*
13+
* @default 'createReactClass'
14+
*/
15+
createClass?: LiteralUnion<'createReactClass'>;
16+
17+
/**
18+
* Pragma to use.
19+
*
20+
* @default 'React'
21+
*/
22+
pragma?: LiteralUnion<'React'>;
23+
24+
/**
25+
* Fragment to use (may be a property of <pragma>).
26+
*
27+
* @default 'Fragment'
28+
*/
29+
fragment?: LiteralUnion<'Fragment'>;
30+
31+
/**
32+
* React version. "detect" automatically picks the version you have installed.
33+
*
34+
* You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
35+
*
36+
* It will default to "latest" and warn if missing, and to "detect" in the future.
37+
*
38+
* @default 'latest'
39+
*/
40+
version?: LiteralUnion<'latest' | 'detect'>;
41+
42+
/**
43+
* Flow version.
44+
*/
45+
flowVersion?: string;
46+
};
47+
48+
/**
49+
* The names of any function used to wrap propTypes, e.g. `forbidExtraProps`.
50+
*
51+
* If this isn't set, any propTypes wrapped in a function will be skipped.
52+
*/
53+
propWrapperFunctions?: Array<
54+
| string
55+
| {
56+
property: string;
57+
object?: string;
58+
/**
59+
* For rules that check exact prop wrappers.
60+
*/
61+
exact?: boolean;
62+
[k: string]: any;
63+
}
64+
>;
65+
66+
/**
67+
* The name of any function used to wrap components, e.g. Mobx `observer` function.
68+
*
69+
* If this isn't set, components wrapped by these functions will be skipped.
70+
*/
71+
componentWrapperFunctions?: Array<
72+
| string
73+
| {
74+
property: string;
75+
object?: string;
76+
[k: string]: any;
77+
}
78+
>;
79+
80+
/**
81+
* Components used as alternatives to <form> for forms, eg. <Form endpoint={ url } />.
82+
*/
83+
formComponents?: Array<
84+
| string
85+
| {
86+
name: string;
87+
formAttribute: string;
88+
}
89+
>;
90+
91+
/**
92+
* Components used as alternatives to <a> for linking, eg. <Link to={ url } />.
93+
*/
94+
linkComponents?: Array<
95+
| string
96+
| {
97+
name: string;
98+
linkAttribute: string;
99+
}
100+
>;
101+
}

0 commit comments

Comments
 (0)