@pob/eslint-plugin 65.4.1 → 65.6.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [65.6.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v65.5.1...v65.6.0) (2026-06-28)
7
+
8
+ ### Features
9
+
10
+ * **deps:** update typescript-eslint monorepo to v8.62.0
11
+
12
+ ## [65.5.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v65.4.3...v65.5.0) (2026-06-12)
13
+
14
+ ### Features
15
+
16
+ * add namespace error
17
+ * add test case for namespace import in react-named-import rule
18
+
6
19
  ## [65.4.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v65.4.0...v65.4.1) (2026-05-01)
7
20
 
8
21
  Note: no notable changes
@@ -17,21 +17,55 @@ export default {
17
17
  },
18
18
 
19
19
  create(context) {
20
- const checkNode = (node, messageId) => {
20
+ const sourceCode = context.sourceCode;
21
+
22
+ const checkImportSpecifier = (node, messageId) => {
21
23
  const importDeclaration = node.parent;
22
- const importSource = importDeclaration.source.value.trim();
24
+ const importSource =
25
+ importDeclaration &&
26
+ importDeclaration.source &&
27
+ importDeclaration.source.value &&
28
+ String(importDeclaration.source.value).trim();
23
29
  if (importSource !== "react") return;
24
- context.report({
25
- node,
26
- messageId,
27
- });
30
+ context.report({ node, messageId });
31
+ };
32
+
33
+ const isReactDeclaredInScope = (node) => {
34
+ const scope = sourceCode.getScope ? sourceCode.getScope(node) : null;
35
+ return (
36
+ scope &&
37
+ ((scope.set && scope.set.get("React")) ||
38
+ (scope.variables && scope.variables.find((v) => v.name === "React")))
39
+ );
28
40
  };
41
+
42
+ const checkReactUsage = (node, messageId = "namespace") => {
43
+ if (!isReactDeclaredInScope(node)) {
44
+ context.report({ node, messageId });
45
+ }
46
+ };
47
+
29
48
  return {
30
- ImportNamespaceSpecifier: (node) => {
31
- checkNode(node, "namespace");
49
+ ImportNamespaceSpecifier: (node) =>
50
+ checkImportSpecifier(node, "namespace"),
51
+ ImportDefaultSpecifier: (node) => checkImportSpecifier(node, "default"),
52
+ MemberExpression: (node) => {
53
+ if (
54
+ node.object &&
55
+ node.object.type === "Identifier" &&
56
+ node.object.name === "React"
57
+ ) {
58
+ checkReactUsage(node.object, "namespace");
59
+ }
32
60
  },
33
- ImportDefaultSpecifier: (node) => {
34
- checkNode(node, "default");
61
+ TSQualifiedName: (node) => {
62
+ if (
63
+ node.left &&
64
+ node.left.type === "Identifier" &&
65
+ node.left.name === "React"
66
+ ) {
67
+ checkReactUsage(node.left, "namespace");
68
+ }
35
69
  },
36
70
  };
37
71
  },
@@ -28,6 +28,34 @@ ruleTester.run("react-named-import", rule, {
28
28
  },
29
29
  ],
30
30
  invalid: [
31
+ {
32
+ code: `
33
+ export const simpleElement: React.ReactNode = <p>paragraph</p>;
34
+ `,
35
+ errors: [
36
+ {
37
+ messageId: "namespace",
38
+ line: 2,
39
+ column: 35,
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ code: `
45
+ import { ReactNode } from 'react';
46
+ import * as React from 'react';
47
+
48
+ export const a: ReactNode = <p>ok</p>;
49
+ export const b: React.ReactNode = <p>bad</p>;
50
+ `,
51
+ errors: [
52
+ {
53
+ messageId: "namespace",
54
+ line: 3,
55
+ column: 14,
56
+ },
57
+ ],
58
+ },
31
59
  {
32
60
  code: `
33
61
  import React from 'react';
@@ -37,6 +65,8 @@ ruleTester.run("react-named-import", rule, {
37
65
  errors: [
38
66
  {
39
67
  messageId: "default",
68
+ line: 2,
69
+ column: 14,
40
70
  },
41
71
  ],
42
72
  },
@@ -49,6 +79,8 @@ ruleTester.run("react-named-import", rule, {
49
79
  errors: [
50
80
  {
51
81
  messageId: "namespace",
82
+ line: 2,
83
+ column: 14,
52
84
  },
53
85
  ],
54
86
  },
@@ -61,6 +93,22 @@ ruleTester.run("react-named-import", rule, {
61
93
  errors: [
62
94
  {
63
95
  messageId: "namespace",
96
+ line: 2,
97
+ column: 19,
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ code: `
103
+ import * as R from 'react';
104
+
105
+ export const simpleElement: R.ReactNode = <p>paragraph</p>;
106
+ `,
107
+ errors: [
108
+ {
109
+ messageId: "namespace",
110
+ line: 2,
111
+ column: 14,
64
112
  },
65
113
  ],
66
114
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pob/eslint-plugin",
3
- "version": "65.4.1",
3
+ "version": "65.6.0",
4
4
  "description": "eslint plugin for react",
5
5
  "keywords": [],
6
6
  "author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
@@ -43,14 +43,14 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@typescript-eslint/utils": "8.59.1",
46
+ "@typescript-eslint/utils": "8.62.0",
47
47
  "eslint-plugin-react": "^7.37.5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/node": "24.10.1",
51
- "@typescript-eslint/rule-tester": "8.59.1",
51
+ "@typescript-eslint/rule-tester": "8.62.0",
52
52
  "eslint": "10.2.1",
53
53
  "typescript": "6.0.3",
54
- "typescript-eslint": "8.59.1"
54
+ "typescript-eslint": "8.62.0"
55
55
  }
56
56
  }