Skip to content

Commit

Permalink
Fix prettier glob to correctly navigate recursively and format missin…
Browse files Browse the repository at this point in the history
…g files (#107)
  • Loading branch information
manuelpuyol committed Feb 17, 2021
1 parent e2b0859 commit 89c194b
Show file tree
Hide file tree
Showing 9 changed files with 965 additions and 962 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -18,7 +18,7 @@
"build": "rollup -c rollup.config.js",
"test": "jest",
"flow": "flow check",
"format": "prettier --write src/**/*.js",
"format": "prettier --write 'src/**/*.js'",
"prepublishOnly": "run-p flow build"
},
"husky": {
Expand Down
28 changes: 14 additions & 14 deletions src/defaultProps.js
@@ -1,14 +1,14 @@
// @flow

import Prism from "./vendor/prism";
import theme from "./themes/duotoneDark";

import type { PrismLib } from "./types";

const defaultProps = {
// $FlowFixMe
Prism: (Prism: PrismLib),
theme
};

export default defaultProps;
// @flow

import Prism from "./vendor/prism";
import theme from "./themes/duotoneDark";

import type { PrismLib } from "./types";

const defaultProps = {
// $FlowFixMe
Prism: (Prism: PrismLib),
theme,
};

export default defaultProps;
21 changes: 9 additions & 12 deletions src/index.js
@@ -1,12 +1,9 @@
// @flow

import Prism from './vendor/prism'
import defaultProps from './defaultProps'
import Highlight from './components/Highlight'

export {
Prism,
defaultProps
}

export default Highlight
// @flow

import Prism from "./vendor/prism";
import defaultProps from "./defaultProps";
import Highlight from "./components/Highlight";

export { Prism, defaultProps };

export default Highlight;
228 changes: 116 additions & 112 deletions src/types.js
@@ -1,112 +1,116 @@
// @flow

import type { Key } from "react";
import includedLangs from "./vendor/prism/includeLangs";

export type Language = $Keys<typeof includedLangs>;

type PrismGrammar = {
[key: string]: mixed
};

type LanguagesDict = {
[lang: Language]: PrismGrammar
};

export type PrismToken = {
type: string | string[],
alias: string | string[],
content: Array<PrismToken | string> | string
};

export type Token = {
types: string[],
content: string,
empty?: boolean
};

export type PrismLib = {
languages: LanguagesDict,
tokenize: (
code: string,
grammar: PrismGrammar,
language: Language
) => Array<PrismToken | string>,
highlight: (code: string, grammar: PrismGrammar, language: Language) => string
};

export type StyleObj = {
[key: string]: string | number | null
};

export type LineInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
line: Token[],
[key: string]: mixed
};

export type LineOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
[key: string]: mixed
};

export type TokenInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
token: Token,
[key: string]: mixed
};

export type TokenOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
children: string,
[key: string]: mixed
};

export type RenderProps = {
tokens: Token[][],
className: string,
getLineProps: (input: LineInputProps) => LineOutputProps,
getTokenProps: (input: TokenInputProps) => TokenOutputProps
};

export type PrismThemeEntry = {
color?: string,
backgroundColor?: string,
fontStyle?: "normal" | "italic",
fontWeight?:
| "normal"
| "bold"
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "900",
textDecorationLine?:
| "none"
| "underline"
| "line-through"
| "underline line-through",
opacity?: number,
[styleKey: string]: string | number | void
};

export type PrismTheme = {
plain: PrismThemeEntry,
styles: Array<{
types: string[],
style: PrismThemeEntry,
languages?: Language[]
}>
};
// @flow

import type { Key } from "react";
import includedLangs from "./vendor/prism/includeLangs";

export type Language = $Keys<typeof includedLangs>;

type PrismGrammar = {
[key: string]: mixed,
};

type LanguagesDict = {
[lang: Language]: PrismGrammar,
};

export type PrismToken = {
type: string | string[],
alias: string | string[],
content: Array<PrismToken | string> | string,
};

export type Token = {
types: string[],
content: string,
empty?: boolean,
};

export type PrismLib = {
languages: LanguagesDict,
tokenize: (
code: string,
grammar: PrismGrammar,
language: Language
) => Array<PrismToken | string>,
highlight: (
code: string,
grammar: PrismGrammar,
language: Language
) => string,
};

export type StyleObj = {
[key: string]: string | number | null,
};

export type LineInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
line: Token[],
[key: string]: mixed,
};

export type LineOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
[key: string]: mixed,
};

export type TokenInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
token: Token,
[key: string]: mixed,
};

export type TokenOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
children: string,
[key: string]: mixed,
};

export type RenderProps = {
tokens: Token[][],
className: string,
getLineProps: (input: LineInputProps) => LineOutputProps,
getTokenProps: (input: TokenInputProps) => TokenOutputProps,
};

export type PrismThemeEntry = {
color?: string,
backgroundColor?: string,
fontStyle?: "normal" | "italic",
fontWeight?:
| "normal"
| "bold"
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "900",
textDecorationLine?:
| "none"
| "underline"
| "line-through"
| "underline line-through",
opacity?: number,
[styleKey: string]: string | number | void,
};

export type PrismTheme = {
plain: PrismThemeEntry,
styles: Array<{
types: string[],
style: PrismThemeEntry,
languages?: Language[],
}>,
};

0 comments on commit 89c194b

Please sign in to comment.