Skip to content

Commit

Permalink
feat: add eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuireu committed Dec 14, 2023
1 parent 6d2086e commit 890cff1
Show file tree
Hide file tree
Showing 11 changed files with 1,801 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
/scripts/*
yarn.lock
.eslintrc.cjs
59 changes: 59 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const tsconfig = require('./scripts/get-tsconfig.cjs');

module.exports = {
ignorePatterns: ['/scripts'],
env: {
browser: true,
es2023: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
],
overrides: [
{
files: tsconfig.include,
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
},
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
extends: [
'plugin:astro/recommended',
],
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
rules: {},
},
{
files: ['*.jsx', '*.tsx'],
extends: [
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
plugins: [
'react',
],
rules: {},
},
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
extraFileExtensions: ['.astro'],
project: './tsconfig.json',
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', {argsIgnorePattern: '^_'}],
'no-restricted-imports': ['error'],
},
};
Binary file modified .yarn/install-state.gz
Binary file not shown.
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
"preview": "astro preview",
"astro": "astro",
"prepare": "husky install",
"format": "prettier --write \"src/**/*.{ts,tsx}\" --config ./prettier.config.js",
"format:check": "prettier --check \"src/**/*.{ts,tsx}\" --config ./prettier.config.js"
"format": "prettier --write \"src/**/*.{ts,js.css}\" --config ./prettier.config.js",
"format:check": "yarn format --check",
"lint": "eslint $(git diff --name-only HEAD | grep -E '.(js|jsx|ts|tsx|astro)$' | xargs) --max-warnings=0",
"lint:typecheck": "tsc --project . --noEmit",
"lint:fix": "yarn lint --fix",
"lint:all": "eslint . --fix --max-warnings=0"
},
"dependencies": {
"@astrojs/mdx": "^2.0.0",
Expand All @@ -45,11 +49,19 @@
"gsap": "^3.12.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.20.1"
"react-router-dom": "^6.20.1",
"typescript": "^5.3.3"
},
"devDependencies": {
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/eslint": "^8",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"eslint": "^8.55.0",
"eslint-plugin-astro": "^0.30.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"prettier": "3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config = {
trailingComma: 'es5',
arrowParens: 'always',
proseWrap: 'always',
xmlWhitespaceSensitivity: 'ignore',
htmlWhitespaceSensitivity: 'ignore',
bracketSpacing: true,
};

Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
description: z.string(),
// Transform string to Date object
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
description: z.string(),
// Transform string to Date object
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});

export const collections = { blog };
20 changes: 10 additions & 10 deletions src/pages/rss.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';

export async function GET(context) {
const posts = await getCollection('blog');
return rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: context.site,
items: posts.map((post) => ({
...post.data,
link: `/blog/${post.slug}/`,
})),
});
const posts = await getCollection('blog');
return rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: context.site,
items: posts.map((post) => ({
...post.data,
link: `/blog/${post.slug}/`,
})),
});
}
1 change: 0 additions & 1 deletion src/ui/components/organisms/siteHead/SiteHead.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'src/ui/styles/index.css';
import '@fontsource/zilla-slab';
import '@fontsource-variable/literata';
import { ViewTransitions } from 'astro:transitions';
import { loadEnv } from 'vite';
interface Props {
title: string;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/components/templates/articleLayout/ArticleLayout.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
import './articleLayout.css';
import type { CollectionEntry } from 'astro:content';
//import type { CollectionEntry } from 'astro:content';
import Footer from '@components/organisms/footer/Footer.astro';
import SiteHead from '@components/organisms/siteHead/SiteHead.astro';
import Header from '@components/organisms/header/Header.astro';
type ArticleLayoutProps = CollectionEntry<'blog'>['data'];
// type ArticleLayoutProps = CollectionEntry<'blog'>['data'];
const { title, description, pubDate, updatedDate, heroImage } = Astro.props;
const { title, description, heroImage } = Astro.props;
---

<html lang="en">
Expand Down
Loading

0 comments on commit 890cff1

Please sign in to comment.