Skip to content

Commit 822fdfd

Browse files
authored
Upgrade eslint (#12)
1 parent 3c55f76 commit 822fdfd

Some content is hidden

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

48 files changed

+3056
-2228
lines changed

.eslintrc.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,54 @@
22
"eslint.workingDirectories": [
33
{ "pattern": "apps/*/" },
44
{ "pattern": "packages/*/" }
5+
],
6+
// Disable the default formatter, use eslint instead
7+
"prettier.enable": false,
8+
"editor.formatOnSave": false,
9+
10+
// Auto fix
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll.eslint": "explicit",
13+
"source.organizeImports": "never"
14+
},
15+
16+
// Silent the stylistic rules in you IDE, but still auto fix them
17+
"eslint.rules.customizations": [
18+
{ "rule": "style/*", "severity": "off", "fixable": true },
19+
{ "rule": "format/*", "severity": "off", "fixable": true },
20+
{ "rule": "*-indent", "severity": "off", "fixable": true },
21+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
22+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
23+
{ "rule": "*-order", "severity": "off", "fixable": true },
24+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
25+
{ "rule": "*-newline", "severity": "off", "fixable": true },
26+
{ "rule": "*quotes", "severity": "off", "fixable": true },
27+
{ "rule": "*semi", "severity": "off", "fixable": true }
28+
],
29+
30+
// Enable eslint for all supported languages
31+
"eslint.validate": [
32+
"javascript",
33+
"javascriptreact",
34+
"typescript",
35+
"typescriptreact",
36+
"vue",
37+
"html",
38+
"markdown",
39+
"json",
40+
"json5",
41+
"jsonc",
42+
"yaml",
43+
"toml",
44+
"xml",
45+
"gql",
46+
"graphql",
47+
"astro",
48+
"svelte",
49+
"css",
50+
"less",
51+
"scss",
52+
"pcss",
53+
"postcss"
554
]
655
}

apps/docs/.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/docs/components/banner/index.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
1-
import { HTMLAttributes } from 'react';
2-
import { RoughOptions, RoughSVG, SVGShape } from 'react-rough-fiber';
3-
import { textPaths } from '../demos/text';
4-
import styles from './index.module.css';
1+
import type { HTMLAttributes } from 'react'
2+
import type { RoughOptions, SVGShape } from 'react-rough-fiber'
3+
import { RoughSVG } from 'react-rough-fiber'
4+
import { textPaths } from '../demos/text'
5+
import styles from './index.module.css'
56

6-
const options = (
7-
{ type }: SVGShape,
8-
props: HTMLAttributes<SVGElement>
9-
): RoughOptions => {
7+
function options({ type }: SVGShape, props: HTMLAttributes<SVGElement>): RoughOptions {
108
switch (type) {
119
case 'rect':
1210
return {
1311
roughness: 0,
1412
fillStyle: 'dots',
1513
hachureGap: 20,
16-
};
14+
}
1715
case 'path': {
18-
const dataIndex = props['data-index' as keyof HTMLAttributes<SVGElement>];
16+
const dataIndex = props['data-index' as keyof HTMLAttributes<SVGElement>]
1917
if (dataIndex === undefined) {
2018
return {
2119
seed: 4,
2220
disableMultiStroke: true,
2321
roughness: 5,
24-
};
22+
}
2523
}
2624
if (dataIndex >= 5 && dataIndex < 10) {
2725
return {
2826
roughness: 0,
2927
fillStyle: 'solid',
30-
};
28+
}
3129
}
3230
return {
3331
roughness: 0,
3432
hachureGap: 4,
3533
fillWeight: 2,
36-
};
34+
}
3735
}
3836
default:
39-
return {};
37+
return {}
4038
}
41-
};
39+
}
4240

43-
export const Banner = () => {
41+
export function Banner() {
4442
return (
4543
<>
4644
<RoughSVG options={options} className="mt-12">
@@ -77,5 +75,5 @@ export const Banner = () => {
7775
</svg>
7876
</RoughSVG>
7977
</>
80-
);
81-
};
78+
)
79+
}

