From d844d0b55a8489d17621056c61a0dfe54014d2ca Mon Sep 17 00:00:00 2001 From: Frad LEE Date: Thu, 2 Mar 2023 10:09:32 +0800 Subject: [PATCH] feat(yarn): split configs, update prettier config --- .prettierignore | 2 ++ eslint.config.js | 6 ++++++ package.json | 29 ++--------------------------- prettier.config.js | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 .prettierignore create mode 100644 eslint.config.js create mode 100644 prettier.config.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b9ed905 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +**/.next +**/.vscode \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..fe060a7 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,6 @@ +module.exports = { + extends: ['next', 'next/core-web-vitals'], + rules: { + '@next/next/no-img-element': 'off', + }, +} diff --git a/package.json b/package.json index c019a0e..f6216e4 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "build": "next build", "start": "next start", "lint": "next lint", + "format": "prettier --write \"**/*.{js,ts,tsx,md,mdx,json}\"", "release": "release-it" }, "dependencies": { @@ -39,6 +40,7 @@ }, "devDependencies": { "@release-it/conventional-changelog": "^5.1.1", + "@serverless-guru/prettier-plugin-import-order": "^0.4.1", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", "@types/react": "^18.0.26", @@ -55,32 +57,5 @@ "release-it": "^15.6.0", "tailwindcss": "^3.2.4", "typescript": "^4.9.4" - }, - "prettier": { - "parser": "typescript", - "tabWidth": 2, - "singleQuote": true, - "printWidth": 80, - "semi": true, - "overrides": [ - { - "files": ["*.json"], - "options": { - "parser": "json" - } - }, - { - "files": ["*.mdx"], - "options": { - "parser": "mdx" - } - } - ] - }, - "eslintConfig": { - "extends": ["next", "next/core-web-vitals"], - "rules": { - "@next/next/no-img-element": "off" - } } } diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..6b70943 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,39 @@ +module.exports = { + parser: 'typescript', + arrowParens: 'always', + singleQuote: true, + tabWidth: 2, + printWidth: 80, + semi: false, + overrides: [ + { + files: ['*.json'], + options: { + parser: 'json', + }, + }, + { + files: ['*.md', '*.mdx'], + options: { + parser: 'markdown', + }, + }, + ], + importOrder: [ + '^react$', + '^next$', + '^@next$', + '', + '^[./]', + '^@/pages/(.*)$', + '^@/components/(.*)$', + '^@/utils/(.*)$', + '^@/styles/(.*)$', + ], + importOrderSeparation: true, + importOrderTypeImportsToBottom: true, + plugins: [ + require('prettier-plugin-tailwindcss'), + require('@serverless-guru/prettier-plugin-import-order'), + ], +}