pnpm add -D prettier
.prettierrc.json
{
"singleQuote": true,
"jsxSingleQuote": true,
"semi": false,
"trailingComma": "all",
"printWidth": 100,
"proseWrap": "never",
"endOfLine": "lf"
}
.prettierignore
node_modules
build
dist
.vscode
pnpm add -D eslint eslint-config-airbnb-base eslint-config-prettier eslint-plugin-import eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks @typescript-eslint/eslint-plugin @typescript-eslint/parser
.eslintrc.json
{
"env": {
"browser": true,
"node": true
},
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended",
"plugin:react/jsx-runtime",
"plugin:import/typescript",
"prettier"
],
"plugins": ["react", "react-hooks", "@typescript-eslint", "import", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"no-console": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"prettier/prettier": ["error"],
"semi": "off",
"no-param-reassign": "off",
"import/extensions": "off",
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/consistent-type-imports": "error"
}
}
.eslintignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
build
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
pnpm add -D stylelint stylelint-config-prettier stylelint-config-standard stylelint-declaration-block-no-ignored-properties stylelint-order
.stylelintrc.json
{
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
"plugins": [
"stylelint-order",
"stylelint-declaration-block-no-ignored-properties"
],
"rules": {
"plugin/declaration-block-no-ignored-properties": true,
"order/order": ["custom-properties", "declarations"],
"order/properties-order": [
"overflow",
"overflow-x",
"overflow-y",
"clip",
"clear",
"position",
"top",
"right",
"bottom",
"left",
"z-index",
"display",
"float",
"width",
"height",
"max-width",
"max-height",
"min-width",
"min-height",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"margin-collapse",
"margin-top-collapse",
"margin-right-collapse",
"margin-bottom-collapse",
"margin-left-collapse",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"background",
"background-color",
"border",
"border-radius",
"color",
"font",
"font-family",
"font-size",
"font-smoothing",
"osx-font-smoothing",
"font-style",
"font-weight",
"line-height",
"letter-spacing",
"word-spacing",
"text-align",
"text-decoration",
"text-indent",
"text-overflow",
"text-rendering",
"text-size-adjust",
"text-shadow",
"text-transform",
"word-break",
"word-wrap",
"white-space",
"vertical-align",
"list-style",
"list-style-type",
"list-style-position",
"list-style-image",
"content",
"outline",
"outline-offset",
"filter",
"visibility",
"size",
"opacity",
"transform",
"cursor",
"pointer-events"
],
"at-rule-no-unknown": null,
},
"ignoreFiles": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "**/*.json"]
}
pnpm add -D sass stylelint-scss postcss-scss postcss
{
"plugins": [
"stylelint-scss",
"stylelint-order",
"stylelint-declaration-block-no-ignored-properties"
],
"overrides": [
{
"files": ["*.scss", "**/*.scss"],
"customSyntax": "postcss-scss"
}
],
"rules": {
"scss/at-rule-no-unknown": null,
"selector-class-pattern": null
}
}
yarn add husky lint-staged
激活hooks
npx husky install
在scripts中添加
"prepare": "husky install"
yarn add @commitlint/cli @commitlint/config-conventional
新建commitlint.config.js
module.exports = {
extends: ["@commitlint/config-conventional"],
};
命令式创建
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
注册Hooks
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit $1'
Copyright © Chenyz的知识星球🌍 2025.豫ICP备2024045759号