apps/docs/components/banner/og.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
import { HTMLAttributes } from 'react';
2-
import { RoughOptions, RoughSVG, SVGShape } from 'react-rough-fiber';
3-
import { textPaths } from '../demos/text';
1+
import type { HTMLAttributes } from 'react'
2+
import type { RoughOptions, SVGShape } from 'react-rough-fiber'
3+
import { RoughSVG } from 'react-rough-fiber'
4+
import { textPaths } from '../demos/text'
45

5-
const options = (
6-
{ type }: SVGShape,
7-
props: HTMLAttributes<SVGElement>
8-
): RoughOptions => {
6+
function options({ type }: SVGShape, props: HTMLAttributes<SVGElement>): RoughOptions {
97
switch (type) {
108
case 'rect':
119
return {
1210
roughness: 0,
1311
fillStyle: 'dots',
1412
hachureGap: 20,
15-
};
13+
}
1614
case 'path': {
17-
const dataIndex = props['data-index' as keyof HTMLAttributes<SVGElement>];
15+
const dataIndex = props['data-index' as keyof HTMLAttributes<SVGElement>]
1816
if (dataIndex === undefined) {
1917
return {
2018
seed: 4,
2119
disableMultiStroke: true,
2220
roughness: 5,
23-
};
21+
}
2422
}
2523
if (dataIndex >= 5 && dataIndex < 10) {
2624
return {
2725
roughness: 0,
2826
fillStyle: 'solid',
29-
};
27+
}
3028
}
3129
return {
3230
roughness: 0,
3331
hachureGap: 4,
3432
fillWeight: 2,
35-
};
33+
}
3634
}
3735
default:
38-
return {};
36+
return {}
3937
}
40-
};
38+
}
4139

42-
export const OG = () => {
40+
export function OG() {
4341
return (
4442
<>
4543
<RoughSVG
@@ -91,5 +89,5 @@ export const OG = () => {
9189
</svg>
9290
</RoughSVG>
9391
</>
94-
);
95-
};
92+
)
93+
}

apps/docs/components/constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export const CAVEAT_BOLD_FONT_URL =
2-
'https://fonts.gstatic.com/s/caveatbrush/v11/EYq0maZfwr9S9-ETZc3fKXt8XLOU.woff';
1+
export const CAVEAT_BOLD_FONT_URL
2+
= 'https://fonts.gstatic.com/s/caveatbrush/v11/EYq0maZfwr9S9-ETZc3fKXt8XLOU.woff'
33

4-
export const CAVEAT_FONT_URL =
5-
'https://fonts.gstatic.com/s/caveat/v17/WnznHAc5bAfYB2QRah7pcpNvOx-pjcB9eIWpZw.woff';
4+
export const CAVEAT_FONT_URL
5+
= 'https://fonts.gstatic.com/s/caveat/v17/WnznHAc5bAfYB2QRah7pcpNvOx-pjcB9eIWpZw.woff'
66

7-
export const TWEMOJI_URL =
8-
'https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg';
7+
export const TWEMOJI_URL
8+
= 'https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg'

apps/docs/components/demos/chart.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { RoughSVG } from 'react-rough-fiber';
2-
import { BarChart, XAxis, YAxis, Tooltip, Legend, Bar } from 'recharts';
3-
import useDimensions from 'react-cool-dimensions';
1+
import useDimensions from 'react-cool-dimensions'
2+
import { RoughSVG } from 'react-rough-fiber'
3+
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from 'recharts'
44

55
const data = [
66
{
@@ -38,16 +38,16 @@ const data = [
3838
uv: 3490,
3939
pv: 4300,
4040
},
41-
];
41+
]
4242

