@eslint-react/kit 4.0.2-beta.0 → 4.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -28
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ Returns a flat `Linter.Config` object with all registered rules set to `"error"`
|
|
|
143
143
|
```ts
|
|
144
144
|
eslintReactKit()
|
|
145
145
|
.use(noForwardRef) // no-arg factory
|
|
146
|
-
.use(
|
|
146
|
+
.use(version, "19") // factory with inferred options
|
|
147
147
|
.getConfig();
|
|
148
148
|
```
|
|
149
149
|
|
|
@@ -153,23 +153,22 @@ Returns an `ESLint.Plugin` object containing the registered rules and plugin met
|
|
|
153
153
|
|
|
154
154
|
```ts
|
|
155
155
|
const kit = eslintReactKit()
|
|
156
|
-
.use(noForwardRef)
|
|
157
|
-
.use(
|
|
156
|
+
.use(noForwardRef);
|
|
157
|
+
.use(version, "19")
|
|
158
158
|
|
|
159
159
|
// Retrieve the raw plugin object
|
|
160
160
|
const plugin = kit.getPlugin();
|
|
161
|
-
// => { meta: { name: "@eslint-react/kit", version: "..." }, rules: { "no-forward-ref": ..., "forbid-elements": ... } }
|
|
162
161
|
|
|
163
162
|
// Use it in a custom flat config with your own namespace and severity
|
|
164
163
|
export default [
|
|
165
164
|
{
|
|
166
165
|
files: ["**/*.{ts,tsx}"],
|
|
167
166
|
plugins: {
|
|
168
|
-
|
|
167
|
+
react: plugin,
|
|
169
168
|
},
|
|
170
169
|
rules: {
|
|
171
|
-
"react
|
|
172
|
-
"react-
|
|
170
|
+
"react/version": "error",
|
|
171
|
+
"react/no-forward-ref": "error",
|
|
173
172
|
},
|
|
174
173
|
},
|
|
175
174
|
];
|
|
@@ -356,13 +355,13 @@ Exposes the normalized `react-x` settings from the ESLint shared configuration (
|
|
|
356
355
|
```ts
|
|
357
356
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
358
357
|
|
|
359
|
-
function
|
|
358
|
+
function version(major = "19"): RuleDefinition {
|
|
360
359
|
return (context, { settings }) => ({
|
|
361
360
|
Program(program) {
|
|
362
|
-
if (!settings.version.startsWith(
|
|
361
|
+
if (!settings.version.startsWith(`${major}.`)) {
|
|
363
362
|
context.report({
|
|
364
363
|
node: program,
|
|
365
|
-
message: `This project requires React
|
|
364
|
+
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
366
365
|
});
|
|
367
366
|
}
|
|
368
367
|
},
|
|
@@ -531,32 +530,32 @@ Use `getPlugin()` when you want full control over the plugin namespace and rule
|
|
|
531
530
|
import eslintReactKit from "@eslint-react/kit";
|
|
532
531
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
533
532
|
|
|
534
|
-
function
|
|
535
|
-
return (context, { is }) => ({
|
|
536
|
-
CallExpression(node) {
|
|
537
|
-
if (is.forwardRefCall(node)) {
|
|
538
|
-
context.report({ node, message: "forwardRef is deprecated in React 19." });
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
function requireReact19(): RuleDefinition {
|
|
533
|
+
function version(major = "19"): RuleDefinition {
|
|
545
534
|
return (context, { settings }) => ({
|
|
546
535
|
Program(program) {
|
|
547
|
-
if (!settings.version.startsWith(
|
|
536
|
+
if (!settings.version.startsWith(`${major}.`)) {
|
|
548
537
|
context.report({
|
|
549
538
|
node: program,
|
|
550
|
-
message: `This project requires React
|
|
539
|
+
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
551
540
|
});
|
|
552
541
|
}
|
|
553
542
|
},
|
|
554
543
|
});
|
|
555
544
|
}
|
|
556
545
|
|
|
546
|
+
function noForwardRef(): RuleDefinition {
|
|
547
|
+
return (context, { is }) => ({
|
|
548
|
+
CallExpression(node) {
|
|
549
|
+
if (is.forwardRefCall(node)) {
|
|
550
|
+
context.report({ node, message: "forwardRef is deprecated in React 19." });
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
|
|
557
556
|
const kit = eslintReactKit()
|
|
558
|
-
.use(noForwardRef)
|
|
559
|
-
.use(
|
|
557
|
+
.use(noForwardRef);
|
|
558
|
+
.use(version, "19")
|
|
560
559
|
|
|
561
560
|
// Instead of kit.getConfig(), use kit.getPlugin() for full control:
|
|
562
561
|
const plugin = kit.getPlugin();
|
|
@@ -566,12 +565,12 @@ export default [
|
|
|
566
565
|
files: ["**/*.{ts,tsx}"],
|
|
567
566
|
plugins: {
|
|
568
567
|
// Choose your own namespace
|
|
569
|
-
|
|
568
|
+
react: plugin,
|
|
570
569
|
},
|
|
571
570
|
rules: {
|
|
572
571
|
// Set individual severities
|
|
573
|
-
"react
|
|
574
|
-
"react
|
|
572
|
+
"react/version": "error",
|
|
573
|
+
"react/no-forward-ref": "error",
|
|
575
574
|
},
|
|
576
575
|
},
|
|
577
576
|
];
|
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ interface Builder {
|
|
|
107
107
|
getPlugin(): ESLint.Plugin;
|
|
108
108
|
use<F extends (...args: any[]) => RuleDefinition>(factory: F, ...args: Parameters<F>): Builder;
|
|
109
109
|
}
|
|
110
|
-
declare function
|
|
110
|
+
declare function build(): Builder;
|
|
111
111
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
112
112
|
interface RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> {
|
|
113
113
|
report(descriptor: {
|
|
@@ -125,4 +125,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
//#endregion
|
|
128
|
-
export { Builder, Collector, CollectorWithContext, RuleDefinition, type RuleFix, type RuleFixer, type RuleListener,
|
|
128
|
+
export { Builder, Collector, CollectorWithContext, RuleDefinition, type RuleFix, type RuleFixer, type RuleListener, build as default, merge };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { kebabCase } from "string-ts";
|
|
|
4
4
|
|
|
5
5
|
//#region package.json
|
|
6
6
|
var name = "@eslint-react/kit";
|
|
7
|
-
var version = "4.0.2-beta.
|
|
7
|
+
var version = "4.0.2-beta.1";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/index.ts
|
|
@@ -102,7 +102,7 @@ function makeRuleToolkit(context) {
|
|
|
102
102
|
settings: getSettingsFromContext(context)
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function build() {
|
|
106
106
|
const idGen = new IdGenerator();
|
|
107
107
|
const rules = {};
|
|
108
108
|
const builder = {
|
|
@@ -141,4 +141,4 @@ function eslintReactKit() {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
//#endregion
|
|
144
|
-
export {
|
|
144
|
+
export { build as default, merge };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/kit",
|
|
3
|
-
"version": "4.0.2-beta.
|
|
3
|
+
"version": "4.0.2-beta.1",
|
|
4
4
|
"description": "ESLint React's utility module for building custom rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@typescript-eslint/utils": "^8.57.2",
|
|
40
40
|
"string-ts": "^2.3.1",
|
|
41
|
-
"@eslint-react/ast": "4.0.2-beta.
|
|
42
|
-
"@eslint-react/
|
|
43
|
-
"@eslint-react/
|
|
41
|
+
"@eslint-react/ast": "4.0.2-beta.1",
|
|
42
|
+
"@eslint-react/shared": "4.0.2-beta.1",
|
|
43
|
+
"@eslint-react/core": "4.0.2-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"eslint": "^10.1.0",
|