Skip to content

Commit

Permalink
Merge pull request #38 from andrewiggins/jsconfig
Browse files Browse the repository at this point in the history
Add jsconfig.json files for each workspace
  • Loading branch information
andrewiggins committed Oct 16, 2023
2 parents 5cf1bf3 + f0341c5 commit 5986f72
Show file tree
Hide file tree
Showing 58 changed files with 1,313 additions and 2,709 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
run: npm run build
- name: test
run: npm test
- run: npm run tsc
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion frameworks/bundleHelpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require("path");
const { readdirSync, existsSync } = require("fs");
const nodeResolve = require("@rollup/plugin-node-resolve").default;
const terser = require("@rollup/plugin-terser");
const { default: terser } = require("@rollup/plugin-terser");
const visualizer = require("rollup-plugin-visualizer").default;

const frameworkOutput = (...args) =>
Expand Down
4 changes: 4 additions & 0 deletions frameworks/lit-html/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../jsconfig.json",
"exclude": ["node_modules", "dist"]
}
3 changes: 2 additions & 1 deletion frameworks/lit-html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p ./jsconfig.json --noEmit"
},
"dependencies": {
"lit-html": "^1.3.0"
Expand Down
2 changes: 1 addition & 1 deletion frameworks/lit-html/src/7GUIs-flight-booker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function update(tripType, departing, returning) {
returningError = "Returning date must be on or after departing date.";
}

const isBookDisabled = departingError || returningError;
const isBookDisabled = Boolean(departingError || returningError);

const setTripType = newTripType => update(newTripType, departing, returning);
const setDeparting = newDate => update(tripType, newDate, returning);
Expand Down
4 changes: 2 additions & 2 deletions frameworks/lit-html/src/7GUIs-temp-converter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const TempConverter = (c, f, setBothFromC, setBothFromF) => html`
const container = document.getElementById("app");

function update(c, f) {
/** @param {Event} e */
/** @param {Event & {target: HTMLInputElement}} e */
function setBothFromC(e) {
c = e.target.value;
f = +(32 + (9 / 5) * c).toFixed(1);
update(c, f);
}

/** @param {Event} e */
/** @param {Event & {target: HTMLInputElement}} e */
function setBothFromF(e) {
f = e.target.value;
c = +((5 / 9) * (f - 32)).toFixed(1);
Expand Down
10 changes: 10 additions & 0 deletions frameworks/preact-hooks/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../jsconfig.json",
"compilerOptions": {
"jsx": "react",
"jsxFactory": "createElement",
"jsxFragmentFactory": "Fragment"
},
"exclude": ["node_modules", "dist"],
"include": ["./**/*"]
}
3 changes: 2 additions & 1 deletion frameworks/preact-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p jsconfig.json --noEmit"
},
"dependencies": {
"preact": "^10.5.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function DateEntry({
class="form-input"
type="text"
value={date}
onInput={e => setDate(e.target.value)}
onInput={e => setDate(e.currentTarget.value)}
disabled={disabled}
/>
{errorMsg && <p class="form-input-hint">{errorMsg}</p>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function TripType({ tripType, setTripType }) {
id="trip-type"
class="form-select"
value={tripType}
onInput={e => setTripType(e.target.value)}
onInput={e => setTripType(e.currentTarget.value)}
>
<option value={oneWayFlight}>one-way flight</option>
<option value={returnFlight}>return flight</option>
Expand Down
4 changes: 2 additions & 2 deletions frameworks/preact-hooks/src/7GUIs-temp-converter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function App() {
<>
<input
value={c}
onInput={e => setBothFromC(e.target.value)}
onInput={e => setBothFromC(e.currentTarget.value)}
type="number"
/>{" "}
°c ={" "}
<input
value={f}
onInput={e => setBothFromF(e.target.value)}
onInput={e => setBothFromF(e.currentTarget.value)}
type="number"
/>{" "}
°f
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact-hooks/src/7GUIs-timer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function App() {
min="1"
max="20000"
value={duration}
onInput={e => setDuration(e.target.value)}
onInput={e => setDuration(e.currentTarget.valueAsNumber)}
/>
</label>
<div>
Expand Down
10 changes: 10 additions & 0 deletions frameworks/preact/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../jsconfig.json",
"compilerOptions": {
"jsx": "react",
"jsxFactory": "createElement",
"jsxFragmentFactory": "Fragment"
},
"exclude": ["node_modules", "dist"],
"include": ["./**/*"]
}
3 changes: 2 additions & 1 deletion frameworks/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p jsconfig.json --noEmit"
},
"dependencies": {
"preact": "^10.5.7"
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-CRUD/FilterInput.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createElement } from "preact";

/**
* @param {{ value: string; onInput: (e: InputEvent) => void; }} props
* @param {{ value: string; onInput: preact.JSX.GenericEventHandler<HTMLInputElement>; }} props
*/
export function FilterInput({ value, onInput }) {
return (
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-CRUD/NameInput.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createElement } from "preact";

/**
* @param {{ id: string; value: string; onInput: (e: InputEvent) => void; label: string; required?: boolean; }} props
* @param {{ id: string; value: string; onInput: preact.JSX.GenericEventHandler<HTMLInputElement>; label: string; required?: boolean; }} props
*/
export function NameInput({ id, value, onInput, label, required = false }) {
// TODO: Show error message if required == true but value == ""
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-CRUD/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Loading() {
}

/**
* @typedef {{ id: number; name: string; surname: string; }} Person
* @typedef {import('lib/crud').Person} Person
* @typedef { "initial" | "create" | "update" | "delete" | null } LoadingState;
* @typedef {{ filter: string; name: string; surname: string; selectedPersonId: number; persons: Person[]; loading: LoadingState; }} State
* @returns {State}
Expand Down
3 changes: 2 additions & 1 deletion frameworks/preact/src/7GUIs-CRUD/util.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
* @param {import('./index').Person} person
* @param {import('lib/crud').Person} person
*/
export function getDisplayName(person) {
return `${person.surname}, ${person.name}`;
}

/** @type {import('lib/crud').Person} */
export const EMPTY_PERSON = Object.freeze({
id: null,
name: "",
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-flight-booker/DateEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function DateEntry({
class="form-input"
type="text"
value={date}
onInput={e => setDate(e.target.value)}
onInput={e => setDate(e.currentTarget.value)}
disabled={disabled}
/>
{errorMsg && <p class="form-input-hint">{errorMsg}</p>}
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-flight-booker/TripType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function TripType({ tripType, setTripType }) {
id="trip-type"
class="form-select"
value={tripType}
onInput={e => setTripType(e.target.value)}
onInput={e => setTripType(e.currentTarget.value)}
>
<option value={oneWayFlight}>one-way flight</option>
<option value={returnFlight}>return flight</option>
Expand Down
4 changes: 2 additions & 2 deletions frameworks/preact/src/7GUIs-temp-converter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class App extends Component {
<>
<input
value={state.c}
onInput={e => this.setBothFromC(e.target.value)}
onInput={e => this.setBothFromC(e.currentTarget.value)}
type="number"
/>{" "}
°c ={" "}
<input
value={state.f}
onInput={e => this.setBothFromF(e.target.value)}
onInput={e => this.setBothFromF(e.currentTarget.value)}
type="number"
/>{" "}
°f
Expand Down
2 changes: 1 addition & 1 deletion frameworks/preact/src/7GUIs-timer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class App extends Component {
min="1"
max="20000"
value={state.duration}
onInput={e => this.setState({ duration: e.target.value })}
onInput={e => this.setState({ duration: e.currentTarget.value })}
/>
</label>
<div>
Expand Down
10 changes: 10 additions & 0 deletions frameworks/react-hooks/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../jsconfig.json",
"compilerOptions": {
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment"
},
"exclude": ["node_modules", "dist"],
"include": ["./**/*"]
}
7 changes: 5 additions & 2 deletions frameworks/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p jsconfig.json --noEmit"
},
"dependencies": {
"react": "^17.0.1",
Expand All @@ -17,6 +18,8 @@
"@babel/preset-react": "^7.12.10",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-commonjs": "25.0.0",
"@rollup/plugin-replace": "5.0.0"
"@rollup/plugin-replace": "5.0.0",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13"
}
}
15 changes: 13 additions & 2 deletions frameworks/react-hooks/src/7GUIs-temp-converter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ function App() {
const [f, setF] = useState("");
const [c, setC] = useState("");

// React doesn't support `valueAsNumber` on controlled inputs, so we have to
// manually do some formatting here.
//
// First format to have one fraction digit. Then convert back to number so
// we drop any unnecessary ".0" from the end of whole numbers. Finally
// convert back to string since that is the type our state expects. Our
// state is a string so the inputs can start with an empty state instead of
// a number.

function setBothFromC(value) {
const newC = +(32 + (9 / 5) * value).toFixed(1);
setC(value);
setF(+(32 + (9 / 5) * value).toFixed(1));
setF("" + newC);
}

function setBothFromF(value) {
const newF = +((5 / 9) * (value - 32)).toFixed(1);
setF(value);
setC(+((5 / 9) * (value - 32)).toFixed(1));
setC("" + newF);
}

return (
Expand Down
2 changes: 1 addition & 1 deletion frameworks/react-hooks/src/7GUIs-timer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function App() {
min="1"
max="20000"
value={duration}
onChange={e => setDuration(e.target.value)}
onChange={e => setDuration(e.currentTarget.valueAsNumber)}
/>
</label>
<div>
Expand Down
10 changes: 10 additions & 0 deletions frameworks/react/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../jsconfig.json",
"compilerOptions": {
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment"
},
"exclude": ["node_modules", "dist"],
"include": ["./**/*"]
}
7 changes: 5 additions & 2 deletions frameworks/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p jsconfig.json --noEmit"
},
"dependencies": {
"react": "^17.0.1",
Expand All @@ -17,6 +18,8 @@
"@babel/preset-react": "^7.12.10",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-commonjs": "25.0.0",
"@rollup/plugin-replace": "5.0.0"
"@rollup/plugin-replace": "5.0.0",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13"
}
}
4 changes: 2 additions & 2 deletions frameworks/react/src/7GUIs-temp-converter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class App extends React.Component {
<>
<input
value={this.state.c}
onInput={e => this.setBothFromC(e.target.value)}
onInput={e => this.setBothFromC(e.currentTarget.value)}
type="number"
/>{" "}
°c ={" "}
<input
value={this.state.f}
onInput={e => this.setBothFromF(e.target.value)}
onInput={e => this.setBothFromF(e.currentTarget.value)}
type="number"
/>{" "}
°f
Expand Down
4 changes: 4 additions & 0 deletions frameworks/svelte/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../jsconfig.json",
"exclude": ["node_modules", "dist"]
}
3 changes: 2 additions & 1 deletion frameworks/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js --watch"
"watch": "rollup -c rollup.config.js --watch",
"tsc": "tsc -p ./jsconfig.json --noEmit"
},
"dependencies": {
"svelte": "^3.31.0"
Expand Down
3 changes: 2 additions & 1 deletion frameworks/svelte/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const babel = require("@rollup/plugin-babel").default;
const { generateConfigs } = require("../bundleHelpers");

const plugins = () => [
// @ts-expect-error Bad mixing of COMMONJS and ESM
svelte({
extensions: [".html"]
}),
babel({
babelHelpers: "bundled",
extensions: DEFAULT_EXTENSIONS.concat([".html"])
extensions: [...DEFAULT_EXTENSIONS, ".html", ".svelte"]
})
];

Expand Down
2 changes: 1 addition & 1 deletion frameworks/svelte/src/7GUIs-counter/Counter.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<button
class="btn badge"
data-badge="{count}"
style="margin-top: 0.5rem;"
style="margin-top: 0.5rem"
on:click="{() => count += 1}"
>
count: {count}
Expand Down
5 changes: 5 additions & 0 deletions frameworks/svelte/svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "*.html" {
import { ComponentType } from "svelte";
const App: ComponentType;
export default App;
}
4 changes: 4 additions & 0 deletions frameworks/vue/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../jsconfig.json",
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 5986f72

Please sign in to comment.