Skip to content

Commit

Permalink
style: prettier organize imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZL-Asica committed Oct 22, 2024
1 parent 496f054 commit b929a25
Show file tree
Hide file tree
Showing 26 changed files with 206 additions and 71 deletions.
19 changes: 18 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": ["next/core-web-vitals", "next/typescript", "prettier"],
"plugins": ["import"],
"rules": {
// Possible Errors
"no-console": "warn", // Warn on console usage (can change to 'error' to disallow)
Expand Down Expand Up @@ -32,6 +33,22 @@
"arrow-spacing": ["error", { "before": true, "after": true }], // Enforce spacing around arrows
"prefer-const": "error", // Prefer const for variables that are never reassigned
"no-var": "error", // Disallow var (use let or const instead)
"template-curly-spacing": ["error", "never"] // Disallow spaces inside template literals
"template-curly-spacing": ["error", "never"], // Disallow spaces inside template literals

// Import
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}
]
}
}
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"quoteProps": "as-needed",
"htmlWhitespaceSensitivity": "css",
"embeddedLanguageFormatting": "auto",
"plugins": ["prettier-plugin-tailwindcss"]
"plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-organize-imports"]
}
73 changes: 73 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends('next/core-web-vitals', 'next/typescript', 'prettier'),
{
rules: {
'no-console': 'warn',
'no-debugger': 'error',
'no-extra-semi': 'error',
'no-irregular-whitespace': 'error',
curly: 'error',
eqeqeq: ['error', 'always'],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-throw-literal': 'error',
'no-unused-expressions': 'error',
'no-undef': 'error',

'no-unused-vars': [
'warn',
{
vars: 'all',
args: 'none',
},
],

camelcase: [
'error',
{
properties: 'never',
},
],

'comma-dangle': ['error', 'always-multiline'],

quotes: [
'error',
'single',
{
avoidEscape: true,
},
],

semi: ['error', 'always'],
indent: ['error', 2],
'eol-last': ['error', 'always'],
'no-trailing-spaces': 'error',

'arrow-spacing': [
'error',
{
before: true,
after: true,
},
],

'prefer-const': 'error',
'no-var': 'error',
'template-curly-spacing': ['error', 'never'],
},
},
];
39 changes: 39 additions & 0 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"yaml": "^2.6.0"
},
"devDependencies": {
"@eslint/compat": "^1.2.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@tailwindcss/typography": "^0.5.15",
"@types/node": "^22.7.7",
"@types/react": "npm:[email protected]",
Expand All @@ -34,6 +37,7 @@
"lint-staged": "^15.2.10",
"postcss": "^8",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-tailwindcss": "^0.6.8",
"tailwindcss": "^3.4.1",
"typescript": "^5.6.0"
Expand Down
4 changes: 2 additions & 2 deletions src/app/about/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { Metadata } from 'next';
import { getConfig } from '@/services/config/getConfig';
import type { Metadata } from 'next';
import React from 'react';

const config = getConfig();

Expand Down
4 changes: 2 additions & 2 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getPostData } from '@/services/content/posts';
import { PostData } from '@/types';
import PostLayout from '@/components/layout/PostLayout';
import { getConfig } from '@/services/config/getConfig';
import { getPostData } from '@/services/content/posts';
import { PostData } from '@/types';

