Skip to content

Commit 489d671

Browse files
chore: eslint sort import (#10)
1 parent 63ac979 commit 489d671

15 files changed

+158
-91
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
indent_style = space
10+
indent_size = 2
11+
12+
end_of_line = lf
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true
16+
17+
max_line_length = 100

.github/ISSUE_TEMPLATE/bug.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
## Bug Description
2+
23
[Concise description of the bug]
34

45
## Steps to Reproduce
5-
1.
6-
2.
7-
3.
6+
7+
1.
8+
2.
9+
3.
810

911
## Expected Behavior
12+
1013
[What you expected to happen]
1114

1215
## Actual Behavior
16+
1317
[What actually happened]
1418

1519
## Environment
20+
1621
- Library version:
1722
- Node.js version:
1823
- Browser (if applicable):
1924
- OS:
2025

2126
## Additional Context
27+
2228
[Any other relevant information, screenshots, etc.]
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
## Feature Description
2+
23
[Concise description of the proposed feature]
34

45
## Problem It Solves
6+
57
[Explain the problem this feature would solve]
68

79
## Proposed Solution
10+
811
[Your ideas on how to implement the feature]
912

1013
## Alternatives Considered
14+
1115
[Any alternative solutions or features you've considered]
1216

1317
## Additional Context
14-
[Any other relevant information, mockups, etc.]
18+
19+
[Any other relevant information, mockups, etc.]

.github/pull_request_template.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
## Summary
2+
23
[Provide a brief description of the changes in this PR]
34

45
## Type of change
6+
57
- [ ] Bug fix
68
- [ ] New feature
79
- [ ] Breaking change
810
- [ ] Documentation update
911
- [ ] Other (specify below)
1012

1113
## How Has This Been Tested?
14+
1215
[Describe the tests you ran to verify your changes]
1316

1417
## Checklist:
18+
1519
- [ ] Code follows style guidelines
1620
- [ ] Self-review completed
1721
- [ ] Code commented where necessary
@@ -22,4 +26,5 @@
2226
- [ ] Dependent changes merged
2327

2428
## Additional Notes:
29+
2530
[Add any additional information or context about the PR here]

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15-
15+
1616
- name: Setup deps
1717
uses: ./.github/actions/setup
1818

eslint.config.js

+45-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
1-
import eslint from '@eslint/js';
2-
import tseslint from 'typescript-eslint';
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import simpleImportSort from "eslint-plugin-simple-import-sort";
34

45
export default tseslint.config(
5-
eslint.configs.recommended,
6-
...tseslint.configs.strictTypeChecked,
7-
{
8-
files: ['src/**/*.{ts,tsx}'],
9-
languageOptions: {
10-
parserOptions: {
11-
projectService: true,
12-
tsconfigRootDir: import.meta.dirname,
13-
},
14-
},
6+
eslint.configs.recommended,
7+
...tseslint.configs.strictTypeChecked,
8+
{
9+
files: ["src/**/*.{ts,tsx}"],
10+
languageOptions: {
11+
parserOptions: {
12+
projectService: true,
13+
tsconfigRootDir: import.meta.dirname,
14+
},
1515
},
16-
{
17-
rules: {
18-
'@typescript-eslint/no-unused-vars': ['error', {
19-
'argsIgnorePattern': '^_',
20-
'varsIgnorePattern': '^_',
21-
'caughtErrorsIgnorePattern': '^_'
22-
}],
23-
},
16+
},
17+
{
18+
plugins: {
19+
"simple-import-sort": simpleImportSort,
2420
},
25-
{
26-
27-
ignores: ['node_modules/**', 'dist/**', "*.config.{js,ts}", "react-native.js", "react-native.d.ts"],
21+
rules: {
22+
"@typescript-eslint/no-unused-vars": [
23+
"error",
24+
{
25+
argsIgnorePattern: "^_",
26+
varsIgnorePattern: "^_",
27+
caughtErrorsIgnorePattern: "^_",
28+
},
29+
],
30+
"@typescript-eslint/consistent-type-imports": ["error", {
31+
fixStyle: "separate-type-imports",
32+
}],
33+
"simple-import-sort/imports": [
34+
"error",
35+
{
36+
groups: [["^\\u0000", "^node:", "^@?\\w", "^"], ["^\\."]],
37+
},
38+
],
2839
},
29-
);
40+
},
41+
{
42+
ignores: [
43+
"node_modules/**",
44+
"dist/**",
45+
"*.config.{js,ts}",
46+
"react-native.js",
47+
"react-native.d.ts",
48+
],
49+
},
50+
);

jest.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
2-
preset: 'ts-jest',
3-
testEnvironment: 'node',
4-
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
5-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
6-
};
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"],
5+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
6+
};

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
"@types/react": "^19.0.10",
5252
"@types/react-reconciler": "^0.28.9",
5353
"eslint": "^9.21.0",
54+
"eslint-plugin-simple-import-sort": "^12.1.1",
5455
"jest": "^29.7.0",
56+
"prettier": "^3.5.2",
5557
"react": "^19.0.0",
5658
"release-it": "^18.1.2",
5759
"ts-jest": "^29.2.6",

pnpm-lock.yaml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/renderer.test.tsx

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { act, createElement, ReactElement } from "react";
21
import { expect, test } from "@jest/globals";
3-
import { createRoot, RootOptions } from "../renderer";
2+
import type { ReactElement } from "react";
3+
import { act, createElement } from "react";
4+
5+
import type { RootOptions } from "../renderer";
6+
import { createRoot } from "../renderer";
47

58
const originalConsoleError = console.error;
69

@@ -43,7 +46,7 @@ test("render with single allowed text component", () => {
4346
<div>
4447
<hr />
4548
</div>,
46-
{ textComponents: ["Text"] }
49+
{ textComponents: ["Text"] },
4750
);
4851
expect(renderer.root?.toJSON()).toMatchInlineSnapshot(`
4952
<div>
@@ -56,7 +59,7 @@ test("render with single allowed text component", () => {
5659
renderer.render(<div>Hello!</div>);
5760
});
5861
}).toThrowErrorMatchingInlineSnapshot(
59-
`"Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render "Hello!" string within a <div> component."`
62+
`"Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render "Hello!" string within a <div> component."`,
6063
);
6164
});
6265

@@ -66,7 +69,7 @@ test("render with two allowed text components", () => {
6669
{createElement("A", null, "Hello!")}
6770
{createElement("B", null, "Hi!")}
6871
</div>,
69-
{ textComponents: ["A", "B"] }
72+
{ textComponents: ["A", "B"] },
7073
);
7174
expect(renderer.root?.toJSON()).toMatchInlineSnapshot(`
7275
<div>
@@ -84,7 +87,7 @@ test("render with two allowed text components", () => {
8487
renderer.render(createElement("X", null, "Hello!"));
8588
});
8689
}).toThrowErrorMatchingInlineSnapshot(
87-
`"Invariant Violation: Text strings must be rendered within a <A> or <B> component. Detected attempt to render "Hello!" string within a <X> component."`
90+
`"Invariant Violation: Text strings must be rendered within a <A> or <B> component. Detected attempt to render "Hello!" string within a <X> component."`,
8891
);
8992
});
9093

