Skip to content

Commit 18f4883

Browse files
committed
chore: Add Code Formatter.
1 parent 8405c79 commit 18f4883

File tree

11 files changed

+106
-57
lines changed

11 files changed

+106
-57
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx pretty-quick --staged

.kktrc.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path';
2-
import webpack, {Configuration} from 'webpack';
2+
import webpack, { Configuration } from 'webpack';
33
import { LoaderConfOptions } from 'kkt';
44
import lessModules from '@kkt/less-modules';
55
import rawModules from '@kkt/raw-modules';
@@ -11,14 +11,14 @@ export default (conf: Configuration, env: string, options: LoaderConfOptions) =>
1111
conf = lessModules(conf, env, options);
1212
conf = scopePluginOptions(conf, env, {
1313
...options,
14-
allowedFiles: [
15-
path.resolve(process.cwd(), 'README.md'),
16-
]
14+
allowedFiles: [path.resolve(process.cwd(), 'README.md')],
1715
});
1816
// Get the project version.
19-
conf.plugins!.push(new webpack.DefinePlugin({
20-
VERSION: JSON.stringify(pkg.version),
21-
}));
17+
conf.plugins!.push(
18+
new webpack.DefinePlugin({
19+
VERSION: JSON.stringify(pkg.version),
20+
}),
21+
);
2222

2323
conf.optimization = {
2424
...conf.optimization,
@@ -34,10 +34,9 @@ export default (conf: Configuration, env: string, options: LoaderConfOptions) =>
3434
name: 'prismjs-vendor',
3535
chunks: 'async',
3636
},
37-
}
38-
}
39-
}
37+
},
38+
},
39+
};
4040

