@eslint-react/kit 4.2.0-beta.3 → 4.2.1-rc.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 +6 -61
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ ESLint React's toolkit for building custom React rules with JavasSript functions
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
|
-
npm install --save-dev @eslint-react/kit@
|
|
33
|
+
npm install --save-dev @eslint-react/kit@rc
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Quick Start
|
|
@@ -552,47 +552,15 @@ eslintReactKit()
|
|
|
552
552
|
import eslintReactKit from "@eslint-react/kit";
|
|
553
553
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
554
554
|
|
|
555
|
-
function functionComponentDefinition(): RuleDefinition {
|
|
556
|
-
return (context, { collect }) => {
|
|
557
|
-
const { query, visitor } = collect.components(context);
|
|
558
|
-
return {
|
|
559
|
-
...visitor,
|
|
560
|
-
"Program:exit"(program) {
|
|
561
|
-
for (const { name, node } of query.all(program)) {
|
|
562
|
-
if (node.type !== "FunctionDeclaration") {
|
|
563
|
-
context.report({
|
|
564
|
-
node,
|
|
565
|
-
message: `Component "${name ?? "(anonymous)"}" must be a function declaration.`,
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
},
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function version(major = "19"): RuleDefinition {
|
|
575
|
-
return (context, { settings }) => ({
|
|
576
|
-
Program(program) {
|
|
577
|
-
if (!settings.version.startsWith(`${major}.`)) {
|
|
578
|
-
context.report({
|
|
579
|
-
node: program,
|
|
580
|
-
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
|
|
587
555
|
// Spread the config into a new object to add or override properties like `files`:
|
|
588
556
|
export default [
|
|
589
557
|
{
|
|
590
558
|
...eslintReactKit()
|
|
591
|
-
.use(
|
|
559
|
+
.use(noForwardRef);
|
|
592
560
|
.use(version, "19")
|
|
593
561
|
.getConfig(),
|
|
594
562
|
// Override `name` so it shows your own label in config inspector tools
|
|
595
|
-
name: "
|
|
563
|
+
name: "react-custom-rules",
|
|
596
564
|
// Override `files` to scope the kit rules to specific source files
|
|
597
565
|
files: ["src/**/*.ts", "src/**/*.tsx"],
|
|
598
566
|
},
|
|
@@ -609,29 +577,6 @@ Use `getPlugin()` when you want full control over the plugin namespace and rule
|
|
|
609
577
|
import eslintReactKit from "@eslint-react/kit";
|
|
610
578
|
import type { RuleDefinition } from "@eslint-react/kit";
|
|
611
579
|
|
|
612
|
-
function version(major = "19"): RuleDefinition {
|
|
613
|
-
return (context, { settings }) => ({
|
|
614
|
-
Program(program) {
|
|
615
|
-
if (!settings.version.startsWith(`${major}.`)) {
|
|
616
|
-
context.report({
|
|
617
|
-
node: program,
|
|
618
|
-
message: `This project requires React ${major}, but detected version ${settings.version}.`,
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
},
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function noForwardRef(): RuleDefinition {
|
|
626
|
-
return (context, { is }) => ({
|
|
627
|
-
CallExpression(node) {
|
|
628
|
-
if (is.forwardRefCall(node)) {
|
|
629
|
-
context.report({ node, message: "forwardRef is deprecated in React 19." });
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
|
|
635
580
|
const kit = eslintReactKit()
|
|
636
581
|
.use(noForwardRef);
|
|
637
582
|
.use(version, "19")
|
|
@@ -644,12 +589,12 @@ export default [
|
|
|
644
589
|
files: ["**/*.{ts,tsx}"],
|
|
645
590
|
plugins: {
|
|
646
591
|
// Choose your own namespace
|
|
647
|
-
react: plugin,
|
|
592
|
+
"react-custom-rules": plugin,
|
|
648
593
|
},
|
|
649
594
|
rules: {
|
|
650
595
|
// Set individual severities
|
|
651
|
-
"react/no-forward-ref": "error",
|
|
652
|
-
"react/version": "error",
|
|
596
|
+
"react-custom-rules/no-forward-ref": "error",
|
|
597
|
+
"react-custom-rules/version": "error",
|
|
653
598
|
},
|
|
654
599
|
},
|
|
655
600
|
];
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/kit",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1-rc.1",
|
|
4
4
|
"description": "ESLint React's utility module for building custom React rules with JavasSript functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@typescript-eslint/utils": "^8.58.0",
|
|
40
40
|
"string-ts": "^2.3.1",
|
|
41
|
-
"@eslint-react/ast": "4.2.
|
|
42
|
-
"@eslint-react/core": "4.2.
|
|
43
|
-
"@eslint-react/shared": "4.2.
|
|
41
|
+
"@eslint-react/ast": "4.2.1-rc.1",
|
|
42
|
+
"@eslint-react/core": "4.2.1-rc.1",
|
|
43
|
+
"@eslint-react/shared": "4.2.1-rc.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"eslint": "^10.1.0",
|