diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 63e5ee34e..9b120751c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,6 +1,8 @@ /** @type {import("@types/eslint").Linter.Config} */ module.exports = { env: { + browser: true, + es2022: true, node: true, }, extends: [ @@ -11,6 +13,7 @@ module.exports = { "plugin:perfectionist/recommended-natural", "plugin:regexp/recommended", "plugin:typescript-sort-keys/recommended", + "plugin:deprecation/recommended", ], ignorePatterns: ["node_modules", "dist"], overrides: [ @@ -38,25 +41,21 @@ module.exports = { "plugin:@typescript-eslint/stylistic-type-checked", ], files: ["*.ts", "*.tsx"], - rules: { - "deprecation/deprecation": "error", - }, }, { - extends: ["plugin:markdown/recommended"], + extends: ["plugin:markdown/recommended-legacy"], files: ["**/*.md"], processor: "markdown/markdown", }, ], parser: "@typescript-eslint/parser", - plugins: [ - "@typescript-eslint", - "astro", - "deprecation", - "perfectionist", - "regexp", - "typescript-sort-keys", - ], + parserOptions: { + ecmaVersion: "latest", + project: true, + sourceType: "module", + tsconfigRootDir: __dirname, + }, + plugins: ["@typescript-eslint", "astro", "perfectionist", "regexp", "typescript-sort-keys"], root: true, rules: { "@typescript-eslint/no-unused-vars": [ diff --git a/.vscode/settings.json b/.vscode/settings.json index c8a9785eb..638d83547 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,7 @@ { - "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" + "source.fixAll": "explicit" }, "[markdown]": { "editor.wordWrap": "on" diff --git a/src/content/config.ts b/src/content/config.ts index 57f7bf8c5..478f8ffcf 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,4 +1,4 @@ -import { z, defineCollection } from "astro:content"; +import { defineCollection, z } from "astro:content"; function removeDupsAndLowerCase(array: string[]) { if (!array.length) return array; @@ -8,29 +8,29 @@ function removeDupsAndLowerCase(array: string[]) { } const post = defineCollection({ - type: "content", schema: ({ image }) => z.object({ - title: z.string().max(60), + coverImage: z + .object({ + alt: z.string(), + src: image(), + }) + .optional(), description: z.string().min(50).max(160), + draft: z.boolean().default(false), + ogImage: z.string().optional(), publishDate: z .string() .or(z.date()) .transform((val) => new Date(val)), + tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase), + title: z.string().max(60), updatedDate: z .string() .optional() .transform((str) => (str ? new Date(str) : undefined)), - coverImage: z - .object({ - src: image(), - alt: z.string(), - }) - .optional(), - draft: z.boolean().default(false), - tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase), - ogImage: z.string().optional(), }), + type: "content", }); export const collections = { post }; diff --git a/tsconfig.json b/tsconfig.json index 57dba57c1..ed1ea6076 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@/site-config": ["src/site.config.ts"] } }, + "include": ["./.eslintrc.cjs", "**/*"], "exclude": ["node_modules", "**/node_modules/*", ".vscode", "dist"] }