4141
return conf;
42-
}
43-
42+
};

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**/*.md
2+
**/*.svg
3+
**/*.ejs
4+
**/*.html
5+
**/*.yml
6+
package.json
7+
node_modules
8+
dist
9+
build
10+
coverage
11+
lib
12+
esm
13+
test

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": { "parser": "json" }
9+
}
10+
]
11+
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
"main": "lib/index.js",
77
"module": "esm/index.js",
88
"scripts": {
9-
"prepare": "npm run build",
9+
"prepare": "npm run build && husky install",
1010
"doc": "kkt build --app-src ./website",
1111
"start": "kkt start --app-src ./website",
1212
"css:build": "compile-less -d src -o esm",
1313
"css:watch": "compile-less -d src -o esm --watch",
1414
"css:build:dist": "compile-less -d src --combine markdown.css --rm-global",
1515
"watch": "tsbb watch & npm run css:watch",
1616
"build": "tsbb build && npm run css:build && npm run css:build:dist",
17+
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
18+
"pretty-quick": "pretty-quick --staged",
1719
"test": "tsbb test --env=jsdom",
1820
"coverage": "tsbb test --env=jsdom --coverage"
1921
},
@@ -68,11 +70,14 @@
6870
"@uiw/reset.css": "1.0.5",
6971
"compile-less-cli": "1.8.9",
7072
"kkt": "6.11.0",
73+
"prettier": "2.4.1",
74+
"pretty-quick": "3.1.1",
7175
"jest": "27.2.5",
7276
"react": "17.0.2",
7377
"react-dom": "17.0.2",
7478
"react-test-renderer": "17.0.2",
75-
"tsbb": "3.4.1"
79+
"tsbb": "3.4.1",
80+
"husky": "^7.0.0"
7681
},
7782
"eslintConfig": {
7883
"extends": "react-app"

renovate.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"extends": [
3-
"config:base"
4-
]
2+
"extends": ["config:base"]
53
}

src/styles/markdown.less

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
.wmde-markdown {
22
font-size: 16px;
33
line-height: 1.5;
4-
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;
4+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji,
5+
Segoe UI Emoji;
56
> :first-child {
67
margin-top: 0 !important;
78
}
89
> :last-child {
910
margin-bottom: 0 !important;
1011
}
11-
code[class*="language-"], pre[class*="language-"] {
12+
code[class*='language-'],
13+
pre[class*='language-'] {
1214
color: black;
1315
text-align: left;
1416
white-space: pre;
@@ -39,31 +41,40 @@
3941
background-color: #f6f8fa;
4042
border-radius: 3px;
4143
}
42-
code, tt {
43-
background-color: rgba(27,31,35,.05);
44+
code,
45+
tt {
46+
background-color: rgba(27, 31, 35, 0.05);
4447
border-radius: 3px;
4548
font-size: 85%;
4649
margin: 0;
47-
padding: .2em .4em;
50+
padding: 0.2em 0.4em;
4851
}
49-
pre, code, tt {
50-
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
52+
pre,
53+
code,
54+
tt {
55+
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
5156
}
5257
img {
5358
max-width: 100%;
5459
}
5560
input {
5661
vertical-align: middle;
57-
margin: 0 .2em .25em -1.6em;
62+
margin: 0 0.2em 0.25em -1.6em;
5863
& + p {
5964
display: inline;
6065
}
6166
}
62-
h1, h2 {
67+
h1,
68+
h2 {
6369
border-bottom: 1px solid #eaecef;
64-
padding-bottom: .3em;
70+
padding-bottom: 0.3em;
6571
}
66-
h1, h2, h3, h4, h5, h6 {
72+
h1,
73+
h2,
74+
h3,
75+
h4,
76+
h5,
77+
h6 {
6778
font-weight: 600;
6879
line-height: 1.25;
6980
margin-bottom: 16px;
@@ -95,12 +106,13 @@
95106
font-size: 1em;
96107
}
97108
h5 {
98-
font-size: .875em;
109+
font-size: 0.875em;
99110
}
100111
h6 {
101-
font-size: .85em;
112+
font-size: 0.85em;
102113
}
103-
ol, ul {
114+
ol,
115+
ul {
104116
padding-left: 2em;
105117
& > p {
106118
margin-bottom: 0;
@@ -111,9 +123,10 @@
111123
margin-top: 0;
112124
list-style: initial;
113125
}
114-
> blockquote, > blockquote blockquote {
126+
> blockquote,
127+
> blockquote blockquote {
115128
margin: 0;
116-
border-left: .25em solid #dfe2e5;
129+
border-left: 0.25em solid #dfe2e5;
117130
color: #6a737d;
118131
padding: 0 1em;
119132
> :last-child {
@@ -131,7 +144,8 @@
131144
height: 1px;
132145
}
133146

134-
> table, > blockquote table {
147+
> table,
148+
> blockquote table {
135149
display: block;
136150
overflow: auto;
137151
width: 100%;
@@ -142,12 +156,20 @@
142156
background-color: #fff;
143157
border-top: 1px solid #c6cbd1;
144158
}
145-
td, th {
159+
td,
160+
th {
146161
border: 1px solid #dfe2e5;
147162
padding: 6px 13px;
148163
}
149164
}
150-
blockquote, details, dl, ol, p, pre, table, ul {
165+
blockquote,
166+
details,
167+
dl,
168+
ol,
169+
p,
170+
pre,
171+
table,
172+
ul {
151173
margin-bottom: 16px;
152174
margin-top: 0;
153175
}
@@ -161,7 +183,7 @@
161183
}
162184

163185
.namespace {
164-
opacity: .7;
186+
opacity: 0.7;
165187
}
166188
.token.important {
167189
font-weight: normal;
@@ -187,9 +209,9 @@
187209
color: #56595d;
188210
display: inline-block;
189211
font-size: 10px;
190-
font-family: ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace;
212+
font-family: ui-monospace, SFMono-Regular, SF Mono, Consolas, Liberation Mono, Menlo, monospace;
191213
line-height: 10px;
192214
padding: 2px 4px;
193215
vertical-align: middle;
194216
}
195-
}
217+
}

src/styles/markdowncolor.less

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
.wmde-markdown-color {
32
.token.tag .attr-value {
43
color: #032f62;
@@ -18,7 +17,7 @@
1817
color: #a0a0a0;
1918
}
2019
}
21-
.wmde-markdown-color code[class*="language-"] {
20+
.wmde-markdown-color code[class*='language-'] {
2221
color: black;
2322
.token.selector,
2423
.token.attr-name,
@@ -50,7 +49,7 @@
5049
.token.prolog,
5150
.token.doctype,
5251
.token.cdata {
53-
color: #7D8B99;
52+
color: #7d8b99;
5453
}
5554
.token.punctuation {
5655
color: #a0a0a0;

tsconfig.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
4+
"lib": ["dom", "dom.iterable", "esnext"],
95
"allowJs": true,
106
"skipLibCheck": true,
117
"esModuleInterop": true,
@@ -22,8 +18,5 @@
2218
"noFallthroughCasesInSwitch": true,
2319
"noEmit": true
2420
},
25-
"include": [
26-
"website",
27-
"test"
28-
]
21+
"include": ["website", "test"]
2922
}

website/App.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ const App = () => {
2121
React Markdown Preview
2222
</a>
2323
<p>
24-
React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style.
24+
React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub
25+
Markdown style.
2526
</p>
2627
</header>
2728
<div className="App-editor">
2829
<button onClick={() => setValue('# Markdown ' + val++)}>set value</button>
29-
30+
3031
<textarea
3132
placeholder="Please enter the Markdown code!"
3233
value={value}
@@ -41,10 +42,14 @@ const App = () => {
4142
<Github.Social type="stars" href="https://github.com/uiwjs/react-markdown-preview/stargazers" />
4243
<Github.Social type="watchers" href="https://github.com/uiwjs/react-markdown-preview/watchers" />
4344
</Github>
44-
<Npm.Version scope="@uiw" packageName="react-markdown-preview" href="https://www.npmjs.com/package/@uiw/react-markdown-preview" />
45+
<Npm.Version
46+
scope="@uiw"
47+
packageName="react-markdown-preview"
48+
href="https://www.npmjs.com/package/@uiw/react-markdown-preview"
49+
/>
4550
</div>
4651
</div>
4752
);
48-
}
53+
};
4954

50-
export default App;
55+
export default App;

0 commit comments

Comments
 (0)