访问卷星是一个支持拖拽自定义问卷的低代码项目,从问卷编辑到发布,再到答卷统计,完成业务的闭环。
shellnpx create-react-app react-questionnaire --template typescript
shellnpm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
shellnpx eslint --init


shellnpm install prettier eslint-config-prettier eslint-plugin-prettier --save-dev
.prettierrc.jsjsmodule.exports = {
// 箭头函数只有一个参数的时候可以忽略括号
arrowParens: 'avoid',
// 括号内部不要出现空格
bracketSpacing: true,
// 行结束符使用 Unix 格式
endOfLine: 'lf',
// true: Put > on the last line instead of at a new line
jsxBracketSameLine: false,
// 行宽
printWidth: 100,
// 换行方式
proseWrap: 'preserve',
// 分号
semi: false,
// 使用单引号
singleQuote: true,
// 缩进
tabWidth: 2,
// 使用 tab 缩进
useTabs: false,
// 后置逗号,多行对象、数组在最后一行增加逗号
trailingComma: 'es5',
parser: 'typescript',
}
注意事项: 防止配置信息冲突,最好重启vscode
在package.json script添加以下指令代码
shell"format": "prettier --write 'src/**/*.+(js|ts|jsx|tsx)'"
给vscode添加当前工程的配置信息
在项目根目录下新建文件夹.vscode 并在其下新建配置文件settings.json,配置信息如下
json{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
shellnpm install husky -D
shellnpm pkg set scripts.prepare="husky install" npm run prepare
shellnpx husky add .husky/pre-commit "npm run lint" npx husky add .husky/pre-commit "npm run format" npx husky add .husky/pre-commit "git add ."
shell# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-conventional,cli}
# For Windows:
npm install --save-dev @commitlint/config-conventional @commitlint/cli
# Configure commitlint to use conventional config
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
shellnpx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'


本文作者:千寻
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!