-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/portable-shebangs-in-scripts
- Loading branch information
Showing
20 changed files
with
483 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-t3-app": minor | ||
--- | ||
|
||
Include ESLlint rules for `drizzle-orm`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import path from "path"; | ||
import fs from "fs-extra"; | ||
|
||
import { _initialConfig } from "~/../template/extras/config/_eslint.js"; | ||
import { type Installer } from "~/installers/index.js"; | ||
|
||
export const dynamicEslintInstaller: Installer = ({ projectDir, packages }) => { | ||
const usingDrizzle = !!packages?.drizzle?.inUse; | ||
|
||
const eslintConfig = getEslintConfig({ usingDrizzle }); | ||
|
||
// Convert config from _eslint.config.json to .eslintrc.cjs | ||
const eslintrcFileContents = [ | ||
'/** @type {import("eslint").Linter.Config} */', | ||
`const config = ${JSON.stringify(eslintConfig, null, 2)}`, | ||
"module.exports = config;", | ||
].join("\n"); | ||
|
||
const eslintConfigDest = path.join(projectDir, ".eslintrc.cjs"); | ||
fs.writeFileSync(eslintConfigDest, eslintrcFileContents, "utf-8"); | ||
}; | ||
|
||
const getEslintConfig = ({ usingDrizzle }: { usingDrizzle: boolean }) => { | ||
const eslintConfig = _initialConfig; | ||
|
||
if (usingDrizzle) { | ||
eslintConfig.plugins = [...(eslintConfig.plugins ?? []), "drizzle"]; | ||
|
||
eslintConfig.rules = { | ||
...eslintConfig.rules, | ||
"drizzle/enforce-delete-with-where": "error", | ||
"drizzle/enforce-update-with-where": "error", | ||
}; | ||
} | ||
return eslintConfig; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 4 additions & 16 deletions
20
cli/template/base/_eslintrc.cjs → cli/template/extras/config/_eslint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,25 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
const config = { | ||
export const _initialConfig = { | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
}, | ||
parserOptions: { project: true }, | ||
plugins: ["@typescript-eslint"], | ||
extends: [ | ||
"next/core-web-vitals", | ||
"plugin:@typescript-eslint/recommended-type-checked", | ||
"plugin:@typescript-eslint/stylistic-type-checked", | ||
], | ||
rules: { | ||
// These opinionated rules are enabled in stylistic-type-checked above. | ||
// Feel free to reconfigure them to your own preference. | ||
"@typescript-eslint/array-type": "off", | ||
"@typescript-eslint/consistent-type-definitions": "off", | ||
|
||
"@typescript-eslint/consistent-type-imports": [ | ||
"warn", | ||
{ | ||
prefer: "type-imports", | ||
fixStyle: "inline-type-imports", | ||
}, | ||
{ prefer: "type-imports", fixStyle: "inline-type-imports" }, | ||
], | ||
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], | ||
"@typescript-eslint/require-await": "off", | ||
"@typescript-eslint/no-misused-promises": [ | ||
"error", | ||
{ | ||
checksVoidReturn: { attributes: false }, | ||
}, | ||
{ checksVoidReturn: { attributes: false } }, | ||
], | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.