export default async function AboutPage() {
const post: PostData = await getPostData('About', 'About');
Expand Down
4 changes: 2 additions & 2 deletions src/app/categories/[categorySlug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAllPosts } from '@/services/content/posts';
import PostListLayout from '@/components/layout/PostListLayout';
import { getConfig } from '@/services/config/getConfig';
import { getAllPosts } from '@/services/content/posts';
import { notFound } from 'next/navigation';
import PostListLayout from '@/components/layout/PostListLayout';

export async function generateStaticParams() {
const config = getConfig();
Expand Down
4 changes: 2 additions & 2 deletions src/app/friends/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { Metadata } from 'next';
import { getConfig } from '@/services/config/getConfig';
import type { Metadata } from 'next';
import React from 'react';

const config = getConfig();

Expand Down
4 changes: 2 additions & 2 deletions src/app/friends/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getPostData } from '@/services/content/posts';
import { PostData } from '@/types';
import PostLayout from '@/components/layout/PostLayout';
import { getConfig } from '@/services/config/getConfig';
import { getPostData } from '@/services/content/posts';
import '@/styles/friendsLinks.css';
import { PostData } from '@/types';

export default async function FriendsPage() {
const post: PostData = await getPostData('Friends', 'Friends');
Expand Down
14 changes: 7 additions & 7 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import type { Metadata } from 'next';
// eslint-disable-next-line camelcase
import { Roboto, Noto_Sans_SC } from 'next/font/google';
import './globals.css';
import ThemeProvider from '@/components/layout/ThemeProvider';
import Header from '@/components/common/Header';
import Footer from '@/components/common/Footer';
import Header from '@/components/common/Header';
import ThemeProvider from '@/components/layout/ThemeProvider';
import { getConfig } from '@/services/config/getConfig';
import type { Metadata } from 'next';
import React from 'react';
// eslint-disable-next-line camelcase
import { Noto_Sans_SC, Roboto } from 'next/font/google';
import Script from 'next/script';
import './globals.css';

const config = getConfig();

Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getConfig } from '@/services/config/getConfig';
import Image from 'next/image';
import PostsPage from './posts/page';
import { getConfig } from '@/services/config/getConfig';

export default function Home() {
const config = getConfig();
Expand Down
2 changes: 1 addition & 1 deletion src/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PostLayout from '@/components/layout/PostLayout';
import { getPostData } from '@/services/content/posts';
import { PostData } from '@/types';
import PostLayout from '@/components/layout/PostLayout';

interface PostPageProps {
params: Promise<{
Expand Down
4 changes: 2 additions & 2 deletions src/app/posts/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { Metadata } from 'next';
import { getConfig } from '@/services/config/getConfig';
import type { Metadata } from 'next';
import React from 'react';

const config = getConfig();

Expand Down
4 changes: 2 additions & 2 deletions src/app/tags/[tagSlug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PostListLayout from '@/components/layout/PostListLayout';
import { getAllPosts } from '@/services/content/posts';
import { convertToPinyin, getUniqueTags } from '@/services/parsing/tagLinks';
import { notFound } from 'next/navigation';
import PostListLayout from '@/components/layout/PostListLayout';
import { getUniqueTags, convertToPinyin } from '@/services/parsing/tagLinks';

// Generate static paths for all unique tags
export async function generateStaticParams() {
Expand Down
14 changes: 7 additions & 7 deletions src/components/common/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { getConfig } from '@/services/config/getConfig';
import Link from 'next/link';
import {
FaBilibili,
FaGithub,
FaLinkedinIn,
FaInstagram,
FaXTwitter,
FaBilibili,
FaYoutube,
FaLinkedinIn,
FaRss,
FaTelegram,
FaXTwitter,
FaYoutube,
} from 'react-icons/fa6';
import { SiZhihu } from 'react-icons/si';
import { MdEmail } from 'react-icons/md';
import { getConfig } from '@/services/config/getConfig';
import Link from 'next/link';
import { SiZhihu } from 'react-icons/si';

export default function Footer() {
const config = getConfig();
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';

import React, { useEffect, useRef, useState } from 'react';
import Link from 'next/link';
import { FaBars, FaAngleUp } from 'react-icons/fa6';
import { Category } from '@/types';
import renderMenuItems from '@/components/common/MenuItems';
import '@/styles/header.css';
import { Category } from '@/types';
import Link from 'next/link';
import { useEffect, useRef, useState } from 'react';
import { FaAngleUp, FaBars } from 'react-icons/fa6';

export default function Header({
siteTitle,
Expand Down
10 changes: 5 additions & 5 deletions src/components/common/MenuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Category } from '@/types';
import Link from 'next/link';
import React from 'react';
import * as Fa6 from 'react-icons/fa6';
import {
FaHouse,
FaRegNewspaper,
FaPeopleGroup,
FaInfo,
FaPeopleGroup,
FaRegNewspaper,
} from 'react-icons/fa6';
import * as Fa6 from 'react-icons/fa6';
import Link from 'next/link';
import { Category } from '@/types';

interface DropdownItem {
href: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/CategoryLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link';
import { getConfig } from '@/services/config/getConfig';
import Link from 'next/link';

export default function CategoryLinks({
categories,
Expand Down
Loading

0 comments on commit b929a25

Please sign in to comment.