From a091d746fa6a0b31e8820608d4e0320870db8af3 Mon Sep 17 00:00:00 2001 From: Alan Lu Date: Sat, 2 Mar 2024 04:53:50 +0800 Subject: [PATCH 1/5] chore: initialize project with code style tools --- .commitlintrc.cjs | 70 + .editorconfig | 25 + .gitignore | 25 + .husky/commit-msg | 1 + .husky/pre-commit | 1 + .lintstagedrc.cjs | 7 + .markdownlint-cli2.cjs | 1 + .npmrc | 5 + .nvmrc | 1 + .prettierignore | 31 + .prettierrc.cjs | 1 + .vscode/extensions.json | 3 + .vscode/settings.json | 47 + README.md | 39 + apps/nuxt/nuxt-demo/README.md | 75 + apps/nuxt/nuxt-demo/app.vue | 5 + apps/nuxt/nuxt-demo/nuxt.config.ts | 4 + apps/nuxt/nuxt-demo/package.json | 20 + apps/nuxt/nuxt-demo/public/favicon.ico | Bin 0 -> 4286 bytes apps/nuxt/nuxt-demo/server/tsconfig.json | 3 + apps/nuxt/nuxt-demo/tsconfig.json | 4 + eslint.config.cjs | 3 + package.json | 41 + packages/linters/eslint-config/index.cjs | 70 + packages/linters/eslint-config/package.json | 28 + .../linters/markdownlint-config/index.cjs | 14 + .../linters/markdownlint-config/package.json | 25 + packages/linters/prettier-config/index.cjs | 46 + packages/linters/prettier-config/package.json | 25 + pnpm-lock.yaml | 9201 +++++++++++++++++ pnpm-workspace.yaml | 3 + 31 files changed, 9824 insertions(+) create mode 100644 .commitlintrc.cjs create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc.cjs create mode 100644 .markdownlint-cli2.cjs create mode 100644 .npmrc create mode 100644 .nvmrc create mode 100644 .prettierignore create mode 100644 .prettierrc.cjs create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 apps/nuxt/nuxt-demo/README.md create mode 100644 apps/nuxt/nuxt-demo/app.vue create mode 100644 apps/nuxt/nuxt-demo/nuxt.config.ts create mode 100644 apps/nuxt/nuxt-demo/package.json create mode 100644 apps/nuxt/nuxt-demo/public/favicon.ico create mode 100644 apps/nuxt/nuxt-demo/server/tsconfig.json create mode 100644 apps/nuxt/nuxt-demo/tsconfig.json create mode 100644 eslint.config.cjs create mode 100644 package.json create mode 100644 packages/linters/eslint-config/index.cjs create mode 100644 packages/linters/eslint-config/package.json create mode 100644 packages/linters/markdownlint-config/index.cjs create mode 100644 packages/linters/markdownlint-config/package.json create mode 100644 packages/linters/prettier-config/index.cjs create mode 100644 packages/linters/prettier-config/package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml diff --git a/.commitlintrc.cjs b/.commitlintrc.cjs new file mode 100644 index 0000000..0913b4b --- /dev/null +++ b/.commitlintrc.cjs @@ -0,0 +1,70 @@ +/** @type {import('czg').UserConfig} */ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + // @see: https://commitlint.js.org/#/reference-rules + // 'scope-enum': [2, 'always', scopes], + }, + prompt: { + alias: { fd: 'docs: fix typos' }, + messages: { + type: `Select the type of change that you're committing:`, + scope: 'Denote the SCOPE of this change (optional):', + customScope: 'Denote the SCOPE of this change:', + subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', + body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', + breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', + footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):', + customFooterPrefix: 'Input ISSUES prefix:', + footer: 'List any ISSUES by this change. E.g.: #31, #34:\n', + generatingByAI: 'Generating your AI commit subject...', + generatedSelectByAI: 'Select suitable subject by AI generated:', + confirmCommit: 'Are you sure you want to proceed with the commit above?', + }, + types: [ + { value: 'feat', name: 'feat: AASD new feature', emoji: ':sparkles:' }, + { value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' }, + { value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' }, + { value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' }, + { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' }, + { value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' }, + { value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' }, + { value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' }, + { value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' }, + { value: 'chore', name: `chore: Other changes that don't modify src or test files`, emoji: ':hammer:' }, + { value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' }, + ], + useEmoji: false, + emojiAlign: 'center', + useAI: false, + aiNumber: 1, + themeColorCode: '', + scopes: [], + allowCustomScopes: true, + allowEmptyScopes: true, + customScopesAlign: 'bottom', + customScopesAlias: 'custom', + emptyScopesAlias: 'empty', + upperCaseSubject: false, + markBreakingChangeMode: false, + allowBreakingChanges: ['feat', 'fix'], + breaklineNumber: 100, + breaklineChar: '|', + skipQuestions: [], + issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }], + customIssuePrefixAlign: 'top', + emptyIssuePrefixAlias: 'skip', + customIssuePrefixAlias: 'custom', + allowCustomIssuePrefix: true, + allowEmptyIssuePrefix: true, + confirmColorize: true, + maxHeaderLength: Number.POSITIVE_INFINITY, + maxSubjectLength: Number.POSITIVE_INFINITY, + minSubjectLength: 0, + scopeOverrides: undefined, + defaultBody: '', + defaultIssues: '', + defaultScope: '', + defaultSubject: '', + }, +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..91da475 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,25 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Matches all files +[*] +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +indent_style = space +indent_size = 2 + +[Makefile] +indent_style = tab + +[*.{yaml,yml,conf}] +indent_size = 2 + +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc7cb7b --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Dependencies +node_modules + +# Build files +.output +.nuxt +.nitro +.cache +.virtual +.turbo +dist + +# Logs +logs +.log + +# Miscellaneous +.DS_Store +.fleet +.idea + +# Local environment files +.env +.env.* +!.env.example diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..cfe7510 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +pnpm commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..cb2c84d --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm lint-staged diff --git a/.lintstagedrc.cjs b/.lintstagedrc.cjs new file mode 100644 index 0000000..721c6d5 --- /dev/null +++ b/.lintstagedrc.cjs @@ -0,0 +1,7 @@ +module.exports = { + '*.json': ['eslint --fix', 'prettier --write'], + '*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'], + '*.vue': ['eslint --fix', 'prettier --write'], + '*.{css,scss,postcss,less,html}': ['eslint --fix', 'prettier --write'], + '*.{md,mdx}': ['markdownlint-cli2 --fix'], +} diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs new file mode 100644 index 0000000..63e1915 --- /dev/null +++ b/.markdownlint-cli2.cjs @@ -0,0 +1 @@ +module.exports = require('@alanlu-dev/markdownlint-config') diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..ee1c54f --- /dev/null +++ b/.npmrc @@ -0,0 +1,5 @@ +auto-install-peers=true +public-hoist-pattern[]=*types* +public-hoist-pattern[]=*eslint* +public-hoist-pattern[]=*prettier* +public-hoist-pattern[]=*markdownlint* diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..ee09fac --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20.11.1 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..efc2e4d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,31 @@ +# Dependencies +**/node_modules + +# Build files +**/.output +**/.nuxt +**/.nitro +**/.cache +**/.virtual +**/.turbo +**/dist + +# Logs +**/logs +**/*.log + +# Miscellaneous +**/.DS_Store +**/.fleet +**/.idea +pnpm-lock.yaml + +# Local environment files +**/.env +**/.env.* +**/!.env.example + +# Markdown files +**/*.md +**/*.mdx + diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 0000000..dd5bf28 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require('@alanlu-dev/prettier-config') diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..e5eec64 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["EditorConfig.EditorConfig", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "DavidAnson.vscode-markdownlint"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e563d7d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,47 @@ +{ + // "prettier.enable": false, // Disable the default formatter, use eslint instead + "editor.defaultFormatter": "esbenp.prettier-vscode", + + "editor.formatOnPaste": false, // required + "editor.formatOnType": false, // required + "editor.formatOnSave": false, // optional, if you use ESlint,this should be false + "editor.formatOnSaveMode": "file", // required to format on save + + "editor.quickSuggestions": { + "strings": true + }, + + "editor.codeActionsOnSave": { + "source.organizeImports": "never", + "source.fixAll": "never", + "source.fixAll.eslint": "explicit", + "source.fixAll.stylelint": "explicit", + "source.fixAll.markdownlint": "explicit" + }, + + // Enable the ESlint flat config support + "eslint.experimental.useFlatConfig": true, + "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "html", "markdown", "json", "jsonc", "yaml", "toml"], + "eslint.rules.customizations": [ + { "rule": "style/*", "severity": "off" }, + { "rule": "format/*", "severity": "off" }, + { "rule": "*-indent", "severity": "off" }, + { "rule": "*-spacing", "severity": "off" }, + { "rule": "*-spaces", "severity": "off" }, + { "rule": "*-order", "severity": "off" }, + { "rule": "*-dangle", "severity": "off" }, + { "rule": "*-newline", "severity": "off" }, + { "rule": "*quotes", "severity": "off" }, + { "rule": "*semi", "severity": "off" } + ], + + "stylelint.enable": true, + "stylelint.validate": ["css", "less", "postcss", "sass", "scss", "vue", "html"], + "css.validate": false, + "less.validate": false, + "scss.validate": false, + + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d57597 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# @alanlu-dev/web-kit + +這套開發模板是一個全方位且易於操作的基礎架構,旨在提升開發效率及確保程式碼風格的統一。它整合了以下幾款主要工具與套件,以優化開發流程: + +* **EditorConfig**:透過維護一致的編輯器設定,EditorConfig 幫助團隊成員在不同的編輯器和 IDE 中保持一致的編碼風格。 + +* **ESLint**:這是一款廣受歡迎的 JavaScript 及 JSX 程式碼檢查工具,能夠協助開發者發現並修正程式碼中的錯誤,保障程式碼質量。 + +* **Prettier**:作為一款程式碼格式化工具,Prettier 能自動整理程式碼格式,確保整個團隊的程式碼風格保持一致。 + +* **Markdownlint**:這是一款專門用於維護 Markdown 文件風格一致性的工具,幫助你遵循最佳寫作實踐。 + +* **Commitlint**:這款工具幫助你規範 git commit 訊息的格式,促進團隊間溝通的效率和清晰度。 + +* **Husky**:Husky 允許你利用 git hooks 在執行 git commit 和 git push 命令前自動進行程式碼檢查和測試,提高代碼質量。 + +* **Lint-staged**:Lint-staged 能夠在 git commit 前自動檢查暫存的程式碼變更,確保只有通過檢查的程式碼才能被提交。 + +## 快速開始 + +若要開始使用這套模板,請按照以下步驟操作: + +1. **克隆倉庫** + + 首先,使用以下命令克隆這個倉庫到本地: + + ```bash + git clone https://github.com/alanlu-dev/web-kit.git + ``` + +2. **安裝依賴** + + 接著,進入項目目錄並執行以下命令安裝所需的依賴: + + ```bash + pnpm install + ``` + +透過這套模板,你可以快速搭建起一個具有良好程式碼風格與質量保障的開發環境。 diff --git a/apps/nuxt/nuxt-demo/README.md b/apps/nuxt/nuxt-demo/README.md new file mode 100644 index 0000000..f5db2a2 --- /dev/null +++ b/apps/nuxt/nuxt-demo/README.md @@ -0,0 +1,75 @@ +# Nuxt 3 Minimal Starter + +Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. + +## Setup + +Make sure to install the dependencies: + +```bash +# npm +npm install + +# pnpm +pnpm install + +# yarn +yarn install + +# bun +bun install +``` + +## Development Server + +Start the development server on `http://localhost:3000`: + +```bash +# npm +npm run dev + +# pnpm +pnpm run dev + +# yarn +yarn dev + +# bun +bun run dev +``` + +## Production + +Build the application for production: + +```bash +# npm +npm run build + +# pnpm +pnpm run build + +# yarn +yarn build + +# bun +bun run build +``` + +Locally preview production build: + +```bash +# npm +npm run preview + +# pnpm +pnpm run preview + +# yarn +yarn preview + +# bun +bun run preview +``` + +Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. diff --git a/apps/nuxt/nuxt-demo/app.vue b/apps/nuxt/nuxt-demo/app.vue new file mode 100644 index 0000000..a495b75 --- /dev/null +++ b/apps/nuxt/nuxt-demo/app.vue @@ -0,0 +1,5 @@ + diff --git a/apps/nuxt/nuxt-demo/nuxt.config.ts b/apps/nuxt/nuxt-demo/nuxt.config.ts new file mode 100644 index 0000000..9d825c4 --- /dev/null +++ b/apps/nuxt/nuxt-demo/nuxt.config.ts @@ -0,0 +1,4 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + devtools: { enabled: true }, +}) diff --git a/apps/nuxt/nuxt-demo/package.json b/apps/nuxt/nuxt-demo/package.json new file mode 100644 index 0000000..30f6022 --- /dev/null +++ b/apps/nuxt/nuxt-demo/package.json @@ -0,0 +1,20 @@ +{ + "name": "@alanlu-dev/nuxt-demo", + "private": true, + "type": "module", + "scripts": { + "build": "nuxt build", + "dev": "nuxt dev", + "generate": "nuxt generate", + "preview": "nuxt preview", + "postinstall": "nuxt prepare", + "lint:eslint": "eslint --fix .", + "lint:prettier": "prettier --ignore-path ../../../.prettierignore . --write", + "lint": "pnpm lint:eslint && pnpm lint:prettier" + }, + "dependencies": { + "nuxt": "^3.10.3", + "vue": "^3.4.21", + "vue-router": "^4.3.0" + } +} diff --git a/apps/nuxt/nuxt-demo/public/favicon.ico b/apps/nuxt/nuxt-demo/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..18993ad91cfd43e03b074dd0b5cc3f37ab38e49c GIT binary patch literal 4286 zcmeHLOKuuL5PjK%MHWVi6lD zOGiREbCw`xmFozJ^aNatJY>w+g ze6a2@u~m#^BZm@8wco9#Crlli0uLb^3E$t2-WIc^#(?t)*@`UpuofJ(Uyh@F>b3Ph z$D^m8Xq~pTkGJ4Q`Q2)te3mgkWYZ^Ijq|hkiP^9`De={bQQ%heZC$QU2UpP(-tbl8 zPWD2abEew;oat@w`uP3J^YpsgT%~jT(Dk%oU}sa$7|n6hBjDj`+I;RX(>)%lm_7N{+B7Mu%H?422lE%MBJH!!YTN2oT7xr>>N-8OF$C&qU^ z>vLsa{$0X%q1fjOe3P1mCv#lN{xQ4_*HCSAZjTb1`}mlc+9rl8$B3OP%VT@mch_~G z7Y+4b{r>9e=M+7vSI;BgB?ryZDY4m>&wcHSn81VH1N~`0gvwH{ z8dv#hG|OK`>1;j7tM#B)Z7zDN?{6=dUal}$e (https://github.com/alanlu-zyl)", + "bugs": { + "url": "https://github.com/alanlu-dev/web-kit/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/alanlu-dev/web-kit.git" + }, + "license": "MIT", + "description": "A monorepo starter template", + "packageManager": "pnpm@8.15.4", + "engines": { + "node": ">=20.11.0", + "pnpm": ">=8.15.4", + "npm": "use pnpm please!", + "yarn": "use pnpm please!" + }, + "scripts": { + "prepare": "husky", + "modules:clean": "npx rimraf --glob ./**/node_modules && rm -rf pnpm-lock.yaml", + "pnpm:clean": "pnpm store prune", + "commit": "czg", + "nuxt-demo": "pnpm --filter=@alanlu-dev/nuxt-demo" + }, + "devDependencies": { + "@alanlu-dev/eslint-config": "workspace:*", + "@alanlu-dev/markdownlint-config": "workspace:*", + "@alanlu-dev/prettier-config": "workspace:*", + "@commitlint/cli": "^19.0.3", + "@commitlint/config-conventional": "^19.0.3", + "czg": "^1.9.0", + "eslint": "^8.57.0", + "husky": "^9.0.11", + "lint-staged": "^15.2.2", + "markdownlint-cli2": "^0.12.1", + "prettier": "^3.2.5" + } +} diff --git a/packages/linters/eslint-config/index.cjs b/packages/linters/eslint-config/index.cjs new file mode 100644 index 0000000..9df94a8 --- /dev/null +++ b/packages/linters/eslint-config/index.cjs @@ -0,0 +1,70 @@ +const antfu = require('@antfu/eslint-config').default +const { FlatCompat } = require('@eslint/eslintrc') + +const compat = new FlatCompat() +module.exports = antfu( + { + // Enable stylistic formatting rules + // stylistic: true, + + // TypeScript and Vue are auto-detected, you can also explicitly enable them: + typescript: true, + // typescript: { + // tsconfigPath: "tsconfig.json", + // }, + vue: true, + + // To enable React support, you need to explicitly turn it on: + // react: true, + + // Disable jsonc and yaml support + jsonc: false, + yaml: false, + + // `.eslintignore` is no longer supported in Flat config, use `ignores` instead + ignores: ['**/node_modules', '**/.output', '**/.nuxt', '**/.nitro', '**/.cache', '**/cache', '**/.virtual', '**/.turbo', '**/dist'], + }, + + // Legacy config + ...compat.config({ + extends: ['plugin:prettier/recommended'], + + plugins: ['markdown', 'mdx'], + rules: { + 'no-console': 'off', + }, + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + overrides: [ + { + // Enable the Markdown processor for all .md files. + files: ['*.md'], + processor: 'markdown/markdown', + }, + { + // Optionally, customize the configuration ESLint uses for ```js + // fenced code blocks inside .md files. + files: ['**/*.md/*.js', '**/*.md/*.ts'], + rules: { + '@stylistic/js/no-multi-spaces': 'off', + }, + }, + // 添加 MDX 支持 + { + files: ['*.mdx'], // 目標 MDX 檔案 + extends: ['plugin:mdx/recommended'], + }, + { + files: ['**/*.mdx/*.js', '**/*.mdx/*.ts'], + rules: { + // 這裡可以根據需要定制 MDX 中的 JS/TS 代碼塊的 lint 規則 + }, + }, + ], + }), + + // Other flat configs... +) diff --git a/packages/linters/eslint-config/package.json b/packages/linters/eslint-config/package.json new file mode 100644 index 0000000..b75cdf3 --- /dev/null +++ b/packages/linters/eslint-config/package.json @@ -0,0 +1,28 @@ +{ + "name": "@alanlu-dev/eslint-config", + "version": "0.0.0", + "author": "Alan Lu (https://github.com/alanlu-zyl)", + "bugs": { + "url": "https://github.com/alanlu-dev/web-kit/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/alanlu-dev/web-kit.git", + "directory": "packages/linters/eslint-config" + }, + "license": "MIT", + "description": "ESLint configuration", + "main": "index.cjs", + "scripts": { + "lint:eslint": "eslint . --fix", + "lint:prettier": "prettier --ignore-path ../../../.prettierignore . --write", + "lint": "pnpm lint:eslint && pnpm lint:prettier" + }, + "devDependencies": { + "@antfu/eslint-config": "^2.7.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-markdown": "^3.0.1", + "eslint-plugin-mdx": "^3.1.5", + "eslint-plugin-prettier": "^5.1.3" + } +} diff --git a/packages/linters/markdownlint-config/index.cjs b/packages/linters/markdownlint-config/index.cjs new file mode 100644 index 0000000..44a7c90 --- /dev/null +++ b/packages/linters/markdownlint-config/index.cjs @@ -0,0 +1,14 @@ +const options = require('@github/markdownlint-github').init({ + // Custom overrides + 'MD013': false, + 'no-generic-link-text': false, +}) + +module.exports = { + config: options, + customRules: ['@github/markdownlint-github'], + // outputFormatters: [ + // ['markdownlint-cli2-formatter-pretty', { appendLink: true }], // ensures the error message includes a link to the rule documentation + // ], + ignores: ['node_modules/**', 'public/**', 'dist/**', '.changeset/**', '**/CHANGELOG.md'], +} diff --git a/packages/linters/markdownlint-config/package.json b/packages/linters/markdownlint-config/package.json new file mode 100644 index 0000000..b21d7d1 --- /dev/null +++ b/packages/linters/markdownlint-config/package.json @@ -0,0 +1,25 @@ +{ + "name": "@alanlu-dev/markdownlint-config", + "version": "0.0.0", + "author": "Alan Lu (https://github.com/alanlu-zyl)", + "bugs": { + "url": "https://github.com/alanlu-dev/web-kit/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/alanlu-dev/web-kit.git", + "directory": "packages/linters/markdownlint-config" + }, + "license": "MIT", + "description": "Markdownlint configuration", + "main": "index.cjs", + "scripts": { + "lint:eslint": "eslint . --fix", + "lint:prettier": "prettier --ignore-path ../../../.prettierignore . --write", + "lint": "pnpm lint:eslint && pnpm lint:prettier" + }, + "devDependencies": { + "@github/markdownlint-github": "^0.6.0", + "markdownlint-cli2-formatter-pretty": "^0.0.5" + } +} diff --git a/packages/linters/prettier-config/index.cjs b/packages/linters/prettier-config/index.cjs new file mode 100644 index 0000000..71c9285 --- /dev/null +++ b/packages/linters/prettier-config/index.cjs @@ -0,0 +1,46 @@ +module.exports = { + plugins: ['prettier-plugin-brace-style'], + braceStyle: 'stroustrup', + + // Use curious ternaries, with the question mark after the condition + experimentalTernaries: false, + + // 每行最多字元數量,超出換行(默認80) + printWidth: 200, + // 縮排空格數量,默認2個空格 + tabWidth: 2, + // 指定縮排方式,空格或tab,默認false,即使用空格 + useTabs: false, + // 結尾添加分號,默認true + semi: false, + // 使用單引號,默認false + singleQuote: true, + // 物件屬性是否使用引號(as-needed | consistent | preserve;默認as-needed:物件的屬性需要加引號才添加) + quoteProps: 'consistent', + // 在 JSX 中使用單引號替代雙引號,默認false + jsxSingleQuote: true, + // 元素末尾是否加上逗號,默認all + trailingComma: 'all', + // 物件字面量的括號之間是否加上空格(true - 範例: { foo: bar } ; false - 範例: {foo:bar}) + bracketSpacing: true, + // 開始標籤的右尖括號是否跟隨在最後一行屬性末尾,默認為false + bracketSameLine: false, + // 單個參數箭頭函式是否要使用小括號(always:始終顯示;avoid:省略括號。默認:always) + arrowParens: 'always', + // 是否只格式化包含特定註解(@prettier| @format)的檔案,默認false + requirePragma: false, + // 當檔案已經被 Prettier 格式化之後,是否在檔案頂部插入一個特殊的 @format 標記,默認false + insertPragma: false, + // 超出打印寬度 (always | never | preserve ) + proseWrap: 'preserve', + // 指定 HTML 檔案的空格敏感度 (css|strict|ignore;默認css) + htmlWhitespaceSensitivity: 'strict', + // Vue 檔案中是否縮排