@eslint-react/kit 4.0.2-beta.0 → 4.0.2-beta.2
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 +52 -31
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @eslint-react/kit
|
|
2
2
|
|
|
3
|
-
ESLint React's toolkit for building custom React
|
|
3
|
+
ESLint React's toolkit for building custom React rules with JavasSript functions right inside your `eslint.config.ts`.
|
|
4
4
|
|
|
5
5
|
## Index
|
|
6
6
|
|
|
@@ -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
|
];
|
|
@@ -259,11 +258,33 @@ Factory functions (context pre-bound):
|
|
|
259
258
|
|
|
260
259
|
Pre-built identifier predicates (context pre-bound):
|
|
261
260
|
|
|
262
|
-
`captureOwnerStack
|
|
261
|
+
- `captureOwnerStack`
|
|
262
|
+
- `childrenCount`
|
|
263
|
+
- `childrenForEach`
|
|
264
|
+
- `childrenMap`
|
|
265
|
+
- `childrenOnly`
|
|
266
|
+
- `childrenToArray`
|
|
267
|
+
- `cloneElement`
|
|
268
|
+
- `createContext`
|
|
269
|
+
- `createElement`
|
|
270
|
+
- `forwardRef`
|
|
271
|
+
- `memo`
|
|
272
|
+
- `lazy`
|
|
263
273
|
|
|
264
274
|
Pre-built call predicates (context pre-bound):
|
|
265
275
|
|
|
266
|
-
`captureOwnerStackCall
|
|
276
|
+
- `captureOwnerStackCall`
|
|
277
|
+
- `childrenCountCall`
|
|
278
|
+
- `childrenForEachCall`
|
|
279
|
+
- `childrenMapCall`
|
|
280
|
+
- `childrenOnlyCall`
|
|
281
|
+
- `childrenToArrayCall`
|
|
282
|
+
- `cloneElementCall`
|
|
283
|
+
- `createContextCall`
|
|
284
|
+
- `createElementCall`
|
|
285
|
+
- `forwardRefCall`
|
|
286
|
+
- `memoCall`
|
|
287
|
+
- `lazyCall`
|
|
267
288
|
|
|
268
289
|
All React API predicates and factories have `context` pre-bound — no need to pass the rule context manually:
|
|
269
290
|
|
|
@@ -356,13 +377,13 @@ Exposes the normalized `react-x` settings from the ESLint shared configuration (
|
|
|
356
377
|
```ts
|
|
357
378
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
358
379
|
|
|
359
|
-
function
|
|
380
|
+
function version(major = "19"): RuleDefinition {
|
|
360
381
|
return (context, { settings }) => ({
|
|
361
382
|
Program(program) {
|
|
362
|
-
if (!settings.version.startsWith(
|
|
383
|
+
if (!settings.version.startsWith(`${major}.`)) {
|
|
363
384
|
context.report({
|
|
364
385
|
node: program,
|
|
365
|
-
message: `This project requires React
|
|
386
|
+
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
366
387
|
});
|
|
367
388
|
}
|
|
368
389
|
},
|
|
@@ -531,32 +552,32 @@ Use `getPlugin()` when you want full control over the plugin namespace and rule
|
|
|
531
552
|
import eslintReactKit from "@eslint-react/kit";
|
|
532
553
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
533
554
|
|
|
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 {
|
|
555
|
+
function version(major = "19"): RuleDefinition {
|
|
545
556
|
return (context, { settings }) => ({
|
|
546
557
|
Program(program) {
|
|
547
|
-
if (!settings.version.startsWith(
|
|
558
|
+
if (!settings.version.startsWith(`${major}.`)) {
|
|
548
559
|
context.report({
|
|
549
560
|
node: program,
|
|
550
|
-
message: `This project requires React
|
|
561
|
+
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
551
562
|
});
|
|
552
563
|
}
|
|
553
564
|
},
|
|
554
565
|
});
|
|
555
566
|
}
|
|
556
567
|
|
|
568
|
+
function noForwardRef(): RuleDefinition {
|
|
569
|
+
return (context, { is }) => ({
|
|
570
|
+
CallExpression(node) {
|
|
571
|
+
if (is.forwardRefCall(node)) {
|
|
572
|
+
context.report({ node, message: "forwardRef is deprecated in React 19." });
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
557
578
|
const kit = eslintReactKit()
|
|
558
|
-
.use(noForwardRef)
|
|
559
|
-
.use(
|
|
579
|
+
.use(noForwardRef);
|
|
580
|
+
.use(version, "19")
|
|
560
581
|
|
|
561
582
|
// Instead of kit.getConfig(), use kit.getPlugin() for full control:
|
|
562
583
|
const plugin = kit.getPlugin();
|
|
@@ -566,12 +587,12 @@ export default [
|
|
|
566
587
|
files: ["**/*.{ts,tsx}"],
|
|
567
588
|
plugins: {
|
|
568
589
|
// Choose your own namespace
|
|
569
|
-
|
|
590
|
+
react: plugin,
|
|
570
591
|
},
|
|
571
592
|
rules: {
|
|
572
593
|
// Set individual severities
|
|
573
|
-
"react
|
|
574
|
-
"react
|
|
594
|
+
"react/no-forward-ref": "error",
|
|
595
|
+
"react/version": "error",
|
|
575
596
|
},
|
|
576
597
|
},
|
|
577
598
|
];
|
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.2";
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/kit",
|
|
3
|
-
"version": "4.0.2-beta.
|
|
4
|
-
"description": "ESLint React's utility module for building custom rules.",
|
|
3
|
+
"version": "4.0.2-beta.2",
|
|
4
|
+
"description": "ESLint React's utility module for building custom React rules with JavasSript functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"eslint",
|
|
@@ -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/core": "4.0.2-beta.
|
|
43
|
-
"@eslint-react/shared": "4.0.2-beta.
|
|
41
|
+
"@eslint-react/ast": "4.0.2-beta.2",
|
|
42
|
+
"@eslint-react/core": "4.0.2-beta.2",
|
|
43
|
+
"@eslint-react/shared": "4.0.2-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"eslint": "^10.1.0",
|