Skip to content

Commit

Permalink
fix: bind configs to variables before exporting to make sure typeerro…
Browse files Browse the repository at this point in the history
…rs are reported (t3-oss#1232)

* bind configs

* Create odd-spies-appear.md

* Update .changeset/odd-spies-appear.md

---------

Co-authored-by: Christopher Ehrlich <[email protected]>
  • Loading branch information
juliusmarminge and c-ehrlich authored Feb 27, 2023
1 parent 9ef6171 commit 9c82f86
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-spies-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: bind configs to variables before exporting to make sure typeerrors are reported
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
const config = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["isaacscript", "import"],
Expand Down Expand Up @@ -45,3 +45,5 @@ module.exports = {
"isaacscript/format-jsdoc-comments": "warn",
},
};

module.exports = config;
4 changes: 3 additions & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('prettier').Config} */
module.exports = {
const config = {
arrowParens: "always",
printWidth: 80,
singleQuote: false,
Expand All @@ -8,3 +8,5 @@ module.exports = {
trailingComma: "all",
tabWidth: 2,
};

module.exports = config;
4 changes: 3 additions & 1 deletion cli/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @type {import('prettier').Config} */
module.exports = {
const config = {
...require("../.prettierrc.cjs"),
plugins: [require.resolve("prettier-plugin-tailwindcss")],
tailwindConfig: "./template/extras/config/tailwind.config.cjs",
};

module.exports = config;
4 changes: 3 additions & 1 deletion cli/template/base/_eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
const config = {
overrides: [
{
extends: [
Expand Down Expand Up @@ -27,3 +27,5 @@ module.exports = {
],
},
};

module.exports = config;
14 changes: 7 additions & 7 deletions cli/template/base/src/env.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { z } from "zod";

/**
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
* Specify your server-side environment variables schema here. This way you can ensure the app isn't
* built with invalid env vars.
*/
const server = z.object({
NODE_ENV: z.enum(["development", "test", "production"]),
});

/**
* Specify your client-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
* To expose them to the client, prefix them with `NEXT_PUBLIC_`.
* Specify your client-side environment variables schema here. This way you can ensure the app isn't
* built with invalid env vars. To expose them to the client, prefix them with `NEXT_PUBLIC_`.
*/
const client = z.object({
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
});

/**
* You can't destruct `process.env` as a regular object in the Next.js
* edge runtimes (e.g. middlewares) or client-side so we need to destruct manually.
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*
* @type {Record<keyof z.infer<typeof server> | keyof z.infer<typeof client>, string | undefined>}
*/
const processEnv = {
Expand Down
4 changes: 3 additions & 1 deletion cli/template/extras/config/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
const config = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

module.exports = config;
4 changes: 3 additions & 1 deletion cli/template/extras/config/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import("prettier").Config} */
module.exports = {
const config = {
plugins: [require.resolve("prettier-plugin-tailwindcss")],
};

module.exports = config;
4 changes: 3 additions & 1 deletion cli/template/extras/config/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
const config = {
content: ["./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};

module.exports = config;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@manypkg/cli": "^0.20.0",
"@types/eslint": "^8.21.1",
"@types/node": "^18.14.0",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.34.0",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion www/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
const config = {
parserOptions: {
extraFileExtensions: [".astro"],
},
};

module.exports = config;
4 changes: 3 additions & 1 deletion www/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('prettier').Config} */
module.exports = {
const config = {
...require("../.prettierrc.cjs"),
plugins: [
require.resolve("prettier-plugin-astro"),
Expand All @@ -17,3 +17,5 @@ module.exports = {
astroAllowShorthand: false,
tailwindConfig: "./tailwind.config.cjs",
};

module.exports = config;
4 changes: 3 additions & 1 deletion www/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
const config = {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
darkMode: "class",
theme: {
Expand Down Expand Up @@ -68,3 +68,5 @@ module.exports = {
// eslint-disable-next-line @typescript-eslint/no-var-requires
plugins: [require("tailwind-scrollbar")({ nocompatible: true })],
};

module.exports = config;

0 comments on commit 9c82f86

Please sign in to comment.