43-
export const ChartDemo = () => {
44-
const { observe, width } = useDimensions();
43+
export function ChartDemo() {
44+
const { observe, width } = useDimensions()
4545
return (
4646
<div ref={observe}>
4747
<RoughSVG
4848
className="my-4"
4949
options={{ fillStyle: 'zigzag' }}
50-
style={{ fontFamily: "'Caveat'" }}
50+
style={{ fontFamily: '\'Caveat\'' }}
5151
>
5252
<BarChart width={width} height={width / 5 + 100} data={data}>
5353
<XAxis dataKey="name" />
@@ -59,5 +59,5 @@ export const ChartDemo = () => {
5959
</BarChart>
6060
</RoughSVG>
6161
</div>
62-
);
63-
};
62+
)
63+
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { ComponentProps, PropsWithChildren } from 'react';
2-
import { RoughSVG, Options } from 'react-rough-fiber';
3-
import { ChevronsDown } from 'react-feather';
1+
import type { ComponentProps, PropsWithChildren } from 'react'
2+
import type { Options } from 'react-rough-fiber'
3+
import { ChevronsDown } from 'react-feather'
4+
import { RoughSVG } from 'react-rough-fiber'
45

5-
type Props = PropsWithChildren<{ options?: Options } & ComponentProps<'div'>>;
6-
export const Comparison = (props: Props) => {
7-
const { options, children, ...restProps } = props;
6+
type Props = PropsWithChildren<{ options?: Options } & ComponentProps<'div'>>
7+
export function Comparison(props: Props) {
8+
const { options, children, ...restProps } = props
89
return (
910
<div className="flex gap-4 my-4 flex-col items-center" {...restProps}>
1011
<div className="flex gap-4">{children}</div>
@@ -13,5 +14,5 @@ export const Comparison = (props: Props) => {
1314
{children}
1415
</RoughSVG>
1516
</div>
16-
);
17-
};
17+
)
18+
}

apps/docs/components/demos/emoji.tsx

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
1-
import SVG from 'react-inlinesvg';
2-
import { TWEMOJI_URL } from '../constants';
3-
import { Comparison } from './comparison';
1+
import SVG from 'react-inlinesvg'
2+
import { TWEMOJI_URL } from '../constants'
3+
import { Comparison } from './comparison'
44

5-
const U200D = String.fromCharCode(0x200d);
6-
const UFE0Fg = /\uFE0F/g;
5+
const U200D = String.fromCharCode(0x200D)
6+
const UFE0Fg = /\uFE0F/g
77
function toCodePoint(unicodeSurrogates: string, sep?: string) {
8-
let r = [];
9-
let c = 0;
10-
let p = 0;
11-
let i = 0;
8+
const r = []
9+
let c = 0
10+
let p = 0
11+
let i = 0
1212
while (i < unicodeSurrogates.length) {
13-
c = unicodeSurrogates.charCodeAt(i++);
13+
c = unicodeSurrogates.charCodeAt(i++)
1414
if (p) {
15-
r.push((0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00)).toString(16));
16-
p = 0;
17-
} else if (0xd800 <= c && c <= 0xdbff) {
18-
p = c;
19-
} else {
20-
r.push(c.toString(16));
15+
r.push((0x10000 + ((p - 0xD800) << 10) + (c - 0xDC00)).toString(16))
16+
p = 0
17+
}
18+
else if (c >= 0xD800 && c <= 0xDBFF) {
19+
p = c
20+
}
21+
else {
22+
r.push(c.toString(16))
2123
}
2224
}
23-
return r.join(sep || '-');
25+
return r.join(sep || '-')
2426
}
2527

26-
type EmojiProps = {
27-
emoji: string;
28-
width?: number;
29-
};
30-
export const Emoji = ({ emoji, width = 48 }: EmojiProps) => {
28+
interface EmojiProps {
29+
emoji: string
30+
width?: number
31+
}
32+
export function Emoji({ emoji, width = 48 }: EmojiProps) {
3133
const HEXCodePoint = toCodePoint(
32-
emoji.indexOf(U200D) < 0 ? emoji.replace(UFE0Fg, '') : emoji
33-
);
34-
const url = TWEMOJI_URL + '/' + HEXCodePoint + '.svg';
34+
!emoji.includes(U200D) ? emoji.replace(UFE0Fg, '') : emoji,
35+
)
36+
const url = `${TWEMOJI_URL}/${HEXCodePoint}.svg`
3537
return (
3638
<SVG src={url} width={width} loader={<img src={url} width={48} />}></SVG>
37-
);
38-
};
39+
)
40+
}
3941

40-
export const EmojiDemo = () => {
42+
export function EmojiDemo() {
4143
return (
4244
<Comparison options={{ seed: 2, hachureGap: 1, fillWeight: 0.5 }}>
4345
<Emoji emoji="😊" />
4446
<Emoji emoji="😜" />
4547
<Emoji emoji="😈" />
4648
</Comparison>
47-
);
48-
};
49+
)
50+
}

0 commit comments

Comments
 (0)