Skip to content

Commit 6456465

Browse files
committed
style: update code style
1 parent 58b2a06 commit 6456465

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+131
-123
lines changed

dprint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"indentWidth": 2,
55
"quoteStyle": "preferDouble",
66
"quoteProps": "asNeeded",
7+
"bracePosition": "maintain",
78
"importDeclaration.sortNamedImports": "maintain",
89
"exportDeclaration.sortNamedExports": "maintain",
910
"module.sortImportDeclarations": "maintain",

eslint.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const p11tGroups = {
7272

7373
const enableTypeCheckedRules = {
7474
...tseslint.configs.strictTypeCheckedOnly
75-
.map(x => x.rules)
75+
.map((x) => x.rules)
7676
.reduce((a, b) => ({ ...a, ...b }), {}),
7777
...eslintPluginSafeTypeScript.configs.recommended.rules,
7878
"@susisu/safe-typescript/no-unsafe-object-property-check": "off",
@@ -90,7 +90,7 @@ const enableTypeCheckedRules = {
9090
}],
9191
} as const;
9292

93-
const disableTypeCheckedRules = Object.fromEntries(Object.keys(enableTypeCheckedRules).map(x => [x, "off"]));
93+
const disableTypeCheckedRules = Object.fromEntries(Object.keys(enableTypeCheckedRules).map((x) => [x, "off"]));
9494

9595
export default tseslint.config(
9696
eslintConfigFlatGitignore(),
@@ -211,7 +211,14 @@ export default tseslint.config(
211211
"simple-import-sort/exports": "warn",
212212
"simple-import-sort/imports": "warn",
213213
// Part: stylistic rules
214+
"@stylistic/arrow-parens": ["warn", "always"],
214215
"@stylistic/curly-newline": ["warn", "always"],
216+
"@stylistic/no-multi-spaces": ["warn"],
217+
"@stylistic/operator-linebreak": [
218+
"warn",
219+
"before",
220+
],
221+
"@stylistic/quote-props": ["error", "as-needed"],
215222
// Part: perfectionist rules
216223
"perfectionist/sort-exports": "off",
217224
"perfectionist/sort-imports": "off",

packages/core/src/component/component-collector-legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useComponentCollectorLegacy() {
3131
_: key,
3232
id,
3333
kind: "class",
34-
name: O.flatMapNullable(id, n => n.name),
34+
name: O.flatMapNullable(id, (n) => n.name),
3535
node,
3636
// TODO: Get displayName of class component
3737
displayName: O.none(),

packages/core/src/component/component-collector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function useComponentCollector(
8585
const shouldDrop = AST.getNestedReturnStatements(entry.node.body)
8686
.slice()
8787
.reverse()
88-
.some(r => {
88+
.some((r) => {
8989
return context.sourceCode.getScope(r).block === entry.node
9090
&& r.argument != null
9191
&& !JSX.isJSXValue(r.argument, jsxCtx, hint);
@@ -144,15 +144,15 @@ export function useComponentCollector(
144144
) {
145145
const { left, right } = node;
146146
const mbComponentName = match(left.object)
147-
.with({ type: T.Identifier }, n => O.some(n.name))
147+
.with({ type: T.Identifier }, (n) => O.some(n.name))
148148
.otherwise(O.none);
149149
if (O.isNone(mbComponentName)) {
150150
return;
151151
}
152152
const componentName = mbComponentName.value;
153153
const component = Array
154154
.from(components.values())
155-
.findLast(({ name }) => O.exists(name, n => n === componentName));
155+
.findLast(({ name }) => O.exists(name, (n) => n === componentName));
156156
if (component == null) {
157157
return;
158158
}

packages/core/src/component/component-name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const RE_COMPONENT_NAME = /^_?[A-Z]/u;
44

55
export function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[]) {
66
return Array.isArray(node)
7-
? node.map(n => n.name).join(".")
7+
? node.map((n) => n.name).join(".")
88
: node.name;
99
}
1010

packages/core/src/element/get-element-represent-name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function getElementRepresentName(node: TSESTree.JSXOpeningElement, contex
1717
return F.pipe(
1818
O.fromNullable(polymorphicPropName),
1919
O.flatMap(JSX.findPropInAttributes(node.attributes, context.sourceCode.getScope(node))),
20-
O.flatMap(attr => JSX.getPropValue(attr, context.sourceCode.getScope(attr))),
20+
O.flatMap((attr) => JSX.getPropValue(attr, context.sourceCode.getScope(attr))),
2121
O.filter(isString),
2222
O.getOrElse(() => rawElementName),
2323
);

packages/core/src/element/hierarchy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export function isChildrenOfCreateElement(
3939
O.fromNullable(node.parent),
4040
O.filter(AST.is(T.CallExpression)),
4141
O.filter(isCreateElementCall(context)),
42-
O.exists(n =>
42+
O.exists((n) =>
4343
n.arguments
4444
.slice(2)
45-
.some(arg => arg === node)
45+
.some((arg) => arg === node)
4646
),
4747
);
4848
}

packages/core/src/render-prop/hierarchy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export function isDeclaredInRenderPropLoose(node: TSESTree.Node) {
4242

4343
return F.pipe(
4444
AST.findParentNodeGuard(node, AST.is(T.JSXExpressionContainer)),
45-
O.flatMapNullable(c => c.parent),
45+
O.flatMapNullable((c) => c.parent),
4646
O.filter(AST.is(T.JSXAttribute)),
47-
O.flatMapNullable(a => a.name),
48-
O.exists(n =>
47+
O.flatMapNullable((a) => a.name),
48+
O.exists((n) =>
4949
n.type === T.JSXIdentifier
5050
&& n.name.startsWith("render")
5151
),

packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default createRule<[], MessageID>({
3333
F.pipe(
3434
O.some("dangerouslySetInnerHTML"),
3535
O.flatMap(JSX.findPropInAttributes(node.openingElement.attributes, context.sourceCode.getScope(node))),
36-
O.map(prop => ({ messageId: "noDangerouslySetInnerhtml", node: prop } as const)),
36+
O.map((prop) => ({ messageId: "noDangerouslySetInnerhtml", node: prop } as const)),
3737
O.map(context.report),
3838
);
3939
},

packages/plugins/eslint-plugin-react-dom/src/rules/no-script-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default createRule<[], MessageID>({
4141
const isJavaScript = F.pipe(
4242
JSX.getPropValue(node, context.sourceCode.getScope(node)),
4343
O.filter(isString),
44-
O.exists(v => RE_JAVASCRIPT_PROTOCOL.test(v)),
44+
O.exists((v) => RE_JAVASCRIPT_PROTOCOL.test(v)),
4545
);
4646
if (isJavaScript) {
4747
context.report({

0 commit comments

Comments
 (0)