Skip to content

Commit 89c194b

Browse files
authored
Fix prettier glob to correctly navigate recursively and format missing files (#107)
1 parent e2b0859 commit 89c194b

File tree

9 files changed

+965
-962
lines changed

9 files changed

+965
-962
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "rollup -c rollup.config.js",
1919
"test": "jest",
2020
"flow": "flow check",
21-
"format": "prettier --write src/**/*.js",
21+
"format": "prettier --write 'src/**/*.js'",
2222
"prepublishOnly": "run-p flow build"
2323
},
2424
"husky": {

src/defaultProps.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// @flow
2-
3-
import Prism from "./vendor/prism";
4-
import theme from "./themes/duotoneDark";
5-
6-
import type { PrismLib } from "./types";
7-
8-
const defaultProps = {
9-
// $FlowFixMe
10-
Prism: (Prism: PrismLib),
11-
theme
12-
};
13-
14-
export default defaultProps;
1+
// @flow
2+
3+
import Prism from "./vendor/prism";
4+
import theme from "./themes/duotoneDark";
5+
6+
import type { PrismLib } from "./types";
7+
8+
const defaultProps = {
9+
// $FlowFixMe
10+
Prism: (Prism: PrismLib),
11+
theme,
12+
};
13+
14+
export default defaultProps;

src/index.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
// @flow
2-
3-
import Prism from './vendor/prism'
4-
import defaultProps from './defaultProps'
5-
import Highlight from './components/Highlight'
6-
7-
export {
8-
Prism,
9-
defaultProps
10-
}
11-
12-
export default Highlight
1+
// @flow
2+
3+
import Prism from "./vendor/prism";
4+
import defaultProps from "./defaultProps";
5+
import Highlight from "./components/Highlight";
6+
7+
export { Prism, defaultProps };
8+
9+
export default Highlight;

src/types.js

Lines changed: 116 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,116 @@
1-
// @flow
2-
3-
import type { Key } from "react";
4-
import includedLangs from "./vendor/prism/includeLangs";
5-
6-
export type Language = $Keys<typeof includedLangs>;
7-
8-
type PrismGrammar = {
9-
[key: string]: mixed
10-
};
11-
12-
type LanguagesDict = {
13-
[lang: Language]: PrismGrammar
14-
};
15-
16-
export type PrismToken = {
17-
type: string | string[],
18-
alias: string | string[],
19-
content: Array<PrismToken | string> | string
20-
};
21-
22-
export type Token = {
23-
types: string[],
24-
content: string,
25-
empty?: boolean
26-
};
27-
28-
export type PrismLib = {
29-
languages: LanguagesDict,
30-
tokenize: (
31-
code: string,
32-
grammar: PrismGrammar,
33-
language: Language
34-
) => Array<PrismToken | string>,
35-
highlight: (code: string, grammar: PrismGrammar, language: Language) => string
36-
};
37-
38-
export type StyleObj = {
39-
[key: string]: string | number | null
40-
};
41-
42-
export type LineInputProps = {
43-
key?: Key,
44-
style?: StyleObj,
45-
className?: string,
46-
line: Token[],
47-
[key: string]: mixed
48-
};
49-
50-
export type LineOutputProps = {
51-
key?: Key,
52-
style?: StyleObj,
53-
className: string,
54-
[key: string]: mixed
55-
};
56-
57-
export type TokenInputProps = {
58-
key?: Key,
59-
style?: StyleObj,
60-
className?: string,
61-
token: Token,
62-
[key: string]: mixed
63-
};
64-
65-
export type TokenOutputProps = {
66-
key?: Key,
67-
style?: StyleObj,
68-
className: string,
69-
children: string,
70-
[key: string]: mixed
71-
};
72-
73-
export type RenderProps = {
74-
tokens: Token[][],
75-
className: string,
76-
getLineProps: (input: LineInputProps) => LineOutputProps,
77-
getTokenProps: (input: TokenInputProps) => TokenOutputProps
78-
};
79-
80-
export type PrismThemeEntry = {
81-
color?: string,
82-
backgroundColor?: string,
83-
fontStyle?: "normal" | "italic",
84-
fontWeight?:
85-
| "normal"
86-
| "bold"
87-
| "100"
88-
| "200"
89-
| "300"
90-
| "400"
91-
| "500"
92-
| "600"
93-
| "700"
94-
| "800"
95-
| "900",
96-
textDecorationLine?:
97-
| "none"
98-
| "underline"
99-
| "line-through"
100-
| "underline line-through",
101-
opacity?: number,
102-
[styleKey: string]: string | number | void
103-
};
104-
105-
export type PrismTheme = {
106-
plain: PrismThemeEntry,
107-
styles: Array<{
108-
types: string[],
109-
style: PrismThemeEntry,
110-
languages?: Language[]
111-
}>
112-
};
1+
// @flow
2+
3+
import type { Key } from "react";
4+
import includedLangs from "./vendor/prism/includeLangs";
5+
6+
export type Language = $Keys<typeof includedLangs>;
7+
8+
type PrismGrammar = {
9+
[key: string]: mixed,
10+
};
11+
12+
type LanguagesDict = {
13+
[lang: Language]: PrismGrammar,
14+
};
15+
16+
export type PrismToken = {
17+
type: string | string[],
18+
alias: string | string[],
19+
content: Array<PrismToken | string> | string,
20+
};
21+
22+
export type Token = {
23+
types: string[],
24+
content: string,
25+
empty?: boolean,
26+
};
27+
28+
export type PrismLib = {
29+
languages: LanguagesDict,
30+
tokenize: (
31+
code: string,
32+
grammar: PrismGrammar,
33+
language: Language
34+
) => Array<PrismToken | string>,
35+
highlight: (
36+
code: string,
37+
grammar: PrismGrammar,
38+
language: Language
39+
) => string,
40+
};
41+
42+
export type StyleObj = {
43+
[key: string]: string | number | null,
44+
};
45+
46+
export type LineInputProps = {
47+
key?: Key,
48+
style?: StyleObj,
49+
className?: string,
50+
line: Token[],
51+
[key: string]: mixed,
52+
};
53+
54+
export type LineOutputProps = {
55+
key?: Key,
56+
style?: StyleObj,
57+
className: string,
58+
[key: string]: mixed,
59+
};
60+
61+
export type TokenInputProps = {
62+
key?: Key,
63+
style?: StyleObj,
64+
className?: string,
65+
token: Token,
66+
[key: string]: mixed,
67+
};
68+
69+
export type TokenOutputProps = {
70+
key?: Key,
71+
style?: StyleObj,
72+
className: string,
73+
children: string,
74+
[key: string]: mixed,
75+
};
76+
77+
export type RenderProps = {
78+
tokens: Token[][],
79+
className: string,
80+
getLineProps: (input: LineInputProps) => LineOutputProps,
81+
getTokenProps: (input: TokenInputProps) => TokenOutputProps,
82+
};
83+
84+
export type PrismThemeEntry = {
85+
color?: string,
86+
backgroundColor?: string,
87+
fontStyle?: "normal" | "italic",
88+
fontWeight?:
89+
| "normal"
90+
| "bold"
91+
| "100"
92+
| "200"
93+
| "300"
94+
| "400"
95+
| "500"
96+
| "600"
97+
| "700"
98+
| "800"
99+
| "900",
100+
textDecorationLine?:
101+
| "none"
102+
| "underline"
103+
| "line-through"
104+
| "underline line-through",
105+
opacity?: number,
106+
[styleKey: string]: string | number | void,
107+
};
108+
109+
export type PrismTheme = {
110+
plain: PrismThemeEntry,
111+
styles: Array<{
112+
types: string[],
113+
style: PrismThemeEntry,
114+
languages?: Language[],
115+
}>,
116+
};

0 commit comments

Comments
 (0)