Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Add prettier, husky, lint-staged #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true
}
8 changes: 4 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "12" } }],
"@babel/preset-typescript",
"@babel/preset-react",
],
['@babel/preset-env', { targets: { node: '12' } }],
'@babel/preset-typescript',
'@babel/preset-react'
]
};
4 changes: 2 additions & 2 deletions example-site/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
typescript: {
ignoreBuildErrors: true,
},
ignoreBuildErrors: true
}
};
4 changes: 2 additions & 2 deletions example-site/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
autoprefixer: {}
}
};
6 changes: 3 additions & 3 deletions example-site/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AppProps } from "next/app";
import "../index.css";
import Head from "next/head";
import type { AppProps } from 'next/app';
import '../index.css';
import Head from 'next/head';

function MyApp({ Component, pageProps }: AppProps) {
return (
Expand Down
8 changes: 4 additions & 4 deletions example-site/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useMemo, useState } from "react";
import { parseMachinesFromFile } from "xstate-parser-demo";
import React, { useMemo, useState } from 'react';
import { parseMachinesFromFile } from 'xstate-parser-demo';

function App() {
const [text, setText] = useState(`createMachine({ initial: 'wow' })`);
const result = useMemo(() => {
try {
return parseMachinesFromFile(text).machines.map((machine) => {
return machine.toConfig() || "could not compile";
return machine.toConfig() || 'could not compile';
});
} catch (e) {
return "Could not parse";
return 'Could not parse';
}
}, [text]);

Expand Down
8 changes: 4 additions & 4 deletions example-site/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// tailwind.config.js
module.exports = {
purge: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
extend: {}
},
variants: {
extend: {},
extend: {}
},
plugins: [],
plugins: []
};
16 changes: 4 additions & 12 deletions example-site/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,10 +16,6 @@
"noEmit": true,
"jsx": "preserve"
},
"include": [
"./src"
],
"exclude": [
"node_modules"
]
}
"include": ["./src"],
"exclude": ["node_modules"]
}
26 changes: 13 additions & 13 deletions examples/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMachine, actions } from "xstate";
import { createMachine, actions } from 'xstate';

const {
after,
Expand All @@ -16,27 +16,27 @@ const {
sendParent,
sendUpdate,
start,
stop,
stop
} = actions;

export const machine = createMachine({
entry: [
after(400),
assign({}),
cancel(""),
done(""),
escalate(""),
forwardTo(""),
cancel(''),
done(''),
escalate(''),
forwardTo(''),
log(),
pure(() => {
return [];
}),
raise(""),
respond(""),
send(""),
sendParent(""),
raise(''),
respond(''),
send(''),
sendParent(''),
sendUpdate(),
start(""),
stop(""),
],
start(''),
stop('')
]
});
12 changes: 6 additions & 6 deletions examples/always.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
// - actions
// - XState (all XState exports)

import { assign, Machine } from "xstate";
import { assign, Machine } from 'xstate';

export const always = Machine({
initial: "checking",
initial: 'checking',
states: {
checking: {
always: {
target: "next",
},
target: 'next'
}
},
next: {},
},
next: {}
}
});
30 changes: 15 additions & 15 deletions examples/arraysAsTargets.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { createMachine } from "xstate";
import { createMachine } from 'xstate';

export const arraysAsTargets = createMachine({
type: "parallel",
type: 'parallel',
on: {
"*": [
'*': [
{
target: ["first.a", "second.b"],
target: ['first.a', 'second.b']
},
{
target: ["first.c", "second.a"],
},
],
target: ['first.c', 'second.a']
}
]
},
states: {
first: {
initial: "a",
initial: 'a',
states: {
a: {},
b: {},
c: {},
},
c: {}
}
},
second: {
initial: "a",
initial: 'a',
states: {
a: {},
b: {},
c: {},
},
},
},
c: {}
}
}
}
});
Loading