Skip to content

Commit

Permalink
Merge pull request #252 from chrismwilliams/eslint-config
Browse files Browse the repository at this point in the history
fix for markdown lib change
  • Loading branch information
chrismwilliams authored Apr 12, 2024
2 parents eaf1ac8 + dcc4f63 commit 7c46c0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
23 changes: 11 additions & 12 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @type {import("@types/eslint").Linter.Config} */
module.exports = {
env: {
browser: true,
es2022: true,
node: true,
},
extends: [
Expand All @@ -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: [
Expand Down Expand Up @@ -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": [
Expand Down
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
24 changes: 12 additions & 12 deletions src/content/config.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 };
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"@/site-config": ["src/site.config.ts"]
}
},
"include": ["./.eslintrc.cjs", "**/*"],
"exclude": ["node_modules", "**/node_modules/*", ".vscode", "dist"]
}

0 comments on commit 7c46c0e

Please sign in to comment.