Skip to content

Commit f5b4fac

Browse files
committed
release: 1.40.4-next.1
1 parent a7587b2 commit f5b4fac

File tree

17 files changed

+26
-24
lines changed

17 files changed

+26
-24
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.40.4-beta.0
1+
1.40.4-next.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/monorepo",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"private": true,
55
"description": "Monorepo for eslint-plugin-react-[x, dom, web-api, hooks-extra, naming-convention].",
66
"keywords": [

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/core",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
55
"homepage": "https://github.com/Rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-debug/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-debug",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint plugin for debugging related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-dom",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint plugin for React DOM related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-hooks-extra/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-hooks-extra",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-naming-convention/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-naming-convention",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint plugin for naming convention related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-web-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-web-api",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-x/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-x",
3-
"version": "1.40.4-beta.0",
3+
"version": "1.40.4-next.1",
44
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-x/src/rules/prefer-react-namespace-import.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { RuleContext, RuleFeature } from "@eslint-react/kit";
21
import type { TSESTree } from "@typescript-eslint/types";
32
import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";
43
import type { CamelCase } from "string-ts";
4+
import { type RuleContext, type RuleFeature } from "@eslint-react/kit";
55
import { getSettingsFromContext } from "@eslint-react/shared";
66

77
import { createRule } from "../utils";
@@ -43,26 +43,28 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4343
messageId: "preferReactNamespaceImport",
4444
node: hasOtherSpecifiers ? node : node.parent,
4545
data: { importSource },
46-
// TODO: Use `settings.languagePreference` to determine what code style to use in the fixer (e.g. single or double quotes)
4746
fix(fixer) {
47+
const importDeclarationText = context.sourceCode.getText(node.parent);
48+
const semi = importDeclarationText.endsWith(";") ? ";" : "";
4849
const quote = node.parent.source.raw.at(0) ?? "'";
4950
const isTypeImport = node.parent.importKind === "type";
5051
const importStringPrefix = `import${isTypeImport ? " type" : ""}`;
5152
const importSourceQuoted = `${quote}${importSource}${quote}`;
52-
const sourceCode = context.sourceCode.getText(node.parent);
53-
const semiColon = sourceCode.endsWith(";") ? ";" : "";
5453
if (!hasOtherSpecifiers) {
5554
return fixer.replaceText(
5655
node.parent,
57-
`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semiColon}`,
56+
`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`,
5857
);
5958
}
60-
59+
// dprint-ignore
6160
// remove the default specifier and prepend the namespace import specifier
62-
const specifiers = sourceCode.slice(sourceCode.indexOf("{"), sourceCode.indexOf("}") + 1);
61+
const specifiers = importDeclarationText.slice(importDeclarationText.indexOf("{"), importDeclarationText.indexOf("}") + 1);
6362
return fixer.replaceText(
6463
node.parent,
65-
`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semiColon}\n${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`,
64+
[
65+
`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`,
66+
`${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semi}`,
67+
].join("\n"),
6668
);
6769
},
6870
});

0 commit comments

Comments
 (0)