diff --git a/package.json b/package.json index f1c7b7c7..4a2b2f5c 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "eslint-plugin-node": "~11.1.0", "eslint-plugin-prettier": "~4.2.1", "eslint-plugin-promise": "~6.1.1", + "eslint-plugin-react": "~7.32.2", "eslint-plugin-sonarjs": "~0.19.0", "eslint-plugin-spellcheck": "~0.0.20", "eslint-plugin-unicorn": "~46.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1fcd74b0..98fc21d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,6 +73,9 @@ devDependencies: eslint-plugin-promise: specifier: ~6.1.1 version: 6.1.1(eslint@8.39.0) + eslint-plugin-react: + specifier: ~7.32.2 + version: 7.32.2(eslint@8.39.0) eslint-plugin-sonarjs: specifier: ~0.19.0 version: 0.19.0(eslint@8.39.0) @@ -1487,6 +1490,16 @@ packages: es-shim-unscopables: 1.0.0 dev: true + /array.prototype.tosorted@1.1.1: + resolution: {integrity: sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ==} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + es-shim-unscopables: 1.0.0 + get-intrinsic: 1.2.0 + dev: true + /arrify@1.0.1: resolution: {integrity: sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==} engines: {node: '>=0.10.0'} @@ -2404,6 +2417,30 @@ packages: eslint: 8.39.0 dev: true + /eslint-plugin-react@7.32.2(eslint@8.39.0): + resolution: {integrity: sha512-t2fBMa+XzonrrNkyVirzKlvn5RXzzPwRHtMvLAtVZrt8oxgnTQaYbU6SXTOO1mwQgp1y5+toMSKInnzGr0Knqg==} + engines: {node: '>=4'} + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 + dependencies: + array-includes: 3.1.6 + array.prototype.flatmap: 1.3.1 + array.prototype.tosorted: 1.1.1 + doctrine: 2.1.0 + eslint: 8.39.0 + estraverse: 5.3.0 + jsx-ast-utils: 3.3.3 + minimatch: 3.1.2 + object.entries: 1.1.6 + object.fromentries: 2.0.6 + object.hasown: 1.1.2 + object.values: 1.1.6 + prop-types: 15.8.1 + resolve: 2.0.0-next.4 + semver: 6.3.0 + string.prototype.matchall: 4.0.8 + dev: true + /eslint-plugin-sonarjs@0.19.0(eslint@8.39.0): resolution: {integrity: sha512-6+s5oNk5TFtVlbRxqZN7FIGmjdPCYQKaTzFPmqieCmsU1kBYDzndTeQav0xtQNwZJWu5awWfTGe8Srq9xFOGnw==} engines: {node: '>=14'} @@ -3448,6 +3485,14 @@ packages: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true + /jsx-ast-utils@3.3.3: + resolution: {integrity: sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==} + engines: {node: '>=4.0'} + dependencies: + array-includes: 3.1.6 + object.assign: 4.1.4 + dev: true + /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} @@ -3510,6 +3555,13 @@ packages: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} dev: true + /loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + dependencies: + js-tokens: 4.0.0 + dev: true + /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: @@ -4141,6 +4193,31 @@ packages: object-keys: 1.1.1 dev: true + /object.entries@1.1.6: + resolution: {integrity: sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + + /object.fromentries@2.0.6: + resolution: {integrity: sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + + /object.hasown@1.1.2: + resolution: {integrity: sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==} + dependencies: + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + /object.values@1.1.6: resolution: {integrity: sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==} engines: {node: '>= 0.4'} @@ -4420,6 +4497,14 @@ packages: engines: {node: '>= 0.8'} dev: true + /prop-types@15.8.1: + resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + react-is: 16.13.1 + dev: true + /pug-error@2.0.0: resolution: {integrity: sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==} dev: true @@ -4456,6 +4541,10 @@ packages: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true + /react-is@16.13.1: + resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + dev: true + /react-is@17.0.2: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} dev: true @@ -4559,6 +4648,15 @@ packages: supports-preserve-symlinks-flag: 1.0.0 dev: true + /resolve@2.0.0-next.4: + resolution: {integrity: sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==} + hasBin: true + dependencies: + is-core-module: 2.12.0 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + /restore-cursor@3.1.0: resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} engines: {node: '>=8'} @@ -4767,6 +4865,19 @@ packages: strip-ansi: 6.0.1 dev: true + /string.prototype.matchall@4.0.8: + resolution: {integrity: sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + get-intrinsic: 1.2.0 + has-symbols: 1.0.3 + internal-slot: 1.0.5 + regexp.prototype.flags: 1.5.0 + side-channel: 1.0.4 + dev: true + /string.prototype.trim@1.2.7: resolution: {integrity: sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==} engines: {node: '>= 0.4'} diff --git a/scripts/generate-rule-files/diffs/rules/react/jsx-no-constructed-context-values.d.ts.diff b/scripts/generate-rule-files/diffs/rules/react/jsx-no-constructed-context-values.d.ts.diff new file mode 100644 index 00000000..152c62d9 --- /dev/null +++ b/scripts/generate-rule-files/diffs/rules/react/jsx-no-constructed-context-values.d.ts.diff @@ -0,0 +1,23 @@ +diff --git a/src/rules/react/jsx-no-constructed-context-values.d.ts b/src/rules/react/jsx-no-constructed-context-values.d.ts +index 410f060..e356693 100644 +--- a/src/rules/react/jsx-no-constructed-context-values.d.ts ++++ b/src/rules/react/jsx-no-constructed-context-values.d.ts +@@ -1,17 +1,9 @@ + import type { RuleConfig } from '../rule-config'; + +-/** +- * Option. +- */ +-export interface JsxNoConstructedContextValuesOption { +- [k: string]: any; +-} +- + /** + * Options. + */ +-export type JsxNoConstructedContextValuesOptions = +- JsxNoConstructedContextValuesOption; ++export type JsxNoConstructedContextValuesOptions = []; + + /** + * Disallows JSX context provider values from taking values that will cause needless rerenders. diff --git a/scripts/generate-rule-files/diffs/rules/react/jsx-props-no-spreading.d.ts.diff b/scripts/generate-rule-files/diffs/rules/react/jsx-props-no-spreading.d.ts.diff new file mode 100644 index 00000000..a1e2e6a7 --- /dev/null +++ b/scripts/generate-rule-files/diffs/rules/react/jsx-props-no-spreading.d.ts.diff @@ -0,0 +1,13 @@ +diff --git a/src/rules/react/jsx-props-no-spreading.d.ts b/src/rules/react/jsx-props-no-spreading.d.ts +index c1e0069..ba1e1bc 100644 +--- a/src/rules/react/jsx-props-no-spreading.d.ts ++++ b/src/rules/react/jsx-props-no-spreading.d.ts +@@ -8,8 +8,6 @@ export type JsxPropsNoSpreadingOption = { + custom?: 'enforce' | 'ignore'; + exceptions?: string[]; + [k: string]: any; +-} & { +- [k: string]: any; + }; + + /** diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index 414970eb..86d8e499 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -55,6 +55,10 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'Promise', module: 'eslint-plugin-promise', }, + react: { + name: 'React', + module: 'eslint-plugin-react', + }, sonarjs: { name: 'SonarJS', prefix: 'sonarjs', diff --git a/src/config/extends/eslint-plugin-react.d.ts b/src/config/extends/eslint-plugin-react.d.ts new file mode 100644 index 00000000..a4ec98b4 --- /dev/null +++ b/src/config/extends/eslint-plugin-react.d.ts @@ -0,0 +1,9 @@ +/** + * Eslint React extensions. + * + * @see [Eslint React extensions](https://github.com/jsx-eslint/eslint-plugin-react) + */ +export type ReactExtensions = + | 'plugin:react/all' + | 'plugin:react/jsx-runtime' + | 'plugin:react/recommended'; diff --git a/src/config/extends/index.d.ts b/src/config/extends/index.d.ts index b6d405c4..b26f946f 100644 --- a/src/config/extends/index.d.ts +++ b/src/config/extends/index.d.ts @@ -10,6 +10,7 @@ import type { NExtensions } from './eslint-plugin-n'; import type { NodeExtensions } from './eslint-plugin-node'; import type { PrettierExtensions } from './eslint-plugin-prettier'; import type { PromiseExtensions } from './eslint-plugin-promise'; +import type { ReactExtensions } from './eslint-plugin-react'; import type { SonarjsExtensions } from './eslint-plugin-sonarjs'; import type { UnicornExtensions } from './eslint-plugin-unicorn'; import type { VitestExtensions } from './eslint-plugin-vitest'; @@ -34,6 +35,7 @@ export type KnownExtensions = LiteralUnion< | NodeExtensions | PrettierExtensions | PromiseExtensions + | ReactExtensions | SonarjsExtensions | TypescriptEslintExtensions | UnicornExtensions diff --git a/src/config/plugin.d.ts b/src/config/plugin.d.ts index b89f074d..dae721e0 100644 --- a/src/config/plugin.d.ts +++ b/src/config/plugin.d.ts @@ -11,6 +11,7 @@ export type Plugin = LiteralUnion< | 'mdx' | 'prettier' | 'promise' + | 'react' | 'sonarjs' | 'spellcheck' | 'unicorn' diff --git a/src/config/settings/index.d.ts b/src/config/settings/index.d.ts index 978412d7..bf7daafb 100644 --- a/src/config/settings/index.d.ts +++ b/src/config/settings/index.d.ts @@ -2,6 +2,7 @@ import type { ImportSettings } from './import'; import type { JSDocSettings } from './jsdoc'; import type { MdxSettings } from './mdx'; import type { NodeSettings } from './node'; +import type { ReactSettings } from './react'; /** * Settings. @@ -11,4 +12,5 @@ export interface Settings JSDocSettings, MdxSettings, NodeSettings, + ReactSettings, Partial> {} diff --git a/src/config/settings/react.d.ts b/src/config/settings/react.d.ts new file mode 100644 index 00000000..10fee4d1 --- /dev/null +++ b/src/config/settings/react.d.ts @@ -0,0 +1,101 @@ +import type { LiteralUnion } from '../../utility-types'; + +/** + * React settings. + * + * @see [React settings](https://github.com/jsx-eslint/eslint-plugin-react) + */ +export interface ReactSettings extends Partial> { + react?: { + /** + * Regex for Component Factory to use. + * + * @default 'createReactClass' + */ + createClass?: LiteralUnion<'createReactClass'>; + + /** + * Pragma to use. + * + * @default 'React' + */ + pragma?: LiteralUnion<'React'>; + + /** + * Fragment to use (may be a property of ). + * + * @default 'Fragment' + */ + fragment?: LiteralUnion<'Fragment'>; + + /** + * React version. "detect" automatically picks the version you have installed. + * + * You can also use `16.0`, `16.3`, etc, if you want to override the detected value. + * + * It will default to "latest" and warn if missing, and to "detect" in the future. + * + * @default 'latest' + */ + version?: LiteralUnion<'latest' | 'detect'>; + + /** + * Flow version. + */ + flowVersion?: string; + }; + + /** + * The names of any function used to wrap propTypes, e.g. `forbidExtraProps`. + * + * If this isn't set, any propTypes wrapped in a function will be skipped. + */ + propWrapperFunctions?: Array< + | string + | { + property: string; + object?: string; + /** + * For rules that check exact prop wrappers. + */ + exact?: boolean; + [k: string]: any; + } + >; + + /** + * The name of any function used to wrap components, e.g. Mobx `observer` function. + * + * If this isn't set, components wrapped by these functions will be skipped. + */ + componentWrapperFunctions?: Array< + | string + | { + property: string; + object?: string; + [k: string]: any; + } + >; + + /** + * Components used as alternatives to
for forms, eg. . + */ + formComponents?: Array< + | string + | { + name: string; + formAttribute: string; + } + >; + + /** + * Components used as alternatives to for linking, eg. . + */ + linkComponents?: Array< + | string + | { + name: string; + linkAttribute: string; + } + >; +} diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index a187b525..0d3d15fd 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -8,6 +8,7 @@ import type { JsoncRules } from './jsonc'; import type { NRules } from './n'; import type { NodeRules } from './node'; import type { PromiseRules } from './promise'; +import type { ReactRules } from './react'; import type { RuleConfig } from './rule-config'; import type { SonarJSRules } from './sonarjs'; import type { SpellcheckRules } from './spellcheck'; @@ -34,6 +35,7 @@ export type Rules = Partial< NodeRules & NRules & PromiseRules & + ReactRules & SonarJSRules & SpellcheckRules & TypeScriptRules & diff --git a/src/rules/react/boolean-prop-naming.d.ts b/src/rules/react/boolean-prop-naming.d.ts new file mode 100644 index 00000000..68da9cf0 --- /dev/null +++ b/src/rules/react/boolean-prop-naming.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface BooleanPropNamingOption { + /** + * @minItems 1 + */ + propTypeNames?: [string, ...string[]]; + rule?: string; + message?: string; + validateNested?: boolean; +} + +/** + * Options. + */ +export type BooleanPropNamingOptions = [BooleanPropNamingOption?]; + +/** + * Enforces consistent naming for boolean props. + * + * @see [boolean-prop-naming](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/boolean-prop-naming.md) + */ +export type BooleanPropNamingRuleConfig = RuleConfig; + +/** + * Enforces consistent naming for boolean props. + * + * @see [boolean-prop-naming](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/boolean-prop-naming.md) + */ +export interface BooleanPropNamingRule { + /** + * Enforces consistent naming for boolean props. + * + * @see [boolean-prop-naming](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/boolean-prop-naming.md) + */ + 'react/boolean-prop-naming': BooleanPropNamingRuleConfig; +} diff --git a/src/rules/react/button-has-type.d.ts b/src/rules/react/button-has-type.d.ts new file mode 100644 index 00000000..aa4a8296 --- /dev/null +++ b/src/rules/react/button-has-type.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ButtonHasTypeOption { + button?: boolean; + submit?: boolean; + reset?: boolean; +} + +/** + * Options. + */ +export type ButtonHasTypeOptions = [ButtonHasTypeOption?]; + +/** + * Disallow usage of `button` elements without an explicit `type` attribute. + * + * @see [button-has-type](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md) + */ +export type ButtonHasTypeRuleConfig = RuleConfig; + +/** + * Disallow usage of `button` elements without an explicit `type` attribute. + * + * @see [button-has-type](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md) + */ +export interface ButtonHasTypeRule { + /** + * Disallow usage of `button` elements without an explicit `type` attribute. + * + * @see [button-has-type](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md) + */ + 'react/button-has-type': ButtonHasTypeRuleConfig; +} diff --git a/src/rules/react/default-props-match-prop-types.d.ts b/src/rules/react/default-props-match-prop-types.d.ts new file mode 100644 index 00000000..6c2098bc --- /dev/null +++ b/src/rules/react/default-props-match-prop-types.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface DefaultPropsMatchPropTypesOption { + allowRequiredDefaults?: boolean; +} + +/** + * Options. + */ +export type DefaultPropsMatchPropTypesOptions = [ + DefaultPropsMatchPropTypesOption?, +]; + +/** + * Enforce all defaultProps have a corresponding non-required PropType. + * + * @see [default-props-match-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md) + */ +export type DefaultPropsMatchPropTypesRuleConfig = + RuleConfig; + +/** + * Enforce all defaultProps have a corresponding non-required PropType. + * + * @see [default-props-match-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md) + */ +export interface DefaultPropsMatchPropTypesRule { + /** + * Enforce all defaultProps have a corresponding non-required PropType. + * + * @see [default-props-match-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md) + */ + 'react/default-props-match-prop-types': DefaultPropsMatchPropTypesRuleConfig; +} diff --git a/src/rules/react/destructuring-assignment.d.ts b/src/rules/react/destructuring-assignment.d.ts new file mode 100644 index 00000000..5b8fb653 --- /dev/null +++ b/src/rules/react/destructuring-assignment.d.ts @@ -0,0 +1,44 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface DestructuringAssignmentConfig { + ignoreClassFields?: boolean; + destructureInSignature?: 'always' | 'ignore'; +} + +/** + * Option. + */ +export type DestructuringAssignmentOption = 'always' | 'never'; + +/** + * Options. + */ +export type DestructuringAssignmentOptions = [ + DestructuringAssignmentOption?, + DestructuringAssignmentConfig?, +]; + +/** + * Enforce consistent usage of destructuring assignment of props, state, and context. + * + * @see [destructuring-assignment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/destructuring-assignment.md) + */ +export type DestructuringAssignmentRuleConfig = + RuleConfig; + +/** + * Enforce consistent usage of destructuring assignment of props, state, and context. + * + * @see [destructuring-assignment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/destructuring-assignment.md) + */ +export interface DestructuringAssignmentRule { + /** + * Enforce consistent usage of destructuring assignment of props, state, and context. + * + * @see [destructuring-assignment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/destructuring-assignment.md) + */ + 'react/destructuring-assignment': DestructuringAssignmentRuleConfig; +} diff --git a/src/rules/react/display-name.d.ts b/src/rules/react/display-name.d.ts new file mode 100644 index 00000000..3d71d608 --- /dev/null +++ b/src/rules/react/display-name.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface DisplayNameOption { + ignoreTranspilerName?: boolean; +} + +/** + * Options. + */ +export type DisplayNameOptions = [DisplayNameOption?]; + +/** + * Disallow missing displayName in a React component definition. + * + * @see [display-name](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/display-name.md) + */ +export type DisplayNameRuleConfig = RuleConfig; + +/** + * Disallow missing displayName in a React component definition. + * + * @see [display-name](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/display-name.md) + */ +export interface DisplayNameRule { + /** + * Disallow missing displayName in a React component definition. + * + * @see [display-name](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/display-name.md) + */ + 'react/display-name': DisplayNameRuleConfig; +} diff --git a/src/rules/react/forbid-component-props.d.ts b/src/rules/react/forbid-component-props.d.ts new file mode 100644 index 00000000..b610b67f --- /dev/null +++ b/src/rules/react/forbid-component-props.d.ts @@ -0,0 +1,44 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ForbidComponentPropsOption { + forbid?: ( + | string + | { + propName?: string; + allowedFor?: string[]; + message?: string; + [k: string]: any; + } + )[]; + [k: string]: any; +} + +/** + * Options. + */ +export type ForbidComponentPropsOptions = [ForbidComponentPropsOption?]; + +/** + * Disallow certain props on components. + * + * @see [forbid-component-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-component-props.md) + */ +export type ForbidComponentPropsRuleConfig = + RuleConfig; + +/** + * Disallow certain props on components. + * + * @see [forbid-component-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-component-props.md) + */ +export interface ForbidComponentPropsRule { + /** + * Disallow certain props on components. + * + * @see [forbid-component-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-component-props.md) + */ + 'react/forbid-component-props': ForbidComponentPropsRuleConfig; +} diff --git a/src/rules/react/forbid-dom-props.d.ts b/src/rules/react/forbid-dom-props.d.ts new file mode 100644 index 00000000..d4293a24 --- /dev/null +++ b/src/rules/react/forbid-dom-props.d.ts @@ -0,0 +1,42 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ForbidDomPropsOption { + forbid?: ( + | string + | { + propName?: string; + disallowedFor?: string[]; + message?: string; + [k: string]: any; + } + )[]; +} + +/** + * Options. + */ +export type ForbidDomPropsOptions = [ForbidDomPropsOption?]; + +/** + * Disallow certain props on DOM Nodes. + * + * @see [forbid-dom-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-dom-props.md) + */ +export type ForbidDomPropsRuleConfig = RuleConfig; + +/** + * Disallow certain props on DOM Nodes. + * + * @see [forbid-dom-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-dom-props.md) + */ +export interface ForbidDomPropsRule { + /** + * Disallow certain props on DOM Nodes. + * + * @see [forbid-dom-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-dom-props.md) + */ + 'react/forbid-dom-props': ForbidDomPropsRuleConfig; +} diff --git a/src/rules/react/forbid-elements.d.ts b/src/rules/react/forbid-elements.d.ts new file mode 100644 index 00000000..4c739bdb --- /dev/null +++ b/src/rules/react/forbid-elements.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ForbidElementsOption { + forbid?: ( + | string + | { + element: string; + message?: string; + } + )[]; +} + +/** + * Options. + */ +export type ForbidElementsOptions = [ForbidElementsOption?]; + +/** + * Disallow certain elements. + * + * @see [forbid-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-elements.md) + */ +export type ForbidElementsRuleConfig = RuleConfig; + +/** + * Disallow certain elements. + * + * @see [forbid-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-elements.md) + */ +export interface ForbidElementsRule { + /** + * Disallow certain elements. + * + * @see [forbid-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-elements.md) + */ + 'react/forbid-elements': ForbidElementsRuleConfig; +} diff --git a/src/rules/react/forbid-foreign-prop-types.d.ts b/src/rules/react/forbid-foreign-prop-types.d.ts new file mode 100644 index 00000000..5aab9a5a --- /dev/null +++ b/src/rules/react/forbid-foreign-prop-types.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ForbidForeignPropTypesOption { + allowInPropTypes?: boolean; +} + +/** + * Options. + */ +export type ForbidForeignPropTypesOptions = [ForbidForeignPropTypesOption?]; + +/** + * Disallow using another component's propTypes. + * + * @see [forbid-foreign-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-foreign-prop-types.md) + */ +export type ForbidForeignPropTypesRuleConfig = + RuleConfig; + +/** + * Disallow using another component's propTypes. + * + * @see [forbid-foreign-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-foreign-prop-types.md) + */ +export interface ForbidForeignPropTypesRule { + /** + * Disallow using another component's propTypes. + * + * @see [forbid-foreign-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-foreign-prop-types.md) + */ + 'react/forbid-foreign-prop-types': ForbidForeignPropTypesRuleConfig; +} diff --git a/src/rules/react/forbid-prop-types.d.ts b/src/rules/react/forbid-prop-types.d.ts new file mode 100644 index 00000000..64a79f7f --- /dev/null +++ b/src/rules/react/forbid-prop-types.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ForbidPropTypesOption { + forbid?: string[]; + checkContextTypes?: boolean; + checkChildContextTypes?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type ForbidPropTypesOptions = [ForbidPropTypesOption?]; + +/** + * Disallow certain propTypes. + * + * @see [forbid-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-prop-types.md) + */ +export type ForbidPropTypesRuleConfig = RuleConfig; + +/** + * Disallow certain propTypes. + * + * @see [forbid-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-prop-types.md) + */ +export interface ForbidPropTypesRule { + /** + * Disallow certain propTypes. + * + * @see [forbid-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-prop-types.md) + */ + 'react/forbid-prop-types': ForbidPropTypesRuleConfig; +} diff --git a/src/rules/react/function-component-definition.d.ts b/src/rules/react/function-component-definition.d.ts new file mode 100644 index 00000000..72e34c12 --- /dev/null +++ b/src/rules/react/function-component-definition.d.ts @@ -0,0 +1,43 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface FunctionComponentDefinitionOption { + namedComponents?: + | ('function-declaration' | 'arrow-function' | 'function-expression') + | ('function-declaration' | 'arrow-function' | 'function-expression')[]; + unnamedComponents?: + | ('arrow-function' | 'function-expression') + | ('arrow-function' | 'function-expression')[]; + [k: string]: any; +} + +/** + * Options. + */ +export type FunctionComponentDefinitionOptions = [ + FunctionComponentDefinitionOption?, +]; + +/** + * Enforce a specific function type for function components. + * + * @see [function-component-definition](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/function-component-definition.md) + */ +export type FunctionComponentDefinitionRuleConfig = + RuleConfig; + +/** + * Enforce a specific function type for function components. + * + * @see [function-component-definition](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/function-component-definition.md) + */ +export interface FunctionComponentDefinitionRule { + /** + * Enforce a specific function type for function components. + * + * @see [function-component-definition](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/function-component-definition.md) + */ + 'react/function-component-definition': FunctionComponentDefinitionRuleConfig; +} diff --git a/src/rules/react/hook-use-state.d.ts b/src/rules/react/hook-use-state.d.ts new file mode 100644 index 00000000..c68d0d14 --- /dev/null +++ b/src/rules/react/hook-use-state.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface HookUseStateOption { + allowDestructuredState?: boolean; +} + +/** + * Options. + */ +export type HookUseStateOptions = [HookUseStateOption?]; + +/** + * Ensure destructuring and symmetric naming of useState hook value and setter variables. + * + * @see [hook-use-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/hook-use-state.md) + */ +export type HookUseStateRuleConfig = RuleConfig; + +/** + * Ensure destructuring and symmetric naming of useState hook value and setter variables. + * + * @see [hook-use-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/hook-use-state.md) + */ +export interface HookUseStateRule { + /** + * Ensure destructuring and symmetric naming of useState hook value and setter variables. + * + * @see [hook-use-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/hook-use-state.md) + */ + 'react/hook-use-state': HookUseStateRuleConfig; +} diff --git a/src/rules/react/iframe-missing-sandbox.d.ts b/src/rules/react/iframe-missing-sandbox.d.ts new file mode 100644 index 00000000..4aee4089 --- /dev/null +++ b/src/rules/react/iframe-missing-sandbox.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce sandbox attribute on iframe elements. + * + * @see [iframe-missing-sandbox](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/iframe-missing-sandbox.md) + */ +export type IframeMissingSandboxRuleConfig = RuleConfig<[]>; + +/** + * Enforce sandbox attribute on iframe elements. + * + * @see [iframe-missing-sandbox](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/iframe-missing-sandbox.md) + */ +export interface IframeMissingSandboxRule { + /** + * Enforce sandbox attribute on iframe elements. + * + * @see [iframe-missing-sandbox](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/iframe-missing-sandbox.md) + */ + 'react/iframe-missing-sandbox': IframeMissingSandboxRuleConfig; +} diff --git a/src/rules/react/index.d.ts b/src/rules/react/index.d.ts new file mode 100644 index 00000000..35232ece --- /dev/null +++ b/src/rules/react/index.d.ts @@ -0,0 +1,204 @@ +import type { BooleanPropNamingRule } from './boolean-prop-naming'; +import type { ButtonHasTypeRule } from './button-has-type'; +import type { DefaultPropsMatchPropTypesRule } from './default-props-match-prop-types'; +import type { DestructuringAssignmentRule } from './destructuring-assignment'; +import type { DisplayNameRule } from './display-name'; +import type { ForbidComponentPropsRule } from './forbid-component-props'; +import type { ForbidDomPropsRule } from './forbid-dom-props'; +import type { ForbidElementsRule } from './forbid-elements'; +import type { ForbidForeignPropTypesRule } from './forbid-foreign-prop-types'; +import type { ForbidPropTypesRule } from './forbid-prop-types'; +import type { FunctionComponentDefinitionRule } from './function-component-definition'; +import type { HookUseStateRule } from './hook-use-state'; +import type { IframeMissingSandboxRule } from './iframe-missing-sandbox'; +import type { JsxBooleanValueRule } from './jsx-boolean-value'; +import type { JsxChildElementSpacingRule } from './jsx-child-element-spacing'; +import type { JsxClosingBracketLocationRule } from './jsx-closing-bracket-location'; +import type { JsxClosingTagLocationRule } from './jsx-closing-tag-location'; +import type { JsxCurlyBracePresenceRule } from './jsx-curly-brace-presence'; +import type { JsxCurlyNewlineRule } from './jsx-curly-newline'; +import type { JsxCurlySpacingRule } from './jsx-curly-spacing'; +import type { JsxEqualsSpacingRule } from './jsx-equals-spacing'; +import type { JsxFilenameExtensionRule } from './jsx-filename-extension'; +import type { JsxFirstPropNewLineRule } from './jsx-first-prop-new-line'; +import type { JsxFragmentsRule } from './jsx-fragments'; +import type { JsxHandlerNamesRule } from './jsx-handler-names'; +import type { JsxIndentRule } from './jsx-indent'; +import type { JsxIndentPropsRule } from './jsx-indent-props'; +import type { JsxKeyRule } from './jsx-key'; +import type { JsxMaxDepthRule } from './jsx-max-depth'; +import type { JsxMaxPropsPerLineRule } from './jsx-max-props-per-line'; +import type { JsxNewlineRule } from './jsx-newline'; +import type { JsxNoBindRule } from './jsx-no-bind'; +import type { JsxNoCommentTextnodesRule } from './jsx-no-comment-textnodes'; +import type { JsxNoConstructedContextValuesRule } from './jsx-no-constructed-context-values'; +import type { JsxNoDuplicatePropsRule } from './jsx-no-duplicate-props'; +import type { JsxNoLeakedRenderRule } from './jsx-no-leaked-render'; +import type { JsxNoLiteralsRule } from './jsx-no-literals'; +import type { JsxNoScriptUrlRule } from './jsx-no-script-url'; +import type { JsxNoTargetBlankRule } from './jsx-no-target-blank'; +import type { JsxNoUndefRule } from './jsx-no-undef'; +import type { JsxNoUselessFragmentRule } from './jsx-no-useless-fragment'; +import type { JsxOneExpressionPerLineRule } from './jsx-one-expression-per-line'; +import type { JsxPascalCaseRule } from './jsx-pascal-case'; +import type { JsxPropsNoMultiSpacesRule } from './jsx-props-no-multi-spaces'; +import type { JsxPropsNoSpreadingRule } from './jsx-props-no-spreading'; +import type { JsxSortDefaultPropsRule } from './jsx-sort-default-props'; +import type { JsxSortPropsRule } from './jsx-sort-props'; +import type { JsxSpaceBeforeClosingRule } from './jsx-space-before-closing'; +import type { JsxTagSpacingRule } from './jsx-tag-spacing'; +import type { JsxUsesReactRule } from './jsx-uses-react'; +import type { JsxUsesVarsRule } from './jsx-uses-vars'; +import type { JsxWrapMultilinesRule } from './jsx-wrap-multilines'; +import type { NoAccessStateInSetstateRule } from './no-access-state-in-setstate'; +import type { NoAdjacentInlineElementsRule } from './no-adjacent-inline-elements'; +import type { NoArrayIndexKeyRule } from './no-array-index-key'; +import type { NoArrowFunctionLifecycleRule } from './no-arrow-function-lifecycle'; +import type { NoChildrenPropRule } from './no-children-prop'; +import type { NoDangerRule } from './no-danger'; +import type { NoDangerWithChildrenRule } from './no-danger-with-children'; +import type { NoDeprecatedRule } from './no-deprecated'; +import type { NoDidMountSetStateRule } from './no-did-mount-set-state'; +import type { NoDidUpdateSetStateRule } from './no-did-update-set-state'; +import type { NoDirectMutationStateRule } from './no-direct-mutation-state'; +import type { NoFindDomNodeRule } from './no-find-dom-node'; +import type { NoInvalidHtmlAttributeRule } from './no-invalid-html-attribute'; +import type { NoIsMountedRule } from './no-is-mounted'; +import type { NoMultiCompRule } from './no-multi-comp'; +import type { NoNamespaceRule } from './no-namespace'; +import type { NoObjectTypeAsDefaultPropRule } from './no-object-type-as-default-prop'; +import type { NoRedundantShouldComponentUpdateRule } from './no-redundant-should-component-update'; +import type { NoRenderReturnValueRule } from './no-render-return-value'; +import type { NoSetStateRule } from './no-set-state'; +import type { NoStringRefsRule } from './no-string-refs'; +import type { NoThisInSfcRule } from './no-this-in-sfc'; +import type { NoTyposRule } from './no-typos'; +import type { NoUnescapedEntitiesRule } from './no-unescaped-entities'; +import type { NoUnknownPropertyRule } from './no-unknown-property'; +import type { NoUnsafeRule } from './no-unsafe'; +import type { NoUnstableNestedComponentsRule } from './no-unstable-nested-components'; +import type { NoUnusedClassComponentMethodsRule } from './no-unused-class-component-methods'; +import type { NoUnusedPropTypesRule } from './no-unused-prop-types'; +import type { NoUnusedStateRule } from './no-unused-state'; +import type { NoWillUpdateSetStateRule } from './no-will-update-set-state'; +import type { PreferEs6ClassRule } from './prefer-es6-class'; +import type { PreferExactPropsRule } from './prefer-exact-props'; +import type { PreferReadOnlyPropsRule } from './prefer-read-only-props'; +import type { PreferStatelessFunctionRule } from './prefer-stateless-function'; +import type { PropTypesRule } from './prop-types'; +import type { ReactInJsxScopeRule } from './react-in-jsx-scope'; +import type { RequireDefaultPropsRule } from './require-default-props'; +import type { RequireOptimizationRule } from './require-optimization'; +import type { RequireRenderReturnRule } from './require-render-return'; +import type { SelfClosingCompRule } from './self-closing-comp'; +import type { SortCompRule } from './sort-comp'; +import type { SortDefaultPropsRule } from './sort-default-props'; +import type { SortPropTypesRule } from './sort-prop-types'; +import type { StateInConstructorRule } from './state-in-constructor'; +import type { StaticPropertyPlacementRule } from './static-property-placement'; +import type { StylePropObjectRule } from './style-prop-object'; +import type { VoidDomElementsNoChildrenRule } from './void-dom-elements-no-children'; + +/** + * All React rules. + */ +export type ReactRules = BooleanPropNamingRule & + ButtonHasTypeRule & + DefaultPropsMatchPropTypesRule & + DestructuringAssignmentRule & + DisplayNameRule & + ForbidComponentPropsRule & + ForbidDomPropsRule & + ForbidElementsRule & + ForbidForeignPropTypesRule & + ForbidPropTypesRule & + FunctionComponentDefinitionRule & + HookUseStateRule & + IframeMissingSandboxRule & + JsxBooleanValueRule & + JsxChildElementSpacingRule & + JsxClosingBracketLocationRule & + JsxClosingTagLocationRule & + JsxCurlySpacingRule & + JsxCurlyNewlineRule & + JsxEqualsSpacingRule & + JsxFilenameExtensionRule & + JsxFirstPropNewLineRule & + JsxHandlerNamesRule & + JsxIndentRule & + JsxIndentPropsRule & + JsxKeyRule & + JsxMaxDepthRule & + JsxMaxPropsPerLineRule & + JsxNewlineRule & + JsxNoBindRule & + JsxNoCommentTextnodesRule & + JsxNoConstructedContextValuesRule & + JsxNoDuplicatePropsRule & + JsxNoLeakedRenderRule & + JsxNoLiteralsRule & + JsxNoScriptUrlRule & + JsxNoTargetBlankRule & + JsxNoUselessFragmentRule & + JsxOneExpressionPerLineRule & + JsxNoUndefRule & + JsxCurlyBracePresenceRule & + JsxPascalCaseRule & + JsxFragmentsRule & + JsxPropsNoMultiSpacesRule & + JsxPropsNoSpreadingRule & + JsxSortDefaultPropsRule & + JsxSortPropsRule & + JsxSpaceBeforeClosingRule & + JsxTagSpacingRule & + JsxUsesReactRule & + JsxUsesVarsRule & + JsxWrapMultilinesRule & + NoInvalidHtmlAttributeRule & + NoAccessStateInSetstateRule & + NoAdjacentInlineElementsRule & + NoArrayIndexKeyRule & + NoArrowFunctionLifecycleRule & + NoChildrenPropRule & + NoDangerRule & + NoDangerWithChildrenRule & + NoDeprecatedRule & + NoDidMountSetStateRule & + NoDidUpdateSetStateRule & + NoDirectMutationStateRule & + NoFindDomNodeRule & + NoIsMountedRule & + NoMultiCompRule & + NoNamespaceRule & + NoSetStateRule & + NoStringRefsRule & + NoRedundantShouldComponentUpdateRule & + NoRenderReturnValueRule & + NoThisInSfcRule & + NoTyposRule & + NoUnescapedEntitiesRule & + NoUnknownPropertyRule & + NoUnsafeRule & + NoUnstableNestedComponentsRule & + NoUnusedClassComponentMethodsRule & + NoUnusedPropTypesRule & + NoUnusedStateRule & + NoObjectTypeAsDefaultPropRule & + NoWillUpdateSetStateRule & + PreferEs6ClassRule & + PreferExactPropsRule & + PreferReadOnlyPropsRule & + PreferStatelessFunctionRule & + PropTypesRule & + ReactInJsxScopeRule & + RequireDefaultPropsRule & + RequireOptimizationRule & + RequireRenderReturnRule & + SelfClosingCompRule & + SortCompRule & + SortDefaultPropsRule & + SortPropTypesRule & + StateInConstructorRule & + StaticPropertyPlacementRule & + StylePropObjectRule & + VoidDomElementsNoChildrenRule; diff --git a/src/rules/react/jsx-boolean-value.d.ts b/src/rules/react/jsx-boolean-value.d.ts new file mode 100644 index 00000000..c322029f --- /dev/null +++ b/src/rules/react/jsx-boolean-value.d.ts @@ -0,0 +1,50 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxBooleanValueOption = + | [] + | ['always' | 'never'] + | [] + | ['always'] + | [ + 'always', + { + never?: string[]; + }, + ] + | [] + | ['never'] + | [ + 'never', + { + always?: string[]; + }, + ]; + +/** + * Options. + */ +export type JsxBooleanValueOptions = JsxBooleanValueOption; + +/** + * Enforce boolean attributes notation in JSX. + * + * @see [jsx-boolean-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-boolean-value.md) + */ +export type JsxBooleanValueRuleConfig = RuleConfig; + +/** + * Enforce boolean attributes notation in JSX. + * + * @see [jsx-boolean-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-boolean-value.md) + */ +export interface JsxBooleanValueRule { + /** + * Enforce boolean attributes notation in JSX. + * + * @see [jsx-boolean-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-boolean-value.md) + */ + 'react/jsx-boolean-value': JsxBooleanValueRuleConfig; +} diff --git a/src/rules/react/jsx-child-element-spacing.d.ts b/src/rules/react/jsx-child-element-spacing.d.ts new file mode 100644 index 00000000..3e5dd9ef --- /dev/null +++ b/src/rules/react/jsx-child-element-spacing.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-child-element-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-child-element-spacing.md) + */ +export type JsxChildElementSpacingRuleConfig = RuleConfig<[]>; + +/** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-child-element-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-child-element-spacing.md) + */ +export interface JsxChildElementSpacingRule { + /** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-child-element-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-child-element-spacing.md) + */ + 'react/jsx-child-element-spacing': JsxChildElementSpacingRuleConfig; +} diff --git a/src/rules/react/jsx-closing-bracket-location.d.ts b/src/rules/react/jsx-closing-bracket-location.d.ts new file mode 100644 index 00000000..caa18868 --- /dev/null +++ b/src/rules/react/jsx-closing-bracket-location.d.ts @@ -0,0 +1,57 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxClosingBracketLocationOption = + | ('after-props' | 'props-aligned' | 'tag-aligned' | 'line-aligned') + | { + location?: + | 'after-props' + | 'props-aligned' + | 'tag-aligned' + | 'line-aligned'; + } + | { + nonEmpty?: + | 'after-props' + | 'props-aligned' + | 'tag-aligned' + | 'line-aligned' + | false; + selfClosing?: + | 'after-props' + | 'props-aligned' + | 'tag-aligned' + | 'line-aligned' + | false; + }; + +/** + * Options. + */ +export type JsxClosingBracketLocationOptions = [ + JsxClosingBracketLocationOption?, +]; + +/** + * Enforce closing bracket location in JSX. + * + * @see [jsx-closing-bracket-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-bracket-location.md) + */ +export type JsxClosingBracketLocationRuleConfig = + RuleConfig; + +/** + * Enforce closing bracket location in JSX. + * + * @see [jsx-closing-bracket-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-bracket-location.md) + */ +export interface JsxClosingBracketLocationRule { + /** + * Enforce closing bracket location in JSX. + * + * @see [jsx-closing-bracket-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-bracket-location.md) + */ + 'react/jsx-closing-bracket-location': JsxClosingBracketLocationRuleConfig; +} diff --git a/src/rules/react/jsx-closing-tag-location.d.ts b/src/rules/react/jsx-closing-tag-location.d.ts new file mode 100644 index 00000000..db030681 --- /dev/null +++ b/src/rules/react/jsx-closing-tag-location.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce closing tag location for multiline JSX. + * + * @see [jsx-closing-tag-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-tag-location.md) + */ +export type JsxClosingTagLocationRuleConfig = RuleConfig<[]>; + +/** + * Enforce closing tag location for multiline JSX. + * + * @see [jsx-closing-tag-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-tag-location.md) + */ +export interface JsxClosingTagLocationRule { + /** + * Enforce closing tag location for multiline JSX. + * + * @see [jsx-closing-tag-location](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-closing-tag-location.md) + */ + 'react/jsx-closing-tag-location': JsxClosingTagLocationRuleConfig; +} diff --git a/src/rules/react/jsx-curly-brace-presence.d.ts b/src/rules/react/jsx-curly-brace-presence.d.ts new file mode 100644 index 00000000..31b58e9e --- /dev/null +++ b/src/rules/react/jsx-curly-brace-presence.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxCurlyBracePresenceOption = + | { + props?: 'always' | 'never' | 'ignore'; + children?: 'always' | 'never' | 'ignore'; + propElementValues?: 'always' | 'never' | 'ignore'; + } + | ('always' | 'never' | 'ignore'); + +/** + * Options. + */ +export type JsxCurlyBracePresenceOptions = [JsxCurlyBracePresenceOption?]; + +/** + * Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes. + * + * @see [jsx-curly-brace-presence](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-brace-presence.md) + */ +export type JsxCurlyBracePresenceRuleConfig = + RuleConfig; + +/** + * Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes. + * + * @see [jsx-curly-brace-presence](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-brace-presence.md) + */ +export interface JsxCurlyBracePresenceRule { + /** + * Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes. + * + * @see [jsx-curly-brace-presence](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-brace-presence.md) + */ + 'react/jsx-curly-brace-presence': JsxCurlyBracePresenceRuleConfig; +} diff --git a/src/rules/react/jsx-curly-newline.d.ts b/src/rules/react/jsx-curly-newline.d.ts new file mode 100644 index 00000000..b5bf7be1 --- /dev/null +++ b/src/rules/react/jsx-curly-newline.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxCurlyNewlineOption = + | ('consistent' | 'never') + | { + singleline?: 'consistent' | 'require' | 'forbid'; + multiline?: 'consistent' | 'require' | 'forbid'; + }; + +/** + * Options. + */ +export type JsxCurlyNewlineOptions = [JsxCurlyNewlineOption?]; + +/** + * Enforce consistent linebreaks in curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-newline.md) + */ +export type JsxCurlyNewlineRuleConfig = RuleConfig; + +/** + * Enforce consistent linebreaks in curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-newline.md) + */ +export interface JsxCurlyNewlineRule { + /** + * Enforce consistent linebreaks in curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-newline.md) + */ + 'react/jsx-curly-newline': JsxCurlyNewlineRuleConfig; +} diff --git a/src/rules/react/jsx-curly-spacing.d.ts b/src/rules/react/jsx-curly-spacing.d.ts new file mode 100644 index 00000000..dea785d2 --- /dev/null +++ b/src/rules/react/jsx-curly-spacing.d.ts @@ -0,0 +1,69 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxCurlySpacingOption = + | [] + | [ + | (BasicConfig & { + attributes?: BasicConfigOrBoolean; + children?: BasicConfigOrBoolean; + [k: string]: any; + }) + | ('always' | 'never'), + ] + | [ + ( + | (BasicConfig & { + attributes?: BasicConfigOrBoolean; + children?: BasicConfigOrBoolean; + [k: string]: any; + }) + | ('always' | 'never') + ), + { + allowMultiline?: boolean; + spacing?: { + objectLiterals?: 'always' | 'never'; + [k: string]: any; + }; + }, + ]; +export type BasicConfigOrBoolean = BasicConfig | boolean; + +export interface BasicConfig { + when?: 'always' | 'never'; + allowMultiline?: boolean; + spacing?: { + objectLiterals?: 'always' | 'never'; + [k: string]: any; + }; + [k: string]: any; +} + +/** + * Options. + */ +export type JsxCurlySpacingOptions = JsxCurlySpacingOption; + +/** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-spacing.md) + */ +export type JsxCurlySpacingRuleConfig = RuleConfig; + +/** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-spacing.md) + */ +export interface JsxCurlySpacingRule { + /** + * Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. + * + * @see [jsx-curly-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-spacing.md) + */ + 'react/jsx-curly-spacing': JsxCurlySpacingRuleConfig; +} diff --git a/src/rules/react/jsx-equals-spacing.d.ts b/src/rules/react/jsx-equals-spacing.d.ts new file mode 100644 index 00000000..434a5d75 --- /dev/null +++ b/src/rules/react/jsx-equals-spacing.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxEqualsSpacingOption = 'always' | 'never'; + +/** + * Options. + */ +export type JsxEqualsSpacingOptions = [JsxEqualsSpacingOption?]; + +/** + * Enforce or disallow spaces around equal signs in JSX attributes. + * + * @see [jsx-equals-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-equals-spacing.md) + */ +export type JsxEqualsSpacingRuleConfig = RuleConfig; + +/** + * Enforce or disallow spaces around equal signs in JSX attributes. + * + * @see [jsx-equals-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-equals-spacing.md) + */ +export interface JsxEqualsSpacingRule { + /** + * Enforce or disallow spaces around equal signs in JSX attributes. + * + * @see [jsx-equals-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-equals-spacing.md) + */ + 'react/jsx-equals-spacing': JsxEqualsSpacingRuleConfig; +} diff --git a/src/rules/react/jsx-filename-extension.d.ts b/src/rules/react/jsx-filename-extension.d.ts new file mode 100644 index 00000000..8da86ed9 --- /dev/null +++ b/src/rules/react/jsx-filename-extension.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxFilenameExtensionOption { + allow?: 'always' | 'as-needed'; + extensions?: string[]; +} + +/** + * Options. + */ +export type JsxFilenameExtensionOptions = [JsxFilenameExtensionOption?]; + +/** + * Disallow file extensions that may contain JSX. + * + * @see [jsx-filename-extension](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-filename-extension.md) + */ +export type JsxFilenameExtensionRuleConfig = + RuleConfig; + +/** + * Disallow file extensions that may contain JSX. + * + * @see [jsx-filename-extension](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-filename-extension.md) + */ +export interface JsxFilenameExtensionRule { + /** + * Disallow file extensions that may contain JSX. + * + * @see [jsx-filename-extension](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-filename-extension.md) + */ + 'react/jsx-filename-extension': JsxFilenameExtensionRuleConfig; +} diff --git a/src/rules/react/jsx-first-prop-new-line.d.ts b/src/rules/react/jsx-first-prop-new-line.d.ts new file mode 100644 index 00000000..debba3c0 --- /dev/null +++ b/src/rules/react/jsx-first-prop-new-line.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxFirstPropNewLineOption = + | 'always' + | 'never' + | 'multiline' + | 'multiline-multiprop'; + +/** + * Options. + */ +export type JsxFirstPropNewLineOptions = [JsxFirstPropNewLineOption?]; + +/** + * Enforce proper position of the first property in JSX. + * + * @see [jsx-first-prop-new-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-first-prop-new-line.md) + */ +export type JsxFirstPropNewLineRuleConfig = + RuleConfig; + +/** + * Enforce proper position of the first property in JSX. + * + * @see [jsx-first-prop-new-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-first-prop-new-line.md) + */ +export interface JsxFirstPropNewLineRule { + /** + * Enforce proper position of the first property in JSX. + * + * @see [jsx-first-prop-new-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-first-prop-new-line.md) + */ + 'react/jsx-first-prop-new-line': JsxFirstPropNewLineRuleConfig; +} diff --git a/src/rules/react/jsx-fragments.d.ts b/src/rules/react/jsx-fragments.d.ts new file mode 100644 index 00000000..7a81a9ca --- /dev/null +++ b/src/rules/react/jsx-fragments.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxFragmentsOption = 'syntax' | 'element'; + +/** + * Options. + */ +export type JsxFragmentsOptions = [JsxFragmentsOption?]; + +/** + * Enforce shorthand or standard form for React fragments. + * + * @see [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md) + */ +export type JsxFragmentsRuleConfig = RuleConfig; + +/** + * Enforce shorthand or standard form for React fragments. + * + * @see [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md) + */ +export interface JsxFragmentsRule { + /** + * Enforce shorthand or standard form for React fragments. + * + * @see [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md) + */ + 'react/jsx-fragments': JsxFragmentsRuleConfig; +} diff --git a/src/rules/react/jsx-handler-names.d.ts b/src/rules/react/jsx-handler-names.d.ts new file mode 100644 index 00000000..4d9c39f3 --- /dev/null +++ b/src/rules/react/jsx-handler-names.d.ts @@ -0,0 +1,56 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxHandlerNamesOption = + | { + eventHandlerPrefix?: string; + eventHandlerPropPrefix?: string; + checkLocalVariables?: boolean; + checkInlineFunction?: boolean; + } + | { + eventHandlerPrefix?: string; + eventHandlerPropPrefix?: false; + checkLocalVariables?: boolean; + checkInlineFunction?: boolean; + } + | { + eventHandlerPrefix?: false; + eventHandlerPropPrefix?: string; + checkLocalVariables?: boolean; + checkInlineFunction?: boolean; + } + | { + checkLocalVariables?: boolean; + } + | { + checkInlineFunction?: boolean; + }; + +/** + * Options. + */ +export type JsxHandlerNamesOptions = [JsxHandlerNamesOption?]; + +/** + * Enforce event handler naming conventions in JSX. + * + * @see [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md) + */ +export type JsxHandlerNamesRuleConfig = RuleConfig; + +/** + * Enforce event handler naming conventions in JSX. + * + * @see [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md) + */ +export interface JsxHandlerNamesRule { + /** + * Enforce event handler naming conventions in JSX. + * + * @see [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md) + */ + 'react/jsx-handler-names': JsxHandlerNamesRuleConfig; +} diff --git a/src/rules/react/jsx-indent-props.d.ts b/src/rules/react/jsx-indent-props.d.ts new file mode 100644 index 00000000..e52e1dab --- /dev/null +++ b/src/rules/react/jsx-indent-props.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxIndentPropsOption = + | ('tab' | 'first') + | number + | { + indentMode?: ('tab' | 'first') | number; + ignoreTernaryOperator?: boolean; + [k: string]: any; + }; + +/** + * Options. + */ +export type JsxIndentPropsOptions = [JsxIndentPropsOption?]; + +/** + * Enforce props indentation in JSX. + * + * @see [jsx-indent-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent-props.md) + */ +export type JsxIndentPropsRuleConfig = RuleConfig; + +/** + * Enforce props indentation in JSX. + * + * @see [jsx-indent-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent-props.md) + */ +export interface JsxIndentPropsRule { + /** + * Enforce props indentation in JSX. + * + * @see [jsx-indent-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent-props.md) + */ + 'react/jsx-indent-props': JsxIndentPropsRuleConfig; +} diff --git a/src/rules/react/jsx-indent.d.ts b/src/rules/react/jsx-indent.d.ts new file mode 100644 index 00000000..1dfd046c --- /dev/null +++ b/src/rules/react/jsx-indent.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface JsxIndentConfig { + checkAttributes?: boolean; + indentLogicalExpressions?: boolean; +} + +/** + * Option. + */ +export type JsxIndentOption = 'tab' | number; + +/** + * Options. + */ +export type JsxIndentOptions = [JsxIndentOption?, JsxIndentConfig?]; + +/** + * Enforce JSX indentation. + * + * @see [jsx-indent](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent.md) + */ +export type JsxIndentRuleConfig = RuleConfig; + +/** + * Enforce JSX indentation. + * + * @see [jsx-indent](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent.md) + */ +export interface JsxIndentRule { + /** + * Enforce JSX indentation. + * + * @see [jsx-indent](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-indent.md) + */ + 'react/jsx-indent': JsxIndentRuleConfig; +} diff --git a/src/rules/react/jsx-key.d.ts b/src/rules/react/jsx-key.d.ts new file mode 100644 index 00000000..747e3482 --- /dev/null +++ b/src/rules/react/jsx-key.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxKeyOption { + checkFragmentShorthand?: boolean; + checkKeyMustBeforeSpread?: boolean; + warnOnDuplicates?: boolean; +} + +/** + * Options. + */ +export type JsxKeyOptions = [JsxKeyOption?]; + +/** + * Disallow missing `key` props in iterators/collection literals. + * + * @see [jsx-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-key.md) + */ +export type JsxKeyRuleConfig = RuleConfig; + +/** + * Disallow missing `key` props in iterators/collection literals. + * + * @see [jsx-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-key.md) + */ +export interface JsxKeyRule { + /** + * Disallow missing `key` props in iterators/collection literals. + * + * @see [jsx-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-key.md) + */ + 'react/jsx-key': JsxKeyRuleConfig; +} diff --git a/src/rules/react/jsx-max-depth.d.ts b/src/rules/react/jsx-max-depth.d.ts new file mode 100644 index 00000000..ffbf69e2 --- /dev/null +++ b/src/rules/react/jsx-max-depth.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxMaxDepthOption { + max?: number; +} + +/** + * Options. + */ +export type JsxMaxDepthOptions = [JsxMaxDepthOption?]; + +/** + * Enforce JSX maximum depth. + * + * @see [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md) + */ +export type JsxMaxDepthRuleConfig = RuleConfig; + +/** + * Enforce JSX maximum depth. + * + * @see [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md) + */ +export interface JsxMaxDepthRule { + /** + * Enforce JSX maximum depth. + * + * @see [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md) + */ + 'react/jsx-max-depth': JsxMaxDepthRuleConfig; +} diff --git a/src/rules/react/jsx-max-props-per-line.d.ts b/src/rules/react/jsx-max-props-per-line.d.ts new file mode 100644 index 00000000..a36e414c --- /dev/null +++ b/src/rules/react/jsx-max-props-per-line.d.ts @@ -0,0 +1,44 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxMaxPropsPerLineOption = + | { + maximum?: { + single?: number; + multi?: number; + [k: string]: any; + }; + } + | { + maximum?: number; + when?: 'always' | 'multiline'; + }; + +/** + * Options. + */ +export type JsxMaxPropsPerLineOptions = [JsxMaxPropsPerLineOption?]; + +/** + * Enforce maximum of props on a single line in JSX. + * + * @see [jsx-max-props-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-props-per-line.md) + */ +export type JsxMaxPropsPerLineRuleConfig = + RuleConfig; + +/** + * Enforce maximum of props on a single line in JSX. + * + * @see [jsx-max-props-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-props-per-line.md) + */ +export interface JsxMaxPropsPerLineRule { + /** + * Enforce maximum of props on a single line in JSX. + * + * @see [jsx-max-props-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-props-per-line.md) + */ + 'react/jsx-max-props-per-line': JsxMaxPropsPerLineRuleConfig; +} diff --git a/src/rules/react/jsx-newline.d.ts b/src/rules/react/jsx-newline.d.ts new file mode 100644 index 00000000..87a960e9 --- /dev/null +++ b/src/rules/react/jsx-newline.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNewlineOption { + prevent?: boolean; + allowMultilines?: boolean; +} + +/** + * Options. + */ +export type JsxNewlineOptions = [JsxNewlineOption?]; + +/** + * Require or prevent a new line after jsx elements and expressions. + * + * @see [jsx-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-newline.md) + */ +export type JsxNewlineRuleConfig = RuleConfig; + +/** + * Require or prevent a new line after jsx elements and expressions. + * + * @see [jsx-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-newline.md) + */ +export interface JsxNewlineRule { + /** + * Require or prevent a new line after jsx elements and expressions. + * + * @see [jsx-newline](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-newline.md) + */ + 'react/jsx-newline': JsxNewlineRuleConfig; +} diff --git a/src/rules/react/jsx-no-bind.d.ts b/src/rules/react/jsx-no-bind.d.ts new file mode 100644 index 00000000..a9c7bc4c --- /dev/null +++ b/src/rules/react/jsx-no-bind.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoBindOption { + allowArrowFunctions?: boolean; + allowBind?: boolean; + allowFunctions?: boolean; + ignoreRefs?: boolean; + ignoreDOMComponents?: boolean; +} + +/** + * Options. + */ +export type JsxNoBindOptions = [JsxNoBindOption?]; + +/** + * Disallow `.bind()` or arrow functions in JSX props. + * + * @see [jsx-no-bind](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-bind.md) + */ +export type JsxNoBindRuleConfig = RuleConfig; + +/** + * Disallow `.bind()` or arrow functions in JSX props. + * + * @see [jsx-no-bind](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-bind.md) + */ +export interface JsxNoBindRule { + /** + * Disallow `.bind()` or arrow functions in JSX props. + * + * @see [jsx-no-bind](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-bind.md) + */ + 'react/jsx-no-bind': JsxNoBindRuleConfig; +} diff --git a/src/rules/react/jsx-no-comment-textnodes.d.ts b/src/rules/react/jsx-no-comment-textnodes.d.ts new file mode 100644 index 00000000..cac5f38c --- /dev/null +++ b/src/rules/react/jsx-no-comment-textnodes.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow comments from being inserted as text nodes. + * + * @see [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md) + */ +export type JsxNoCommentTextnodesRuleConfig = RuleConfig<[]>; + +/** + * Disallow comments from being inserted as text nodes. + * + * @see [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md) + */ +export interface JsxNoCommentTextnodesRule { + /** + * Disallow comments from being inserted as text nodes. + * + * @see [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md) + */ + 'react/jsx-no-comment-textnodes': JsxNoCommentTextnodesRuleConfig; +} diff --git a/src/rules/react/jsx-no-constructed-context-values.d.ts b/src/rules/react/jsx-no-constructed-context-values.d.ts new file mode 100644 index 00000000..e3566935 --- /dev/null +++ b/src/rules/react/jsx-no-constructed-context-values.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Options. + */ +export type JsxNoConstructedContextValuesOptions = []; + +/** + * Disallows JSX context provider values from taking values that will cause needless rerenders. + * + * @see [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md) + */ +export type JsxNoConstructedContextValuesRuleConfig = + RuleConfig; + +/** + * Disallows JSX context provider values from taking values that will cause needless rerenders. + * + * @see [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md) + */ +export interface JsxNoConstructedContextValuesRule { + /** + * Disallows JSX context provider values from taking values that will cause needless rerenders. + * + * @see [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md) + */ + 'react/jsx-no-constructed-context-values': JsxNoConstructedContextValuesRuleConfig; +} diff --git a/src/rules/react/jsx-no-duplicate-props.d.ts b/src/rules/react/jsx-no-duplicate-props.d.ts new file mode 100644 index 00000000..0db2e48b --- /dev/null +++ b/src/rules/react/jsx-no-duplicate-props.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoDuplicatePropsOption { + ignoreCase?: boolean; +} + +/** + * Options. + */ +export type JsxNoDuplicatePropsOptions = [JsxNoDuplicatePropsOption?]; + +/** + * Disallow duplicate properties in JSX. + * + * @see [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md) + */ +export type JsxNoDuplicatePropsRuleConfig = + RuleConfig; + +/** + * Disallow duplicate properties in JSX. + * + * @see [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md) + */ +export interface JsxNoDuplicatePropsRule { + /** + * Disallow duplicate properties in JSX. + * + * @see [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md) + */ + 'react/jsx-no-duplicate-props': JsxNoDuplicatePropsRuleConfig; +} diff --git a/src/rules/react/jsx-no-leaked-render.d.ts b/src/rules/react/jsx-no-leaked-render.d.ts new file mode 100644 index 00000000..28997195 --- /dev/null +++ b/src/rules/react/jsx-no-leaked-render.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoLeakedRenderOption { + validStrategies?: ('ternary' | 'coerce')[]; +} + +/** + * Options. + */ +export type JsxNoLeakedRenderOptions = [JsxNoLeakedRenderOption?]; + +/** + * Disallow problematic leaked values from being rendered. + * + * @see [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md) + */ +export type JsxNoLeakedRenderRuleConfig = RuleConfig; + +/** + * Disallow problematic leaked values from being rendered. + * + * @see [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md) + */ +export interface JsxNoLeakedRenderRule { + /** + * Disallow problematic leaked values from being rendered. + * + * @see [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md) + */ + 'react/jsx-no-leaked-render': JsxNoLeakedRenderRuleConfig; +} diff --git a/src/rules/react/jsx-no-literals.d.ts b/src/rules/react/jsx-no-literals.d.ts new file mode 100644 index 00000000..d84c54c5 --- /dev/null +++ b/src/rules/react/jsx-no-literals.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoLiteralsOption { + noStrings?: boolean; + allowedStrings?: string[]; + ignoreProps?: boolean; + noAttributeStrings?: boolean; +} + +/** + * Options. + */ +export type JsxNoLiteralsOptions = [JsxNoLiteralsOption?]; + +/** + * Disallow usage of string literals in JSX. + * + * @see [jsx-no-literals](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-literals.md) + */ +export type JsxNoLiteralsRuleConfig = RuleConfig; + +/** + * Disallow usage of string literals in JSX. + * + * @see [jsx-no-literals](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-literals.md) + */ +export interface JsxNoLiteralsRule { + /** + * Disallow usage of string literals in JSX. + * + * @see [jsx-no-literals](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-literals.md) + */ + 'react/jsx-no-literals': JsxNoLiteralsRuleConfig; +} diff --git a/src/rules/react/jsx-no-script-url.d.ts b/src/rules/react/jsx-no-script-url.d.ts new file mode 100644 index 00000000..4dc7f429 --- /dev/null +++ b/src/rules/react/jsx-no-script-url.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxNoScriptUrlOption = { + name: string; + props: string[]; +}[]; + +/** + * Options. + */ +export type JsxNoScriptUrlOptions = [JsxNoScriptUrlOption?]; + +/** + * Disallow usage of `javascript:` URLs. + * + * @see [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md) + */ +export type JsxNoScriptUrlRuleConfig = RuleConfig; + +/** + * Disallow usage of `javascript:` URLs. + * + * @see [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md) + */ +export interface JsxNoScriptUrlRule { + /** + * Disallow usage of `javascript:` URLs. + * + * @see [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md) + */ + 'react/jsx-no-script-url': JsxNoScriptUrlRuleConfig; +} diff --git a/src/rules/react/jsx-no-target-blank.d.ts b/src/rules/react/jsx-no-target-blank.d.ts new file mode 100644 index 00000000..694c52c8 --- /dev/null +++ b/src/rules/react/jsx-no-target-blank.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoTargetBlankOption { + allowReferrer?: boolean; + enforceDynamicLinks?: 'always' | 'never'; + warnOnSpreadAttributes?: boolean; + links?: boolean; + forms?: boolean; +} + +/** + * Options. + */ +export type JsxNoTargetBlankOptions = [JsxNoTargetBlankOption?]; + +/** + * Disallow `target="_blank"` attribute without `rel="noreferrer"`. + * + * @see [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md) + */ +export type JsxNoTargetBlankRuleConfig = RuleConfig; + +/** + * Disallow `target="_blank"` attribute without `rel="noreferrer"`. + * + * @see [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md) + */ +export interface JsxNoTargetBlankRule { + /** + * Disallow `target="_blank"` attribute without `rel="noreferrer"`. + * + * @see [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md) + */ + 'react/jsx-no-target-blank': JsxNoTargetBlankRuleConfig; +} diff --git a/src/rules/react/jsx-no-undef.d.ts b/src/rules/react/jsx-no-undef.d.ts new file mode 100644 index 00000000..dcaf1625 --- /dev/null +++ b/src/rules/react/jsx-no-undef.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoUndefOption { + allowGlobals?: boolean; +} + +/** + * Options. + */ +export type JsxNoUndefOptions = [JsxNoUndefOption?]; + +/** + * Disallow undeclared variables in JSX. + * + * @see [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md) + */ +export type JsxNoUndefRuleConfig = RuleConfig; + +/** + * Disallow undeclared variables in JSX. + * + * @see [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md) + */ +export interface JsxNoUndefRule { + /** + * Disallow undeclared variables in JSX. + * + * @see [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md) + */ + 'react/jsx-no-undef': JsxNoUndefRuleConfig; +} diff --git a/src/rules/react/jsx-no-useless-fragment.d.ts b/src/rules/react/jsx-no-useless-fragment.d.ts new file mode 100644 index 00000000..7b3d7de5 --- /dev/null +++ b/src/rules/react/jsx-no-useless-fragment.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxNoUselessFragmentOption { + allowExpressions?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type JsxNoUselessFragmentOptions = [JsxNoUselessFragmentOption?]; + +/** + * Disallow unnecessary fragments. + * + * @see [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md) + */ +export type JsxNoUselessFragmentRuleConfig = + RuleConfig; + +/** + * Disallow unnecessary fragments. + * + * @see [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md) + */ +export interface JsxNoUselessFragmentRule { + /** + * Disallow unnecessary fragments. + * + * @see [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md) + */ + 'react/jsx-no-useless-fragment': JsxNoUselessFragmentRuleConfig; +} diff --git a/src/rules/react/jsx-one-expression-per-line.d.ts b/src/rules/react/jsx-one-expression-per-line.d.ts new file mode 100644 index 00000000..06d71aa1 --- /dev/null +++ b/src/rules/react/jsx-one-expression-per-line.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxOneExpressionPerLineOption { + allow?: 'none' | 'literal' | 'single-child'; +} + +/** + * Options. + */ +export type JsxOneExpressionPerLineOptions = [JsxOneExpressionPerLineOption?]; + +/** + * Require one JSX element per line. + * + * @see [jsx-one-expression-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-one-expression-per-line.md) + */ +export type JsxOneExpressionPerLineRuleConfig = + RuleConfig; + +/** + * Require one JSX element per line. + * + * @see [jsx-one-expression-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-one-expression-per-line.md) + */ +export interface JsxOneExpressionPerLineRule { + /** + * Require one JSX element per line. + * + * @see [jsx-one-expression-per-line](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-one-expression-per-line.md) + */ + 'react/jsx-one-expression-per-line': JsxOneExpressionPerLineRuleConfig; +} diff --git a/src/rules/react/jsx-pascal-case.d.ts b/src/rules/react/jsx-pascal-case.d.ts new file mode 100644 index 00000000..487f5dfa --- /dev/null +++ b/src/rules/react/jsx-pascal-case.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxPascalCaseOption { + allowAllCaps?: boolean; + allowLeadingUnderscore?: boolean; + allowNamespace?: boolean; + /** + * @minItems 0 + */ + ignore?: [] | [string]; +} + +/** + * Options. + */ +export type JsxPascalCaseOptions = [JsxPascalCaseOption?]; + +/** + * Enforce PascalCase for user-defined JSX components. + * + * @see [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md) + */ +export type JsxPascalCaseRuleConfig = RuleConfig; + +/** + * Enforce PascalCase for user-defined JSX components. + * + * @see [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md) + */ +export interface JsxPascalCaseRule { + /** + * Enforce PascalCase for user-defined JSX components. + * + * @see [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md) + */ + 'react/jsx-pascal-case': JsxPascalCaseRuleConfig; +} diff --git a/src/rules/react/jsx-props-no-multi-spaces.d.ts b/src/rules/react/jsx-props-no-multi-spaces.d.ts new file mode 100644 index 00000000..d7bf7819 --- /dev/null +++ b/src/rules/react/jsx-props-no-multi-spaces.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow multiple spaces between inline JSX props. + * + * @see [jsx-props-no-multi-spaces](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-multi-spaces.md) + */ +export type JsxPropsNoMultiSpacesRuleConfig = RuleConfig<[]>; + +/** + * Disallow multiple spaces between inline JSX props. + * + * @see [jsx-props-no-multi-spaces](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-multi-spaces.md) + */ +export interface JsxPropsNoMultiSpacesRule { + /** + * Disallow multiple spaces between inline JSX props. + * + * @see [jsx-props-no-multi-spaces](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-multi-spaces.md) + */ + 'react/jsx-props-no-multi-spaces': JsxPropsNoMultiSpacesRuleConfig; +} diff --git a/src/rules/react/jsx-props-no-spreading.d.ts b/src/rules/react/jsx-props-no-spreading.d.ts new file mode 100644 index 00000000..ba1e1bc6 --- /dev/null +++ b/src/rules/react/jsx-props-no-spreading.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxPropsNoSpreadingOption = { + html?: 'enforce' | 'ignore'; + custom?: 'enforce' | 'ignore'; + exceptions?: string[]; + [k: string]: any; +}; + +/** + * Options. + */ +export type JsxPropsNoSpreadingOptions = [JsxPropsNoSpreadingOption?]; + +/** + * Disallow JSX prop spreading. + * + * @see [jsx-props-no-spreading](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spreading.md) + */ +export type JsxPropsNoSpreadingRuleConfig = + RuleConfig; + +/** + * Disallow JSX prop spreading. + * + * @see [jsx-props-no-spreading](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spreading.md) + */ +export interface JsxPropsNoSpreadingRule { + /** + * Disallow JSX prop spreading. + * + * @see [jsx-props-no-spreading](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spreading.md) + */ + 'react/jsx-props-no-spreading': JsxPropsNoSpreadingRuleConfig; +} diff --git a/src/rules/react/jsx-sort-default-props.d.ts b/src/rules/react/jsx-sort-default-props.d.ts new file mode 100644 index 00000000..00b40c5a --- /dev/null +++ b/src/rules/react/jsx-sort-default-props.d.ts @@ -0,0 +1,41 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxSortDefaultPropsOption { + ignoreCase?: boolean; +} + +/** + * Options. + */ +export type JsxSortDefaultPropsOptions = [JsxSortDefaultPropsOption?]; + +/** + * Enforce defaultProps declarations alphabetical sorting. + * + * @deprecated + * + * @see [jsx-sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-default-props.md) + */ +export type JsxSortDefaultPropsRuleConfig = + RuleConfig; + +/** + * Enforce defaultProps declarations alphabetical sorting. + * + * @deprecated + * + * @see [jsx-sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-default-props.md) + */ +export interface JsxSortDefaultPropsRule { + /** + * Enforce defaultProps declarations alphabetical sorting. + * + * @deprecated + * + * @see [jsx-sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-default-props.md) + */ + 'react/jsx-sort-default-props': JsxSortDefaultPropsRuleConfig; +} diff --git a/src/rules/react/jsx-sort-props.d.ts b/src/rules/react/jsx-sort-props.d.ts new file mode 100644 index 00000000..c4aa5594 --- /dev/null +++ b/src/rules/react/jsx-sort-props.d.ts @@ -0,0 +1,41 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxSortPropsOption { + callbacksLast?: boolean; + shorthandFirst?: boolean; + shorthandLast?: boolean; + multiline?: 'ignore' | 'first' | 'last'; + ignoreCase?: boolean; + noSortAlphabetically?: boolean; + reservedFirst?: any[] | boolean; + locale?: string; +} + +/** + * Options. + */ +export type JsxSortPropsOptions = [JsxSortPropsOption?]; + +/** + * Enforce props alphabetical sorting. + * + * @see [jsx-sort-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-props.md) + */ +export type JsxSortPropsRuleConfig = RuleConfig; + +/** + * Enforce props alphabetical sorting. + * + * @see [jsx-sort-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-props.md) + */ +export interface JsxSortPropsRule { + /** + * Enforce props alphabetical sorting. + * + * @see [jsx-sort-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-sort-props.md) + */ + 'react/jsx-sort-props': JsxSortPropsRuleConfig; +} diff --git a/src/rules/react/jsx-space-before-closing.d.ts b/src/rules/react/jsx-space-before-closing.d.ts new file mode 100644 index 00000000..938a1d4e --- /dev/null +++ b/src/rules/react/jsx-space-before-closing.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type JsxSpaceBeforeClosingOption = 'always' | 'never'; + +/** + * Options. + */ +export type JsxSpaceBeforeClosingOptions = [JsxSpaceBeforeClosingOption?]; + +/** + * Enforce spacing before closing bracket in JSX. + * + * @deprecated + * + * @see [jsx-space-before-closing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-space-before-closing.md) + */ +export type JsxSpaceBeforeClosingRuleConfig = + RuleConfig; + +/** + * Enforce spacing before closing bracket in JSX. + * + * @deprecated + * + * @see [jsx-space-before-closing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-space-before-closing.md) + */ +export interface JsxSpaceBeforeClosingRule { + /** + * Enforce spacing before closing bracket in JSX. + * + * @deprecated + * + * @see [jsx-space-before-closing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-space-before-closing.md) + */ + 'react/jsx-space-before-closing': JsxSpaceBeforeClosingRuleConfig; +} diff --git a/src/rules/react/jsx-tag-spacing.d.ts b/src/rules/react/jsx-tag-spacing.d.ts new file mode 100644 index 00000000..a2903332 --- /dev/null +++ b/src/rules/react/jsx-tag-spacing.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxTagSpacingOption { + closingSlash?: 'always' | 'never' | 'allow'; + beforeSelfClosing?: 'always' | 'proportional-always' | 'never' | 'allow'; + afterOpening?: 'always' | 'allow-multiline' | 'never' | 'allow'; + beforeClosing?: 'always' | 'proportional-always' | 'never' | 'allow'; +} + +/** + * Options. + */ +export type JsxTagSpacingOptions = [JsxTagSpacingOption?]; + +/** + * Enforce whitespace in and around the JSX opening and closing brackets. + * + * @see [jsx-tag-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-tag-spacing.md) + */ +export type JsxTagSpacingRuleConfig = RuleConfig; + +/** + * Enforce whitespace in and around the JSX opening and closing brackets. + * + * @see [jsx-tag-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-tag-spacing.md) + */ +export interface JsxTagSpacingRule { + /** + * Enforce whitespace in and around the JSX opening and closing brackets. + * + * @see [jsx-tag-spacing](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-tag-spacing.md) + */ + 'react/jsx-tag-spacing': JsxTagSpacingRuleConfig; +} diff --git a/src/rules/react/jsx-uses-react.d.ts b/src/rules/react/jsx-uses-react.d.ts new file mode 100644 index 00000000..a1eae02b --- /dev/null +++ b/src/rules/react/jsx-uses-react.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow React to be incorrectly marked as unused. + * + * @see [jsx-uses-react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-react.md) + */ +export type JsxUsesReactRuleConfig = RuleConfig<[]>; + +/** + * Disallow React to be incorrectly marked as unused. + * + * @see [jsx-uses-react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-react.md) + */ +export interface JsxUsesReactRule { + /** + * Disallow React to be incorrectly marked as unused. + * + * @see [jsx-uses-react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-react.md) + */ + 'react/jsx-uses-react': JsxUsesReactRuleConfig; +} diff --git a/src/rules/react/jsx-uses-vars.d.ts b/src/rules/react/jsx-uses-vars.d.ts new file mode 100644 index 00000000..6325943a --- /dev/null +++ b/src/rules/react/jsx-uses-vars.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow variables used in JSX to be incorrectly marked as unused. + * + * @see [jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-vars.md) + */ +export type JsxUsesVarsRuleConfig = RuleConfig<[]>; + +/** + * Disallow variables used in JSX to be incorrectly marked as unused. + * + * @see [jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-vars.md) + */ +export interface JsxUsesVarsRule { + /** + * Disallow variables used in JSX to be incorrectly marked as unused. + * + * @see [jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-vars.md) + */ + 'react/jsx-uses-vars': JsxUsesVarsRuleConfig; +} diff --git a/src/rules/react/jsx-wrap-multilines.d.ts b/src/rules/react/jsx-wrap-multilines.d.ts new file mode 100644 index 00000000..0558d0de --- /dev/null +++ b/src/rules/react/jsx-wrap-multilines.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface JsxWrapMultilinesOption { + declaration?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + assignment?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + return?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + arrow?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + condition?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + logical?: true | false | 'ignore' | 'parens' | 'parens-new-line'; + prop?: true | false | 'ignore' | 'parens' | 'parens-new-line'; +} + +/** + * Options. + */ +export type JsxWrapMultilinesOptions = [JsxWrapMultilinesOption?]; + +/** + * Disallow missing parentheses around multiline JSX. + * + * @see [jsx-wrap-multilines](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-wrap-multilines.md) + */ +export type JsxWrapMultilinesRuleConfig = RuleConfig; + +/** + * Disallow missing parentheses around multiline JSX. + * + * @see [jsx-wrap-multilines](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-wrap-multilines.md) + */ +export interface JsxWrapMultilinesRule { + /** + * Disallow missing parentheses around multiline JSX. + * + * @see [jsx-wrap-multilines](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-wrap-multilines.md) + */ + 'react/jsx-wrap-multilines': JsxWrapMultilinesRuleConfig; +} diff --git a/src/rules/react/no-access-state-in-setstate.d.ts b/src/rules/react/no-access-state-in-setstate.d.ts new file mode 100644 index 00000000..d61fff6e --- /dev/null +++ b/src/rules/react/no-access-state-in-setstate.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow when this.state is accessed within setState. + * + * @see [no-access-state-in-setstate](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-access-state-in-setstate.md) + */ +export type NoAccessStateInSetstateRuleConfig = RuleConfig<[]>; + +/** + * Disallow when this.state is accessed within setState. + * + * @see [no-access-state-in-setstate](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-access-state-in-setstate.md) + */ +export interface NoAccessStateInSetstateRule { + /** + * Disallow when this.state is accessed within setState. + * + * @see [no-access-state-in-setstate](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-access-state-in-setstate.md) + */ + 'react/no-access-state-in-setstate': NoAccessStateInSetstateRuleConfig; +} diff --git a/src/rules/react/no-adjacent-inline-elements.d.ts b/src/rules/react/no-adjacent-inline-elements.d.ts new file mode 100644 index 00000000..9d060263 --- /dev/null +++ b/src/rules/react/no-adjacent-inline-elements.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow adjacent inline elements not separated by whitespace. + * + * @see [no-adjacent-inline-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-adjacent-inline-elements.md) + */ +export type NoAdjacentInlineElementsRuleConfig = RuleConfig<[]>; + +/** + * Disallow adjacent inline elements not separated by whitespace. + * + * @see [no-adjacent-inline-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-adjacent-inline-elements.md) + */ +export interface NoAdjacentInlineElementsRule { + /** + * Disallow adjacent inline elements not separated by whitespace. + * + * @see [no-adjacent-inline-elements](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-adjacent-inline-elements.md) + */ + 'react/no-adjacent-inline-elements': NoAdjacentInlineElementsRuleConfig; +} diff --git a/src/rules/react/no-array-index-key.d.ts b/src/rules/react/no-array-index-key.d.ts new file mode 100644 index 00000000..85d87ef3 --- /dev/null +++ b/src/rules/react/no-array-index-key.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of Array index in keys. + * + * @see [no-array-index-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-array-index-key.md) + */ +export type NoArrayIndexKeyRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of Array index in keys. + * + * @see [no-array-index-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-array-index-key.md) + */ +export interface NoArrayIndexKeyRule { + /** + * Disallow usage of Array index in keys. + * + * @see [no-array-index-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-array-index-key.md) + */ + 'react/no-array-index-key': NoArrayIndexKeyRuleConfig; +} diff --git a/src/rules/react/no-arrow-function-lifecycle.d.ts b/src/rules/react/no-arrow-function-lifecycle.d.ts new file mode 100644 index 00000000..969d22c7 --- /dev/null +++ b/src/rules/react/no-arrow-function-lifecycle.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Lifecycle methods should be methods on the prototype, not class fields. + * + * @see [no-arrow-function-lifecycle](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-arrow-function-lifecycle.md) + */ +export type NoArrowFunctionLifecycleRuleConfig = RuleConfig<[]>; + +/** + * Lifecycle methods should be methods on the prototype, not class fields. + * + * @see [no-arrow-function-lifecycle](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-arrow-function-lifecycle.md) + */ +export interface NoArrowFunctionLifecycleRule { + /** + * Lifecycle methods should be methods on the prototype, not class fields. + * + * @see [no-arrow-function-lifecycle](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-arrow-function-lifecycle.md) + */ + 'react/no-arrow-function-lifecycle': NoArrowFunctionLifecycleRuleConfig; +} diff --git a/src/rules/react/no-children-prop.d.ts b/src/rules/react/no-children-prop.d.ts new file mode 100644 index 00000000..cf44e0d3 --- /dev/null +++ b/src/rules/react/no-children-prop.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoChildrenPropOption { + allowFunctions?: boolean; +} + +/** + * Options. + */ +export type NoChildrenPropOptions = [NoChildrenPropOption?]; + +/** + * Disallow passing of children as props. + * + * @see [no-children-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-children-prop.md) + */ +export type NoChildrenPropRuleConfig = RuleConfig; + +/** + * Disallow passing of children as props. + * + * @see [no-children-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-children-prop.md) + */ +export interface NoChildrenPropRule { + /** + * Disallow passing of children as props. + * + * @see [no-children-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-children-prop.md) + */ + 'react/no-children-prop': NoChildrenPropRuleConfig; +} diff --git a/src/rules/react/no-danger-with-children.d.ts b/src/rules/react/no-danger-with-children.d.ts new file mode 100644 index 00000000..7443102c --- /dev/null +++ b/src/rules/react/no-danger-with-children.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow when a DOM element is using both children and dangerouslySetInnerHTML. + * + * @see [no-danger-with-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger-with-children.md) + */ +export type NoDangerWithChildrenRuleConfig = RuleConfig<[]>; + +/** + * Disallow when a DOM element is using both children and dangerouslySetInnerHTML. + * + * @see [no-danger-with-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger-with-children.md) + */ +export interface NoDangerWithChildrenRule { + /** + * Disallow when a DOM element is using both children and dangerouslySetInnerHTML. + * + * @see [no-danger-with-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger-with-children.md) + */ + 'react/no-danger-with-children': NoDangerWithChildrenRuleConfig; +} diff --git a/src/rules/react/no-danger.d.ts b/src/rules/react/no-danger.d.ts new file mode 100644 index 00000000..56797696 --- /dev/null +++ b/src/rules/react/no-danger.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of dangerous JSX properties. + * + * @see [no-danger](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger.md) + */ +export type NoDangerRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of dangerous JSX properties. + * + * @see [no-danger](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger.md) + */ +export interface NoDangerRule { + /** + * Disallow usage of dangerous JSX properties. + * + * @see [no-danger](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger.md) + */ + 'react/no-danger': NoDangerRuleConfig; +} diff --git a/src/rules/react/no-deprecated.d.ts b/src/rules/react/no-deprecated.d.ts new file mode 100644 index 00000000..a20938f3 --- /dev/null +++ b/src/rules/react/no-deprecated.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of deprecated methods. + * + * @see [no-deprecated](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-deprecated.md) + */ +export type NoDeprecatedRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of deprecated methods. + * + * @see [no-deprecated](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-deprecated.md) + */ +export interface NoDeprecatedRule { + /** + * Disallow usage of deprecated methods. + * + * @see [no-deprecated](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-deprecated.md) + */ + 'react/no-deprecated': NoDeprecatedRuleConfig; +} diff --git a/src/rules/react/no-did-mount-set-state.d.ts b/src/rules/react/no-did-mount-set-state.d.ts new file mode 100644 index 00000000..12545fec --- /dev/null +++ b/src/rules/react/no-did-mount-set-state.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoDidMountSetStateOption = 'disallow-in-func'; + +/** + * Options. + */ +export type NoDidMountSetStateOptions = [NoDidMountSetStateOption?]; + +/** + * Disallow usage of setState in componentDidMount. + * + * @see [no-did-mount-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-mount-set-state.md) + */ +export type NoDidMountSetStateRuleConfig = + RuleConfig; + +/** + * Disallow usage of setState in componentDidMount. + * + * @see [no-did-mount-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-mount-set-state.md) + */ +export interface NoDidMountSetStateRule { + /** + * Disallow usage of setState in componentDidMount. + * + * @see [no-did-mount-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-mount-set-state.md) + */ + 'react/no-did-mount-set-state': NoDidMountSetStateRuleConfig; +} diff --git a/src/rules/react/no-did-update-set-state.d.ts b/src/rules/react/no-did-update-set-state.d.ts new file mode 100644 index 00000000..1f904318 --- /dev/null +++ b/src/rules/react/no-did-update-set-state.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoDidUpdateSetStateOption = 'disallow-in-func'; + +/** + * Options. + */ +export type NoDidUpdateSetStateOptions = [NoDidUpdateSetStateOption?]; + +/** + * Disallow usage of setState in componentDidUpdate. + * + * @see [no-did-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md) + */ +export type NoDidUpdateSetStateRuleConfig = + RuleConfig; + +/** + * Disallow usage of setState in componentDidUpdate. + * + * @see [no-did-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md) + */ +export interface NoDidUpdateSetStateRule { + /** + * Disallow usage of setState in componentDidUpdate. + * + * @see [no-did-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md) + */ + 'react/no-did-update-set-state': NoDidUpdateSetStateRuleConfig; +} diff --git a/src/rules/react/no-direct-mutation-state.d.ts b/src/rules/react/no-direct-mutation-state.d.ts new file mode 100644 index 00000000..2660256b --- /dev/null +++ b/src/rules/react/no-direct-mutation-state.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow direct mutation of this.state. + * + * @see [no-direct-mutation-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-direct-mutation-state.md) + */ +export type NoDirectMutationStateRuleConfig = RuleConfig<[]>; + +/** + * Disallow direct mutation of this.state. + * + * @see [no-direct-mutation-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-direct-mutation-state.md) + */ +export interface NoDirectMutationStateRule { + /** + * Disallow direct mutation of this.state. + * + * @see [no-direct-mutation-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-direct-mutation-state.md) + */ + 'react/no-direct-mutation-state': NoDirectMutationStateRuleConfig; +} diff --git a/src/rules/react/no-find-dom-node.d.ts b/src/rules/react/no-find-dom-node.d.ts new file mode 100644 index 00000000..eb7ba159 --- /dev/null +++ b/src/rules/react/no-find-dom-node.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of findDOMNode. + * + * @see [no-find-dom-node](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-find-dom-node.md) + */ +export type NoFindDomNodeRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of findDOMNode. + * + * @see [no-find-dom-node](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-find-dom-node.md) + */ +export interface NoFindDomNodeRule { + /** + * Disallow usage of findDOMNode. + * + * @see [no-find-dom-node](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-find-dom-node.md) + */ + 'react/no-find-dom-node': NoFindDomNodeRuleConfig; +} diff --git a/src/rules/react/no-invalid-html-attribute.d.ts b/src/rules/react/no-invalid-html-attribute.d.ts new file mode 100644 index 00000000..3db7e5d1 --- /dev/null +++ b/src/rules/react/no-invalid-html-attribute.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoInvalidHtmlAttributeOption = 'rel'[]; + +/** + * Options. + */ +export type NoInvalidHtmlAttributeOptions = [NoInvalidHtmlAttributeOption?]; + +/** + * Disallow usage of invalid attributes. + * + * @see [no-invalid-html-attribute](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-invalid-html-attribute.md) + */ +export type NoInvalidHtmlAttributeRuleConfig = + RuleConfig; + +/** + * Disallow usage of invalid attributes. + * + * @see [no-invalid-html-attribute](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-invalid-html-attribute.md) + */ +export interface NoInvalidHtmlAttributeRule { + /** + * Disallow usage of invalid attributes. + * + * @see [no-invalid-html-attribute](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-invalid-html-attribute.md) + */ + 'react/no-invalid-html-attribute': NoInvalidHtmlAttributeRuleConfig; +} diff --git a/src/rules/react/no-is-mounted.d.ts b/src/rules/react/no-is-mounted.d.ts new file mode 100644 index 00000000..7b56a910 --- /dev/null +++ b/src/rules/react/no-is-mounted.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of isMounted. + * + * @see [no-is-mounted](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-is-mounted.md) + */ +export type NoIsMountedRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of isMounted. + * + * @see [no-is-mounted](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-is-mounted.md) + */ +export interface NoIsMountedRule { + /** + * Disallow usage of isMounted. + * + * @see [no-is-mounted](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-is-mounted.md) + */ + 'react/no-is-mounted': NoIsMountedRuleConfig; +} diff --git a/src/rules/react/no-multi-comp.d.ts b/src/rules/react/no-multi-comp.d.ts new file mode 100644 index 00000000..c5dc49db --- /dev/null +++ b/src/rules/react/no-multi-comp.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoMultiCompOption { + ignoreStateless?: boolean; +} + +/** + * Options. + */ +export type NoMultiCompOptions = [NoMultiCompOption?]; + +/** + * Disallow multiple component definition per file. + * + * @see [no-multi-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-multi-comp.md) + */ +export type NoMultiCompRuleConfig = RuleConfig; + +/** + * Disallow multiple component definition per file. + * + * @see [no-multi-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-multi-comp.md) + */ +export interface NoMultiCompRule { + /** + * Disallow multiple component definition per file. + * + * @see [no-multi-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-multi-comp.md) + */ + 'react/no-multi-comp': NoMultiCompRuleConfig; +} diff --git a/src/rules/react/no-namespace.d.ts b/src/rules/react/no-namespace.d.ts new file mode 100644 index 00000000..94ef4841 --- /dev/null +++ b/src/rules/react/no-namespace.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce that namespaces are not used in React elements. + * + * @see [no-namespace](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-namespace.md) + */ +export type NoNamespaceRuleConfig = RuleConfig<[]>; + +/** + * Enforce that namespaces are not used in React elements. + * + * @see [no-namespace](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-namespace.md) + */ +export interface NoNamespaceRule { + /** + * Enforce that namespaces are not used in React elements. + * + * @see [no-namespace](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-namespace.md) + */ + 'react/no-namespace': NoNamespaceRuleConfig; +} diff --git a/src/rules/react/no-object-type-as-default-prop.d.ts b/src/rules/react/no-object-type-as-default-prop.d.ts new file mode 100644 index 00000000..12f8c8ad --- /dev/null +++ b/src/rules/react/no-object-type-as-default-prop.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of referential-type variables as default param in functional component. + * + * @see [no-object-type-as-default-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-object-type-as-default-prop.md) + */ +export type NoObjectTypeAsDefaultPropRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of referential-type variables as default param in functional component. + * + * @see [no-object-type-as-default-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-object-type-as-default-prop.md) + */ +export interface NoObjectTypeAsDefaultPropRule { + /** + * Disallow usage of referential-type variables as default param in functional component. + * + * @see [no-object-type-as-default-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-object-type-as-default-prop.md) + */ + 'react/no-object-type-as-default-prop': NoObjectTypeAsDefaultPropRuleConfig; +} diff --git a/src/rules/react/no-redundant-should-component-update.d.ts b/src/rules/react/no-redundant-should-component-update.d.ts new file mode 100644 index 00000000..b3b64f52 --- /dev/null +++ b/src/rules/react/no-redundant-should-component-update.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of shouldComponentUpdate when extending React.PureComponent. + * + * @see [no-redundant-should-component-update](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-redundant-should-component-update.md) + */ +export type NoRedundantShouldComponentUpdateRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of shouldComponentUpdate when extending React.PureComponent. + * + * @see [no-redundant-should-component-update](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-redundant-should-component-update.md) + */ +export interface NoRedundantShouldComponentUpdateRule { + /** + * Disallow usage of shouldComponentUpdate when extending React.PureComponent. + * + * @see [no-redundant-should-component-update](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-redundant-should-component-update.md) + */ + 'react/no-redundant-should-component-update': NoRedundantShouldComponentUpdateRuleConfig; +} diff --git a/src/rules/react/no-render-return-value.d.ts b/src/rules/react/no-render-return-value.d.ts new file mode 100644 index 00000000..b1668e2e --- /dev/null +++ b/src/rules/react/no-render-return-value.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of the return value of ReactDOM.render. + * + * @see [no-render-return-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-render-return-value.md) + */ +export type NoRenderReturnValueRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of the return value of ReactDOM.render. + * + * @see [no-render-return-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-render-return-value.md) + */ +export interface NoRenderReturnValueRule { + /** + * Disallow usage of the return value of ReactDOM.render. + * + * @see [no-render-return-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-render-return-value.md) + */ + 'react/no-render-return-value': NoRenderReturnValueRuleConfig; +} diff --git a/src/rules/react/no-set-state.d.ts b/src/rules/react/no-set-state.d.ts new file mode 100644 index 00000000..8a134e31 --- /dev/null +++ b/src/rules/react/no-set-state.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow usage of setState. + * + * @see [no-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-set-state.md) + */ +export type NoSetStateRuleConfig = RuleConfig<[]>; + +/** + * Disallow usage of setState. + * + * @see [no-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-set-state.md) + */ +export interface NoSetStateRule { + /** + * Disallow usage of setState. + * + * @see [no-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-set-state.md) + */ + 'react/no-set-state': NoSetStateRuleConfig; +} diff --git a/src/rules/react/no-string-refs.d.ts b/src/rules/react/no-string-refs.d.ts new file mode 100644 index 00000000..a14ca926 --- /dev/null +++ b/src/rules/react/no-string-refs.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoStringRefsOption { + noTemplateLiterals?: boolean; +} + +/** + * Options. + */ +export type NoStringRefsOptions = [NoStringRefsOption?]; + +/** + * Disallow using string references. + * + * @see [no-string-refs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-string-refs.md) + */ +export type NoStringRefsRuleConfig = RuleConfig; + +/** + * Disallow using string references. + * + * @see [no-string-refs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-string-refs.md) + */ +export interface NoStringRefsRule { + /** + * Disallow using string references. + * + * @see [no-string-refs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-string-refs.md) + */ + 'react/no-string-refs': NoStringRefsRuleConfig; +} diff --git a/src/rules/react/no-this-in-sfc.d.ts b/src/rules/react/no-this-in-sfc.d.ts new file mode 100644 index 00000000..7e4124d6 --- /dev/null +++ b/src/rules/react/no-this-in-sfc.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow `this` from being used in stateless functional components. + * + * @see [no-this-in-sfc](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-this-in-sfc.md) + */ +export type NoThisInSfcRuleConfig = RuleConfig<[]>; + +/** + * Disallow `this` from being used in stateless functional components. + * + * @see [no-this-in-sfc](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-this-in-sfc.md) + */ +export interface NoThisInSfcRule { + /** + * Disallow `this` from being used in stateless functional components. + * + * @see [no-this-in-sfc](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-this-in-sfc.md) + */ + 'react/no-this-in-sfc': NoThisInSfcRuleConfig; +} diff --git a/src/rules/react/no-typos.d.ts b/src/rules/react/no-typos.d.ts new file mode 100644 index 00000000..4fccda29 --- /dev/null +++ b/src/rules/react/no-typos.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow common typos. + * + * @see [no-typos](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-typos.md) + */ +export type NoTyposRuleConfig = RuleConfig<[]>; + +/** + * Disallow common typos. + * + * @see [no-typos](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-typos.md) + */ +export interface NoTyposRule { + /** + * Disallow common typos. + * + * @see [no-typos](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-typos.md) + */ + 'react/no-typos': NoTyposRuleConfig; +} diff --git a/src/rules/react/no-unescaped-entities.d.ts b/src/rules/react/no-unescaped-entities.d.ts new file mode 100644 index 00000000..d86a8e9d --- /dev/null +++ b/src/rules/react/no-unescaped-entities.d.ts @@ -0,0 +1,42 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnescapedEntitiesOption { + forbid?: ( + | string + | { + char?: string; + alternatives?: string[]; + [k: string]: any; + } + )[]; +} + +/** + * Options. + */ +export type NoUnescapedEntitiesOptions = [NoUnescapedEntitiesOption?]; + +/** + * Disallow unescaped HTML entities from appearing in markup. + * + * @see [no-unescaped-entities](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unescaped-entities.md) + */ +export type NoUnescapedEntitiesRuleConfig = + RuleConfig; + +/** + * Disallow unescaped HTML entities from appearing in markup. + * + * @see [no-unescaped-entities](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unescaped-entities.md) + */ +export interface NoUnescapedEntitiesRule { + /** + * Disallow unescaped HTML entities from appearing in markup. + * + * @see [no-unescaped-entities](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unescaped-entities.md) + */ + 'react/no-unescaped-entities': NoUnescapedEntitiesRuleConfig; +} diff --git a/src/rules/react/no-unknown-property.d.ts b/src/rules/react/no-unknown-property.d.ts new file mode 100644 index 00000000..21d5622d --- /dev/null +++ b/src/rules/react/no-unknown-property.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnknownPropertyOption { + ignore?: string[]; +} + +/** + * Options. + */ +export type NoUnknownPropertyOptions = [NoUnknownPropertyOption?]; + +/** + * Disallow usage of unknown DOM property. + * + * @see [no-unknown-property](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unknown-property.md) + */ +export type NoUnknownPropertyRuleConfig = RuleConfig; + +/** + * Disallow usage of unknown DOM property. + * + * @see [no-unknown-property](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unknown-property.md) + */ +export interface NoUnknownPropertyRule { + /** + * Disallow usage of unknown DOM property. + * + * @see [no-unknown-property](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unknown-property.md) + */ + 'react/no-unknown-property': NoUnknownPropertyRuleConfig; +} diff --git a/src/rules/react/no-unsafe.d.ts b/src/rules/react/no-unsafe.d.ts new file mode 100644 index 00000000..8afc896d --- /dev/null +++ b/src/rules/react/no-unsafe.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnsafeOption { + checkAliases?: boolean; +} + +/** + * Options. + */ +export type NoUnsafeOptions = [NoUnsafeOption?]; + +/** + * Disallow usage of unsafe lifecycle methods. + * + * @see [no-unsafe](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unsafe.md) + */ +export type NoUnsafeRuleConfig = RuleConfig; + +/** + * Disallow usage of unsafe lifecycle methods. + * + * @see [no-unsafe](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unsafe.md) + */ +export interface NoUnsafeRule { + /** + * Disallow usage of unsafe lifecycle methods. + * + * @see [no-unsafe](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unsafe.md) + */ + 'react/no-unsafe': NoUnsafeRuleConfig; +} diff --git a/src/rules/react/no-unstable-nested-components.d.ts b/src/rules/react/no-unstable-nested-components.d.ts new file mode 100644 index 00000000..ddef0ae4 --- /dev/null +++ b/src/rules/react/no-unstable-nested-components.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnstableNestedComponentsOption { + customValidators?: string[]; + allowAsProps?: boolean; +} + +/** + * Options. + */ +export type NoUnstableNestedComponentsOptions = [ + NoUnstableNestedComponentsOption?, +]; + +/** + * Disallow creating unstable components inside components. + * + * @see [no-unstable-nested-components](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unstable-nested-components.md) + */ +export type NoUnstableNestedComponentsRuleConfig = + RuleConfig; + +/** + * Disallow creating unstable components inside components. + * + * @see [no-unstable-nested-components](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unstable-nested-components.md) + */ +export interface NoUnstableNestedComponentsRule { + /** + * Disallow creating unstable components inside components. + * + * @see [no-unstable-nested-components](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unstable-nested-components.md) + */ + 'react/no-unstable-nested-components': NoUnstableNestedComponentsRuleConfig; +} diff --git a/src/rules/react/no-unused-class-component-methods.d.ts b/src/rules/react/no-unused-class-component-methods.d.ts new file mode 100644 index 00000000..e83bc72a --- /dev/null +++ b/src/rules/react/no-unused-class-component-methods.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow declaring unused methods of component class. + * + * @see [no-unused-class-component-methods](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-class-component-methods.md) + */ +export type NoUnusedClassComponentMethodsRuleConfig = RuleConfig<[]>; + +/** + * Disallow declaring unused methods of component class. + * + * @see [no-unused-class-component-methods](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-class-component-methods.md) + */ +export interface NoUnusedClassComponentMethodsRule { + /** + * Disallow declaring unused methods of component class. + * + * @see [no-unused-class-component-methods](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-class-component-methods.md) + */ + 'react/no-unused-class-component-methods': NoUnusedClassComponentMethodsRuleConfig; +} diff --git a/src/rules/react/no-unused-prop-types.d.ts b/src/rules/react/no-unused-prop-types.d.ts new file mode 100644 index 00000000..0485a03f --- /dev/null +++ b/src/rules/react/no-unused-prop-types.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUnusedPropTypesOption { + ignore?: string[]; + customValidators?: string[]; + skipShapeProps?: boolean; +} + +/** + * Options. + */ +export type NoUnusedPropTypesOptions = [NoUnusedPropTypesOption?]; + +/** + * Disallow definitions of unused propTypes. + * + * @see [no-unused-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-prop-types.md) + */ +export type NoUnusedPropTypesRuleConfig = RuleConfig; + +/** + * Disallow definitions of unused propTypes. + * + * @see [no-unused-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-prop-types.md) + */ +export interface NoUnusedPropTypesRule { + /** + * Disallow definitions of unused propTypes. + * + * @see [no-unused-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-prop-types.md) + */ + 'react/no-unused-prop-types': NoUnusedPropTypesRuleConfig; +} diff --git a/src/rules/react/no-unused-state.d.ts b/src/rules/react/no-unused-state.d.ts new file mode 100644 index 00000000..9143693e --- /dev/null +++ b/src/rules/react/no-unused-state.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow definitions of unused state. + * + * @see [no-unused-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-state.md) + */ +export type NoUnusedStateRuleConfig = RuleConfig<[]>; + +/** + * Disallow definitions of unused state. + * + * @see [no-unused-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-state.md) + */ +export interface NoUnusedStateRule { + /** + * Disallow definitions of unused state. + * + * @see [no-unused-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-state.md) + */ + 'react/no-unused-state': NoUnusedStateRuleConfig; +} diff --git a/src/rules/react/no-will-update-set-state.d.ts b/src/rules/react/no-will-update-set-state.d.ts new file mode 100644 index 00000000..260c3a61 --- /dev/null +++ b/src/rules/react/no-will-update-set-state.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoWillUpdateSetStateOption = 'disallow-in-func'; + +/** + * Options. + */ +export type NoWillUpdateSetStateOptions = [NoWillUpdateSetStateOption?]; + +/** + * Disallow usage of setState in componentWillUpdate. + * + * @see [no-will-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-will-update-set-state.md) + */ +export type NoWillUpdateSetStateRuleConfig = + RuleConfig; + +/** + * Disallow usage of setState in componentWillUpdate. + * + * @see [no-will-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-will-update-set-state.md) + */ +export interface NoWillUpdateSetStateRule { + /** + * Disallow usage of setState in componentWillUpdate. + * + * @see [no-will-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-will-update-set-state.md) + */ + 'react/no-will-update-set-state': NoWillUpdateSetStateRuleConfig; +} diff --git a/src/rules/react/prefer-es6-class.d.ts b/src/rules/react/prefer-es6-class.d.ts new file mode 100644 index 00000000..ac1d163d --- /dev/null +++ b/src/rules/react/prefer-es6-class.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type PreferEs6ClassOption = 'always' | 'never'; + +/** + * Options. + */ +export type PreferEs6ClassOptions = [PreferEs6ClassOption?]; + +/** + * Enforce ES5 or ES6 class for React Components. + * + * @see [prefer-es6-class](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-es6-class.md) + */ +export type PreferEs6ClassRuleConfig = RuleConfig; + +/** + * Enforce ES5 or ES6 class for React Components. + * + * @see [prefer-es6-class](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-es6-class.md) + */ +export interface PreferEs6ClassRule { + /** + * Enforce ES5 or ES6 class for React Components. + * + * @see [prefer-es6-class](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-es6-class.md) + */ + 'react/prefer-es6-class': PreferEs6ClassRuleConfig; +} diff --git a/src/rules/react/prefer-exact-props.d.ts b/src/rules/react/prefer-exact-props.d.ts new file mode 100644 index 00000000..309e5c39 --- /dev/null +++ b/src/rules/react/prefer-exact-props.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer exact proptype definitions. + * + * @see [prefer-exact-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-exact-props.md) + */ +export type PreferExactPropsRuleConfig = RuleConfig<[]>; + +/** + * Prefer exact proptype definitions. + * + * @see [prefer-exact-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-exact-props.md) + */ +export interface PreferExactPropsRule { + /** + * Prefer exact proptype definitions. + * + * @see [prefer-exact-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-exact-props.md) + */ + 'react/prefer-exact-props': PreferExactPropsRuleConfig; +} diff --git a/src/rules/react/prefer-read-only-props.d.ts b/src/rules/react/prefer-read-only-props.d.ts new file mode 100644 index 00000000..03b6169e --- /dev/null +++ b/src/rules/react/prefer-read-only-props.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce that props are read-only. + * + * @see [prefer-read-only-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-read-only-props.md) + */ +export type PreferReadOnlyPropsRuleConfig = RuleConfig<[]>; + +/** + * Enforce that props are read-only. + * + * @see [prefer-read-only-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-read-only-props.md) + */ +export interface PreferReadOnlyPropsRule { + /** + * Enforce that props are read-only. + * + * @see [prefer-read-only-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-read-only-props.md) + */ + 'react/prefer-read-only-props': PreferReadOnlyPropsRuleConfig; +} diff --git a/src/rules/react/prefer-stateless-function.d.ts b/src/rules/react/prefer-stateless-function.d.ts new file mode 100644 index 00000000..40f54f2c --- /dev/null +++ b/src/rules/react/prefer-stateless-function.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferStatelessFunctionOption { + ignorePureComponents?: boolean; +} + +/** + * Options. + */ +export type PreferStatelessFunctionOptions = [PreferStatelessFunctionOption?]; + +/** + * Enforce stateless components to be written as a pure function. + * + * @see [prefer-stateless-function](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-stateless-function.md) + */ +export type PreferStatelessFunctionRuleConfig = + RuleConfig; + +/** + * Enforce stateless components to be written as a pure function. + * + * @see [prefer-stateless-function](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-stateless-function.md) + */ +export interface PreferStatelessFunctionRule { + /** + * Enforce stateless components to be written as a pure function. + * + * @see [prefer-stateless-function](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-stateless-function.md) + */ + 'react/prefer-stateless-function': PreferStatelessFunctionRuleConfig; +} diff --git a/src/rules/react/prop-types.d.ts b/src/rules/react/prop-types.d.ts new file mode 100644 index 00000000..75bcb1b5 --- /dev/null +++ b/src/rules/react/prop-types.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PropTypesOption { + ignore?: string[]; + customValidators?: string[]; + skipUndeclared?: boolean; +} + +/** + * Options. + */ +export type PropTypesOptions = [PropTypesOption?]; + +/** + * Disallow missing props validation in a React component definition. + * + * @see [prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prop-types.md) + */ +export type PropTypesRuleConfig = RuleConfig; + +/** + * Disallow missing props validation in a React component definition. + * + * @see [prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prop-types.md) + */ +export interface PropTypesRule { + /** + * Disallow missing props validation in a React component definition. + * + * @see [prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prop-types.md) + */ + 'react/prop-types': PropTypesRuleConfig; +} diff --git a/src/rules/react/react-in-jsx-scope.d.ts b/src/rules/react/react-in-jsx-scope.d.ts new file mode 100644 index 00000000..99b9663c --- /dev/null +++ b/src/rules/react/react-in-jsx-scope.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow missing React when using JSX. + * + * @see [react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/react-in-jsx-scope.md) + */ +export type ReactInJsxScopeRuleConfig = RuleConfig<[]>; + +/** + * Disallow missing React when using JSX. + * + * @see [react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/react-in-jsx-scope.md) + */ +export interface ReactInJsxScopeRule { + /** + * Disallow missing React when using JSX. + * + * @see [react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/react-in-jsx-scope.md) + */ + 'react/react-in-jsx-scope': ReactInJsxScopeRuleConfig; +} diff --git a/src/rules/react/require-default-props.d.ts b/src/rules/react/require-default-props.d.ts new file mode 100644 index 00000000..513eadc5 --- /dev/null +++ b/src/rules/react/require-default-props.d.ts @@ -0,0 +1,42 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface RequireDefaultPropsOption { + forbidDefaultForRequired?: boolean; + classes?: { + [k: string]: any; + }; + functions?: { + [k: string]: any; + }; + ignoreFunctionalComponents?: boolean; +} + +/** + * Options. + */ +export type RequireDefaultPropsOptions = [RequireDefaultPropsOption?]; + +/** + * Enforce a defaultProps definition for every prop that is not a required prop. + * + * @see [require-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-default-props.md) + */ +export type RequireDefaultPropsRuleConfig = + RuleConfig; + +/** + * Enforce a defaultProps definition for every prop that is not a required prop. + * + * @see [require-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-default-props.md) + */ +export interface RequireDefaultPropsRule { + /** + * Enforce a defaultProps definition for every prop that is not a required prop. + * + * @see [require-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-default-props.md) + */ + 'react/require-default-props': RequireDefaultPropsRuleConfig; +} diff --git a/src/rules/react/require-optimization.d.ts b/src/rules/react/require-optimization.d.ts new file mode 100644 index 00000000..18dbc0e5 --- /dev/null +++ b/src/rules/react/require-optimization.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface RequireOptimizationOption { + allowDecorators?: string[]; +} + +/** + * Options. + */ +export type RequireOptimizationOptions = [RequireOptimizationOption?]; + +/** + * Enforce React components to have a shouldComponentUpdate method. + * + * @see [require-optimization](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-optimization.md) + */ +export type RequireOptimizationRuleConfig = + RuleConfig; + +/** + * Enforce React components to have a shouldComponentUpdate method. + * + * @see [require-optimization](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-optimization.md) + */ +export interface RequireOptimizationRule { + /** + * Enforce React components to have a shouldComponentUpdate method. + * + * @see [require-optimization](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-optimization.md) + */ + 'react/require-optimization': RequireOptimizationRuleConfig; +} diff --git a/src/rules/react/require-render-return.d.ts b/src/rules/react/require-render-return.d.ts new file mode 100644 index 00000000..58f4f54b --- /dev/null +++ b/src/rules/react/require-render-return.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce ES5 or ES6 class for returning value in render function. + * + * @see [require-render-return](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-render-return.md) + */ +export type RequireRenderReturnRuleConfig = RuleConfig<[]>; + +/** + * Enforce ES5 or ES6 class for returning value in render function. + * + * @see [require-render-return](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-render-return.md) + */ +export interface RequireRenderReturnRule { + /** + * Enforce ES5 or ES6 class for returning value in render function. + * + * @see [require-render-return](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-render-return.md) + */ + 'react/require-render-return': RequireRenderReturnRuleConfig; +} diff --git a/src/rules/react/self-closing-comp.d.ts b/src/rules/react/self-closing-comp.d.ts new file mode 100644 index 00000000..163eda58 --- /dev/null +++ b/src/rules/react/self-closing-comp.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SelfClosingCompOption { + component?: boolean; + html?: boolean; +} + +/** + * Options. + */ +export type SelfClosingCompOptions = [SelfClosingCompOption?]; + +/** + * Disallow extra closing tags for components without children. + * + * @see [self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md) + */ +export type SelfClosingCompRuleConfig = RuleConfig; + +/** + * Disallow extra closing tags for components without children. + * + * @see [self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md) + */ +export interface SelfClosingCompRule { + /** + * Disallow extra closing tags for components without children. + * + * @see [self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md) + */ + 'react/self-closing-comp': SelfClosingCompRuleConfig; +} diff --git a/src/rules/react/sort-comp.d.ts b/src/rules/react/sort-comp.d.ts new file mode 100644 index 00000000..86a4130e --- /dev/null +++ b/src/rules/react/sort-comp.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortCompOption { + order?: string[]; + groups?: { + /** + */ + [k: string]: string[]; + }; +} + +/** + * Options. + */ +export type SortCompOptions = [SortCompOption?]; + +/** + * Enforce component methods order. + * + * @see [sort-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-comp.md) + */ +export type SortCompRuleConfig = RuleConfig; + +/** + * Enforce component methods order. + * + * @see [sort-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-comp.md) + */ +export interface SortCompRule { + /** + * Enforce component methods order. + * + * @see [sort-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-comp.md) + */ + 'react/sort-comp': SortCompRuleConfig; +} diff --git a/src/rules/react/sort-default-props.d.ts b/src/rules/react/sort-default-props.d.ts new file mode 100644 index 00000000..bc4f372b --- /dev/null +++ b/src/rules/react/sort-default-props.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortDefaultPropsOption { + ignoreCase?: boolean; +} + +/** + * Options. + */ +export type SortDefaultPropsOptions = [SortDefaultPropsOption?]; + +/** + * Enforce defaultProps declarations alphabetical sorting. + * + * @see [sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-default-props.md) + */ +export type SortDefaultPropsRuleConfig = RuleConfig; + +/** + * Enforce defaultProps declarations alphabetical sorting. + * + * @see [sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-default-props.md) + */ +export interface SortDefaultPropsRule { + /** + * Enforce defaultProps declarations alphabetical sorting. + * + * @see [sort-default-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-default-props.md) + */ + 'react/sort-default-props': SortDefaultPropsRuleConfig; +} diff --git a/src/rules/react/sort-prop-types.d.ts b/src/rules/react/sort-prop-types.d.ts new file mode 100644 index 00000000..ee6eed0f --- /dev/null +++ b/src/rules/react/sort-prop-types.d.ts @@ -0,0 +1,38 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortPropTypesOption { + requiredFirst?: boolean; + callbacksLast?: boolean; + ignoreCase?: boolean; + noSortAlphabetically?: boolean; + sortShapeProp?: boolean; +} + +/** + * Options. + */ +export type SortPropTypesOptions = [SortPropTypesOption?]; + +/** + * Enforce propTypes declarations alphabetical sorting. + * + * @see [sort-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-prop-types.md) + */ +export type SortPropTypesRuleConfig = RuleConfig; + +/** + * Enforce propTypes declarations alphabetical sorting. + * + * @see [sort-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-prop-types.md) + */ +export interface SortPropTypesRule { + /** + * Enforce propTypes declarations alphabetical sorting. + * + * @see [sort-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-prop-types.md) + */ + 'react/sort-prop-types': SortPropTypesRuleConfig; +} diff --git a/src/rules/react/state-in-constructor.d.ts b/src/rules/react/state-in-constructor.d.ts new file mode 100644 index 00000000..ea07aba9 --- /dev/null +++ b/src/rules/react/state-in-constructor.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type StateInConstructorOption = 'always' | 'never'; + +/** + * Options. + */ +export type StateInConstructorOptions = [StateInConstructorOption?]; + +/** + * Enforce class component state initialization style. + * + * @see [state-in-constructor](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/state-in-constructor.md) + */ +export type StateInConstructorRuleConfig = + RuleConfig; + +/** + * Enforce class component state initialization style. + * + * @see [state-in-constructor](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/state-in-constructor.md) + */ +export interface StateInConstructorRule { + /** + * Enforce class component state initialization style. + * + * @see [state-in-constructor](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/state-in-constructor.md) + */ + 'react/state-in-constructor': StateInConstructorRuleConfig; +} diff --git a/src/rules/react/static-property-placement.d.ts b/src/rules/react/static-property-placement.d.ts new file mode 100644 index 00000000..d4f7b365 --- /dev/null +++ b/src/rules/react/static-property-placement.d.ts @@ -0,0 +1,60 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface StaticPropertyPlacementConfig { + propTypes?: 'static public field' | 'static getter' | 'property assignment'; + defaultProps?: + | 'static public field' + | 'static getter' + | 'property assignment'; + childContextTypes?: + | 'static public field' + | 'static getter' + | 'property assignment'; + contextTypes?: + | 'static public field' + | 'static getter' + | 'property assignment'; + contextType?: 'static public field' | 'static getter' | 'property assignment'; + displayName?: 'static public field' | 'static getter' | 'property assignment'; +} + +/** + * Option. + */ +export type StaticPropertyPlacementOption = + | 'static public field' + | 'static getter' + | 'property assignment'; + +/** + * Options. + */ +export type StaticPropertyPlacementOptions = [ + StaticPropertyPlacementOption?, + StaticPropertyPlacementConfig?, +]; + +/** + * Enforces where React component static properties should be positioned. + * + * @see [static-property-placement](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/static-property-placement.md) + */ +export type StaticPropertyPlacementRuleConfig = + RuleConfig; + +/** + * Enforces where React component static properties should be positioned. + * + * @see [static-property-placement](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/static-property-placement.md) + */ +export interface StaticPropertyPlacementRule { + /** + * Enforces where React component static properties should be positioned. + * + * @see [static-property-placement](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/static-property-placement.md) + */ + 'react/static-property-placement': StaticPropertyPlacementRuleConfig; +} diff --git a/src/rules/react/style-prop-object.d.ts b/src/rules/react/style-prop-object.d.ts new file mode 100644 index 00000000..c6c4186d --- /dev/null +++ b/src/rules/react/style-prop-object.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface StylePropObjectOption { + allow?: string[]; + [k: string]: any; +} + +/** + * Options. + */ +export type StylePropObjectOptions = [StylePropObjectOption?]; + +/** + * Enforce style prop value is an object. + * + * @see [style-prop-object](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/style-prop-object.md) + */ +export type StylePropObjectRuleConfig = RuleConfig; + +/** + * Enforce style prop value is an object. + * + * @see [style-prop-object](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/style-prop-object.md) + */ +export interface StylePropObjectRule { + /** + * Enforce style prop value is an object. + * + * @see [style-prop-object](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/style-prop-object.md) + */ + 'react/style-prop-object': StylePropObjectRuleConfig; +} diff --git a/src/rules/react/void-dom-elements-no-children.d.ts b/src/rules/react/void-dom-elements-no-children.d.ts new file mode 100644 index 00000000..9fc60544 --- /dev/null +++ b/src/rules/react/void-dom-elements-no-children.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow void DOM elements (e.g. ``, `
`) from receiving children. + * + * @see [void-dom-elements-no-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/void-dom-elements-no-children.md) + */ +export type VoidDomElementsNoChildrenRuleConfig = RuleConfig<[]>; + +/** + * Disallow void DOM elements (e.g. ``, `
`) from receiving children. + * + * @see [void-dom-elements-no-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/void-dom-elements-no-children.md) + */ +export interface VoidDomElementsNoChildrenRule { + /** + * Disallow void DOM elements (e.g. ``, `
`) from receiving children. + * + * @see [void-dom-elements-no-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/void-dom-elements-no-children.md) + */ + 'react/void-dom-elements-no-children': VoidDomElementsNoChildrenRuleConfig; +}