Skip to content

Commit eda0a71

Browse files
committed
chore: make code formatting more accessible
1 parent 70eff65 commit eda0a71

14 files changed

+8835
-8823
lines changed

.babelrc.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"presets": [
3-
"@babel/typescript",
4-
"@babel/react",
5-
["@babel/env", { "targets": "defaults", "bugfixes": true, "loose": true }]
6-
]
2+
"presets": [
3+
"@babel/typescript",
4+
"@babel/react",
5+
["@babel/env", { "targets": "defaults", "bugfixes": true, "loose": true }]
6+
]
77
}

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
root = true
22

33
[*]
4-
indent_style = space
4+
indent_style = tab
55
indent_size = 2
66
end_of_line = lf
77
charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010

11+
[*.yml]
12+
indent_style = space
13+
1114
[*.md]
1215
trim_trailing_whitespace = false

.eslintrc.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"root": true,
3-
"env": { "browser": true },
4-
"parserOptions": { "project": "./tsconfig.json" },
5-
"extends": [
6-
"airbnb-typescript",
7-
"airbnb/hooks",
8-
"plugin:@typescript-eslint/recommended",
9-
"prettier",
10-
"prettier/@typescript-eslint",
11-
"prettier/react"
12-
],
13-
"plugins": ["simple-import-sort"],
2+
"root": true,
3+
"env": { "browser": true },
4+
"parserOptions": { "project": "./tsconfig.json" },
5+
"extends": [
6+
"airbnb-typescript",
7+
"airbnb/hooks",
8+
"plugin:@typescript-eslint/recommended",
9+
"prettier",
10+
"prettier/@typescript-eslint",
11+
"prettier/react"
12+
],
13+
"plugins": ["simple-import-sort"],
1414

15-
"rules": {
16-
// Auto-sort imports
17-
"sort-imports": "off",
18-
"import/order": "off",
19-
"simple-import-sort/sort": "error",
15+
"rules": {
16+
// Auto-sort imports
17+
"sort-imports": "off",
18+
"import/order": "off",
19+
"simple-import-sort/sort": "error",
2020

21-
// Using a type system makes it safe enough to spread props
22-
"react/jsx-props-no-spreading": "off"
23-
}
21+
// Using a type system makes it safe enough to spread props
22+
"react/jsx-props-no-spreading": "off"
23+
}
2424
}

.prettierrc.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2-
"singleQuote": true,
3-
"trailingComma": "all"
2+
"useTabs": true,
3+
"trailingComma": "all",
4+
"overrides": [
5+
{
6+
"files": "*.md",
7+
"options": {
8+
"useTabs": false,
9+
"trailingComma": "none"
10+
}
11+
}
12+
]
413
}

.vscode/extensions.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"recommendations": [
3-
"dbaeumer.vscode-eslint",
4-
"editorconfig.editorconfig",
5-
"esbenp.prettier-vscode"
6-
]
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"editorconfig.editorconfig",
5+
"esbenp.prettier-vscode"
6+
]
77
}

.vscode/settings.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
// Enable automatic file formatting and fixing
3-
"editor.defaultFormatter": "esbenp.prettier-vscode",
4-
"editor.formatOnSave": true,
5-
"editor.codeActionsOnSave": {
6-
"source.fixAll.eslint": true
7-
}
2+
// Enable automatic file formatting and fixing
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.formatOnSave": true,
5+
"editor.codeActionsOnSave": {
6+
"source.fixAll.eslint": true
7+
}
88
}

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ A `Heading` component can demonstrate the effectiveness of polymorphism:
3939
Custom components like the previous one may utilize the package as shown below.
4040

4141
```tsx
42-
import * as React from 'react';
43-
import { Box, PolymorphicComponentProps } from 'react-polymorphic-box';
42+
import * as React from "react";
43+
import { Box, PolymorphicComponentProps } from "react-polymorphic-box";
4444

4545
// Component-specific props should be specified separately
4646
export interface HeadingOwnProps {
@@ -53,7 +53,7 @@ export type HeadingProps<
5353
> = PolymorphicComponentProps<E, HeadingOwnProps>;
5454

5555
// An HTML tag or a different React component can be rendered by default
56-
const defaultElement = 'h2';
56+
const defaultElement = "h2";
5757

5858
export function Heading<E extends React.ElementType = typeof defaultElement>({
5959
color,
@@ -70,16 +70,16 @@ export function Heading<E extends React.ElementType = typeof defaultElement>({
7070
Alternatively, you can also type your custom components by using the `PolymorphicComponent` type. This is especially handy when working with external libraries that already expose polymorphic components. Here's an example implementing the Heading component from above using [styled-components](https://styled-components.com):
7171

7272
```tsx
73-
import { PolymorphicComponent } from 'react-polymorphic-box';
74-
import styled from 'styled-components';
73+
import { PolymorphicComponent } from "react-polymorphic-box";
74+
import styled from "styled-components";
7575

7676
// Component-specific props
7777
interface HeadingProps {
7878
color?: string;
7979
}
8080

8181
// An HTML tag or a different React component can be rendered by default
82-
const defaultElement = 'h2';
82+
const defaultElement = "h2";
8383

8484
const Heading: PolymorphicComponent<
8585
HeadingProps, // Merged with props from the underlying element type
@@ -94,13 +94,13 @@ const Heading: PolymorphicComponent<
9494
Library authors should consider encapsulating reusable components, [passing a ref](https://reactjs.org/docs/forwarding-refs.html) through each of them:
9595

9696
```tsx
97-
import * as React from 'react';
98-
import { Box } from 'react-polymorphic-box';
97+
import * as React from "react";
98+
import { Box } from "react-polymorphic-box";
9999

100100
export const Heading = React.forwardRef(
101101
<E extends React.ElementType = typeof defaultElement>(
102102
{ ref, color, style, ...restProps }: HeadingProps<E>,
103-
innerRef: typeof ref,
103+
innerRef: typeof ref
104104
) => {
105105
return (
106106
<Box
@@ -110,8 +110,8 @@ export const Heading = React.forwardRef(
110110
{...restProps}
111111
/>
112112
);
113-
},
113+
}
114114
) as <E extends React.ElementType = typeof defaultElement>(
115-
props: HeadingProps<E>,
115+
props: HeadingProps<E>
116116
) => JSX.Element;
117117
```

0 commit comments

Comments
 (0)