@@ -95,14 +98,14 @@ test("render with multiple allowed text components", () => {
9598
{createElement("B", null, "Hi!")}
9699
{createElement("C", null, "Hola!")}
97100
</div>,
98-
{ textComponents: ["A", "B", "C"] }
101+
{ textComponents: ["A", "B", "C"] },
99102
);
100103

101104
expect(() => {
102105
act(() => {
103106
renderer.render(createElement("X", null, "Hello!"));
104107
});
105108
}).toThrowErrorMatchingInlineSnapshot(
106-
`"Invariant Violation: Text strings must be rendered within a <A>, <B>, or <C> component. Detected attempt to render "Hello!" string within a <X> component."`
109+
`"Invariant Violation: Text strings must be rendered within a <A>, <B>, or <C> component. Detected attempt to render "Hello!" string within a <X> component."`,
107110
);
108111
});

src/host-element.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { CONTAINER_TYPE } from "./constants";
2-
import { Container, Instance, TextInstance } from "./reconciler";
3-
import { JsonNode, renderToJson } from "./render-to-json";
2+
import type { Container, Instance, TextInstance } from "./reconciler";
3+
import type { JsonNode} from "./render-to-json";
4+
import { renderToJson } from "./render-to-json";
45

56
export type HostNode = HostElement | string;
67

78
// eslint-disable-next-line @typescript-eslint/no-explicit-any
89
export type HostElementProps = Record<string, any>;
910

10-
const instanceToHostElementMap = new WeakMap<
11-
Container | Instance,
12-
HostElement
13-
>();
11+
const instanceToHostElementMap = new WeakMap<Container | Instance, HostElement>();
1412

1513
export class HostElement {
1614
private instance: Instance | Container;
@@ -20,9 +18,7 @@ export class HostElement {
2018
}
2119

2220
get type(): string {
23-
return this.instance.tag === "INSTANCE"
24-
? this.instance.type
25-
: CONTAINER_TYPE;
21+
return this.instance.tag === "INSTANCE" ? this.instance.type : CONTAINER_TYPE;
2622
}
2723

2824
get props(): HostElementProps {

src/platforms/react-native.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { ReactElement } from "react";
2-
import { createRoot, Root } from "../renderer";
1+
import type { ReactElement } from "react";
2+
3+
import type { Root } from "../renderer";
4+
import { createRoot } from "../renderer";
35

46
export type ReactNativeRootOptions = {
57
createNodeMock?: (element: ReactElement) => object;

0 commit comments

Comments
 (0)