├── play
├── src
│ ├── components
│ │ ├── name.vue
│ │ └── HelloWorld.vue
│ ├── assets
│ │ └── logo.png
│ ├── main.js
│ └── App.vue
├── README.md
├── public
│ ├── favicon.ico
│ └── index.html
├── .eslintignore
├── .husky
│ ├── pre-commit
│ └── commit-msg
├── babel.config.js
├── .prettierrc
├── .gitignore
├── package.json
├── commitlint.config.js
├── commitlint.config copy.js
└── .eslintrc.js
├── index.ts
├── .eslintignore
├── src
├── static
│ ├── eslint.png
│ ├── loading.png
│ ├── Jun-20-2022-1.gif
│ └── Jun-20-2022-2.gif
├── utils
│ ├── path.ts
│ ├── check.ts
│ ├── debug.ts
│ ├── env.ts
│ └── tool.ts
├── templet
│ ├── prettierrc.ts
│ ├── commitlint-no-emoji.config.ts
│ ├── commitlint.config.ts
│ └── eslintrc.ts
├── core
│ ├── eslintignore.ts
│ ├── special.ts
│ ├── husky.ts
│ ├── commitlint.ts
│ ├── vscode.ts
│ └── eslint.ts
├── especial.ts
├── cli.ts
└── start.ts
├── .husky
├── pre-commit
└── commit-msg
├── .prettierrc
├── .gitignore
├── .github
└── workflows
│ └── nodejs.yml
├── .cz-config.js
├── .history
├── README_20221113004239.md
├── README_20230208145450.md
├── README_20230208145459.md
├── README_20230208145501.md
├── README_20230208145543.md
└── README_20230208145548.md
├── README.md
├── package.json
├── commitlint.config.js
├── tsconfig.json
├── .eslintrc.js
└── .eslintcache
/play/src/components/name.vue:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/play/README.md:
--------------------------------------------------------------------------------
1 | ## 测试使用的项目
2 |
--------------------------------------------------------------------------------
/index.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import cliInit from './src/cli';
3 | cliInit();
4 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 |
2 | .prettierrc
3 | !commitlint.config.js
4 | .babel.config.js
5 | !.umirc.ts
6 |
--------------------------------------------------------------------------------
/play/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/play/public/favicon.ico
--------------------------------------------------------------------------------
/src/static/eslint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/src/static/eslint.png
--------------------------------------------------------------------------------
/src/static/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/src/static/loading.png
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 | npm run pre-commit
4 |
--------------------------------------------------------------------------------
/play/.eslintignore:
--------------------------------------------------------------------------------
1 |
2 | .eslintrc.js
3 | .prettierrc
4 | commitlint.config.js
5 | .babel.config.js
6 |
--------------------------------------------------------------------------------
/play/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/play/src/assets/logo.png
--------------------------------------------------------------------------------
/src/static/Jun-20-2022-1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/src/static/Jun-20-2022-1.gif
--------------------------------------------------------------------------------
/src/static/Jun-20-2022-2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyh0371/web-norm/HEAD/src/static/Jun-20-2022-2.gif
--------------------------------------------------------------------------------
/play/.husky/pre-commit:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env sh
3 | . "$(dirname -- "$0")/_/husky.sh"
4 | npm run pre-commit
5 |
--------------------------------------------------------------------------------
/play/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no-install commitlint --edit $1
5 |
--------------------------------------------------------------------------------
/play/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no-install commitlint --edit $1
5 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "semi": false,
4 | "singleQuote": true,
5 | "printWidth": 180,
6 | "tabWidth": 2,
7 | "trailingComma": "none"
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/play/.prettierrc:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "semi": false,
4 | "singleQuote": true,
5 | "printWidth": 180,
6 | "tabWidth": 2,
7 | "trailingComma": "none"
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/play/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 |
4 | Vue.config.productionTip = false
5 |
6 | new Vue({
7 | render: h => h(App),
8 | }).$mount('#app')
9 |
--------------------------------------------------------------------------------
/src/utils/path.ts:
--------------------------------------------------------------------------------
1 | import { getEnv } from './env'
2 | import path from 'path'
3 | export const getpath = (name: string) => {
4 | const basePath = getEnv('base') as string
5 | return path.resolve(basePath, name)
6 | }
7 |
--------------------------------------------------------------------------------
/src/templet/prettierrc.ts:
--------------------------------------------------------------------------------
1 | export const prettierrcInit = `
2 | {
3 | "semi": false,
4 | "singleQuote": true,
5 | "printWidth": 100,
6 | "tabWidth": 2,
7 | "trailingComma": "none"
8 | }
9 |
10 | `
11 |
--------------------------------------------------------------------------------
/play/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/src/core/eslintignore.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * husk 结合 commitlint 提交信息校验
3 | */
4 | import fs from 'fs-extra';
5 | import { getpath } from '../utils/path';
6 |
7 | const eslintignore = `
8 | .prettierrc
9 | !commitlint.config.js
10 | .babel.config.js
11 | !.umirc.ts
12 | `;
13 | export const eslintignoreInit = async () => {
14 | fs.outputFileSync(getpath('.eslintignore'), eslintignore);
15 | };
16 |
--------------------------------------------------------------------------------
/src/especial.ts:
--------------------------------------------------------------------------------
1 | export const teepEslintConfig = {
2 | rules: {
3 | 'no-console': ['error', { allow: ['warn', 'error'] }],
4 | 'no-nested-ternary': ['error'],
5 | 'max-lines': [
6 | 'error',
7 | {
8 | max: 1500,
9 | skipBlankLines: true,
10 | skipComments: true
11 | }
12 | ],
13 | complexity: ['error', 15],
14 | eqeqeq: 2
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .progress-estimator
2 | # Logs
3 | logs
4 | *.log
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 |
9 | node_modules
10 | play/node_modules/
11 | .DS_Store
12 | dist
13 | dist-ssr
14 | coverage
15 | *.local
16 |
17 | /cypress/videos/
18 | /cypress/screenshots/
19 |
20 | # Editor directories and files
21 | .vscode/*
22 | !.vscode/extensions.json
23 | .idea
24 | *.suo
25 | *.ntvs*
26 | *.njsproj
27 | *.sln
28 | *.sw?
29 |
--------------------------------------------------------------------------------
/src/core/special.ts:
--------------------------------------------------------------------------------
1 | // 一些特殊的处理
2 | import fs from 'fs-extra';
3 | import { env, getPackageJson } from '../utils/env';
4 | import { getpath } from '../utils/path';
5 | export const specialFn = async () => {
6 | const { isVue3 } = env;
7 | if (!isVue3) return;
8 | let pkgJson = await getPackageJson();
9 | if (pkgJson.type) {
10 | delete pkgJson.type;
11 | }
12 | fs.writeJsonSync(getpath('package.json'), pkgJson, { spaces: 2 });
13 | // 如果是vue3 的话 需要把package中的 type="module"去掉
14 | };
15 |
--------------------------------------------------------------------------------
/play/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | For a guide and recipes on how to configure / customize this project,
6 | check out the
7 | vue-cli documentation.
8 |
60 |
61 | ## 支持配置
62 |
63 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
64 |
65 | ```sh
66 | "scripts": {
67 | "web-norm": "web-norm --noEmoji",
68 | },
69 | ```
70 |
71 |
72 | ## 验证
73 |
74 | 代码提交前校验
75 |
76 | ```sh
77 | npm run commit
78 | ```
79 |
80 |
81 |
82 | ## 在老项目中使用
83 |
84 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
85 |
86 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
87 |
88 |
89 |
90 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
91 |
92 |
93 |
94 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
95 |
96 | - husky 无法触发
97 |
98 | 1. 项目首先需要被 `git` 管理
99 |
100 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
101 |
102 |
103 | ## 说明
104 |
105 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
106 |
107 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
108 |
--------------------------------------------------------------------------------
/src/utils/env.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import fs from 'fs-extra'
3 | import { checkVueVersion } from './check'
4 | export const env = {
5 | base: '',
6 | isVue: false,
7 | isVue3: false,
8 | isReact: false,
9 | isVue2: false,
10 | isVueCli: false,
11 | isWebpack: true,
12 | isEslint: false,
13 | especial: false,
14 | merge: false, // 是否覆盖原有eslint 默认覆盖
15 | isZh: true, // 中英文
16 | simple: false, // 是否是简单模式 默认是否
17 | noEmoji: false // 是否不要表情 默认是要
18 | }
19 |
20 | type envKeys = keyof typeof env
21 |
22 | /**
23 | * @name 设置变量
24 | */
25 | export const setEnv = (key: envKeys, val: any) => {
26 | env[key] = val as never
27 | }
28 | /**
29 | * @name 获取变量
30 | */
31 | export const getEnv = (key: envKeys) => {
32 | return env[key]
33 | }
34 |
35 | /**
36 | * @name 检测是否包含指定文件
37 | *
38 | */
39 |
40 | export const existsSync = (fileName: string, base: string = getEnv('base') as string) => {
41 | const file = path.resolve(base, fileName)
42 | return fs.existsSync(file)
43 | }
44 |
45 | /**
46 | * @name 获取指定文件,并转化为json
47 | *
48 | */
49 |
50 | export const getFiletoJson = async (fileName: string, base: string = getEnv('base') as string) => {
51 | const file = path.resolve(base, fileName)
52 | const res = fs.existsSync(file)
53 | if (!res) return false
54 | const json = fs.readJSON(file)
55 | return json
56 | }
57 | /**
58 | * @name 把package.json转化为json
59 | */
60 | export const getPackageJson = async (base: string = getEnv('base') as string) => {
61 | return getFiletoJson('package.json', base)
62 | }
63 |
64 | /**
65 | * @name 获取eslintrc
66 | */
67 | export const getEslintrc = async (base: string = getEnv('base') as string) => {
68 | const file = path.resolve(base, '.eslintrc.js')
69 | const res = fs.existsSync(file)
70 | if (!res) return false
71 | const eslintStr = await fs.readFile(file, 'utf8')
72 | return eval(eslintStr)
73 | }
74 |
75 | export const initProjectInfo = async (pckJson: any) => {
76 | const deps = { ...pckJson.devDependencies, ...pckJson.dependencies }
77 | if (deps['vue']) {
78 | setEnv('isVue', true)
79 | if (checkVueVersion(deps['vue']) === 2) {
80 | setEnv('isVue2', true)
81 | }
82 | if (checkVueVersion(deps['vue']) === 3) {
83 | setEnv('isVue3', true)
84 | }
85 | }
86 |
87 | if (deps['react']) {
88 | setEnv('isReact', true)
89 | }
90 |
91 | if (deps['eslint']) {
92 | setEnv('isEslint', true)
93 | }
94 | return true
95 | }
96 |
--------------------------------------------------------------------------------
/src/core/vscode.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * vscode 配置
3 | */
4 | import fs from 'fs-extra';
5 | import { getpath } from '../utils/path';
6 |
7 | export const vscodeInit = async () => {
8 | const haveVscodeSetting = await fs.pathExists(getpath('./vscode/settings.json'));
9 |
10 | let vscodeSetting = {};
11 | if (!haveVscodeSetting) {
12 | vscodeSetting = {
13 | // 每次保存自动格式化
14 | 'editor.formatOnSave': true,
15 | // 每次保存的时候将代码按eslint格式进行修复
16 | 'editor.codeActionsOnSave': {
17 | 'source.fixAll.eslint': true,
18 | },
19 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
20 | // vue文件默认格式化方式vetur
21 | '[vue]': {
22 | // "editor.defaultFormatter": "octref.vetur"
23 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
24 | },
25 |
26 | 'javascript.format.insertSpaceBeforeFunctionParenthesis': true, // 函数前加上空格 只有在默认vetur的时候生效
27 | // js文件默认格式化方式 和vue中的js保持一致使用编辑器自带的ts格式
28 | '[javascript]': {
29 | // "editor.defaultFormatter": "vscode.typescript-language-features"
30 | // javascript文件默认格式化方式prettier
31 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
32 | },
33 | // json文件默认格式化方式prettier
34 | '[json]': {
35 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
36 | },
37 | // css文件默认格式化方式prettier
38 | '[css]': {
39 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
40 | },
41 | // typescript文件默认格式化方式prettier
42 | '[typescript]': {
43 | 'editor.defaultFormatter': 'esbenp.prettier-vscode',
44 | },
45 |
46 | // 控制折行方式 - "on" (根据视区宽度折行)
47 | 'editor.wordWrap': 'on',
48 | 'editor.tabSize': 2, // 换行默认以tab缩进 2个字符
49 | 'editor.snippetSuggestions': 'top', // 将建议的代码段优先级提前选择,比如输入for第一个提示是for循环代码段。
50 | 'files.associations': {
51 | // 文件关联语言的优先级配置
52 | '*.js': 'javascriptreact',
53 | '*.vue': 'vue',
54 | '*.cshtml': 'html',
55 | '*.dwt': 'html',
56 | },
57 | // "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
58 |
59 | 'editor.formatOnPaste': true,
60 | };
61 | } else {
62 | // const nowSetting = await getPackageJson('./vscode/settings.json');
63 | const nowSetting = fs.readJSON(getpath('./vscode/settings.json'));
64 | vscodeSetting = { ...nowSetting, ...vscodeSetting };
65 | }
66 | fs.outputFileSync(getpath('./.vscode/settings.json'), JSON.stringify(vscodeSetting, null, 2));
67 | };
68 |
--------------------------------------------------------------------------------
/.history/README_20230208145450.md:
--------------------------------------------------------------------------------
1 |
64 |
65 | ## 支持配置
66 |
67 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
68 |
69 | ```sh
70 | "scripts": {
71 | "web-norm": "web-norm --noEmoji",
72 | },
73 | ```
74 |
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 |
107 | ## 说明
108 |
109 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
110 |
111 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
112 |
--------------------------------------------------------------------------------
/.history/README_20230208145459.md:
--------------------------------------------------------------------------------
1 |
64 |
65 | ## 支持配置
66 |
67 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
68 |
69 | ```sh
70 | "scripts": {
71 | "web-norm": "web-norm --noEmoji",
72 | },
73 | ```
74 |
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 |
107 | ## 说明
108 |
109 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
110 |
111 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
112 |
--------------------------------------------------------------------------------
/.history/README_20230208145501.md:
--------------------------------------------------------------------------------
1 |
64 |
65 | ## 支持配置
66 |
67 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
68 |
69 | ```sh
70 | "scripts": {
71 | "web-norm": "web-norm --noEmoji",
72 | },
73 | ```
74 |
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 |
107 | ## 说明
108 |
109 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
110 |
111 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
112 |
--------------------------------------------------------------------------------
/.history/README_20230208145543.md:
--------------------------------------------------------------------------------
1 |
64 |
65 | ## 支持配置
66 |
67 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
68 |
69 | ```sh
70 | "scripts": {
71 | "web-norm": "web-norm --noEmoji",
72 | },
73 | ```
74 |
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 |
107 | ## 说明
108 |
109 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
110 |
111 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
112 |
--------------------------------------------------------------------------------
/.history/README_20230208145548.md:
--------------------------------------------------------------------------------
1 |
64 |
65 | ## 支持配置
66 |
67 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
68 |
69 | ```sh
70 | "scripts": {
71 | "web-norm": "web-norm --noEmoji",
72 | },
73 | ```
74 |
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 |
107 | ## 说明
108 |
109 | 1. `web-norm` 只支持 vue(包括 vue3)及 react 项目
110 |
111 | 2. 在使用过程中遇到任何问题,请提交 issues 😚
112 |
--------------------------------------------------------------------------------
/src/utils/tool.ts:
--------------------------------------------------------------------------------
1 | import spawn from 'cross-spawn';
2 | import fs from 'fs-extra';
3 |
4 | import { getEnv, getPackageJson } from './env';
5 | import { checkNpmOrYarn } from './check';
6 | import { getpath } from './path';
7 |
8 | import { debugInfo, debugWarning } from './debug';
9 | export const down = async (runName: string | string[], type: string) => {
10 | const basePath = getEnv('base') as string;
11 | const [n, i] = await checkNpmOrYarn(basePath);
12 | if (typeof runName === 'string') {
13 | await spawnSync(n, i, runName, type, basePath);
14 | return false;
15 | }
16 | runName.forEach(async (runItem) => {
17 | await spawnSync(n, i, runItem, type, basePath);
18 | });
19 | };
20 |
21 | export const spawnSync = (n: string, i: string, runItem: string, type: string, basePath: string) => {
22 | return new Promise((resolve) => {
23 | spawn.sync(n, [i, runItem, type], {
24 | stdio: 'pipe',
25 | cwd: basePath,
26 | });
27 | debugInfo(`${runItem}✅`);
28 |
29 | resolve({ success: true });
30 | });
31 | };
32 |
33 | /**
34 | * @name 写入依赖
35 | */
36 |
37 | /**
38 | * @name 睡眠函数
39 | * @param numberMillis -- 要睡眠的毫秒数
40 | */
41 | export const sleep = (numberMillis: number) => {
42 | var now = new Date();
43 | var exitTime = now.getTime() + numberMillis;
44 | while (true) {
45 | now = new Date();
46 | if (now.getTime() > exitTime) return;
47 | }
48 | };
49 |
50 | export const writeInPkg = async (devArr: string[], key: string = 'devDependencies') => {
51 | let pkg = await getPackageJson();
52 | devArr.forEach((item: string) => {
53 | // 为了防止安装包里面的名字有@
54 | const index = item.lastIndexOf('@');
55 | const k = index === -1 ? item : item.slice(0, index);
56 | const v = index === -1 ? '' : item.slice(index + 1) || '';
57 | pkg[key][k] = v;
58 | debugInfo(`${item}✅`);
59 | sleep(Math.random() * 500);
60 | });
61 | fs.writeJsonSync(getpath('package.json'), pkg, { spaces: 2 });
62 | };
63 |
64 | export const run = async (str: string) => {
65 | const basePath = getEnv('base') as string;
66 | const runArr = str.split(' ');
67 | if (runArr.length < 2) {
68 | debugWarning(`运行参数错误${str}`);
69 | return false;
70 | }
71 | const [npm, ...args] = runArr;
72 | debugInfo(`${runArr.join(' ')}✅`);
73 | spawn.sync(npm, args, {
74 | stdio: 'pipe',
75 | cwd: basePath,
76 | });
77 | };
78 |
79 | export const downNodeModules = async () => {
80 | const basePath = getEnv('base') as string;
81 | const [n] = await checkNpmOrYarn(basePath);
82 | await run(`${n} install`);
83 | };
84 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
65 |
66 | ## 支持配置
67 |
68 | `web-norm` 默认在提交记录上为带表情符号 📦👷📝🌟🐛🚀🌠🔂💎🚨 。如果不喜欢这些表情符号的话可以在用 `web-norm` 初始化项目的时候加上 `--noEmoji` 去掉
69 |
70 | ```sh
71 | "scripts": {
72 | "web-norm": "web-norm --noEmoji",
73 | },
74 | ```
75 |
76 | ## 验证
77 |
78 | 代码提交前校验
79 |
80 | ```sh
81 | npm run commit
82 | ```
83 |
84 |
85 |
86 | ## 在老项目中使用
87 |
88 | 在老项目使用会牵扯到一个问题就是以前的代码规范和通过`web-norm`生成的代码规范不一致怎么办?
89 |
90 | 1、如果项目比较小,只有几个文件,你可以把所以的文件都保存一遍即可(保存的时候 vscode 会自动格式化代码,确保使用 vscode 编辑器并安装 eslint 和 pretter 插件)
91 |
92 |
93 |
94 | 2、如果项目比较大,建议使用 vscode 插件`Format Files`进行自动化保存
95 |
96 |
97 |
98 | ## 可能遇到问题,详细内容参考这篇文章[可能遇到问题](https://juejin.cn/post/7124196350446534670#heading-4)
99 |
100 | - husky 无法触发
101 |
102 | 1. 项目首先需要被 `git` 管理
103 |
104 | 2. mac 电脑执行 `npm run postinstallmac` 来设置 husky 的读写权限
105 |
106 | ## 说明
107 |
108 | 1. 在使用过程中遇到任何问题,请提交 issues 😚
109 |
--------------------------------------------------------------------------------
/src/core/eslint.ts:
--------------------------------------------------------------------------------
1 | import fs from 'fs-extra'
2 | import { writeInPkg } from '../utils/tool'
3 | import { getPackageJson, getEnv, getEslintrc } from '../utils/env'
4 | import { prettierrcInit } from '../templet/prettierrc'
5 | import { eslintrcFn } from '../templet/eslintrc'
6 | import { getpath } from '../utils/path'
7 | import { teepEslintConfig } from '../especial'
8 | import { debugError } from '../utils/debug'
9 | const baseDep = [
10 | 'eslint@^7.25.0',
11 | 'prettier@^2.7.1',
12 | 'eslint-friendly-formatter@^4.0.1',
13 | 'eslint-plugin-prettier@^4.0.0',
14 | 'eslint-plugin-html@^6.2.0',
15 | 'eslint-config-prettier@^8.5.0'
16 | ]
17 |
18 | interface Obj {
19 | [key: string]: any
20 | }
21 |
22 | export const eslintInit = async () => {
23 | let devDependencies: string[] = baseDep
24 | if (getEnv('isVue2')) {
25 | devDependencies = [...baseDep, 'eslint-plugin-vue@^9.21.1']
26 | }
27 | if (getEnv('isVue3')) {
28 | devDependencies = [...baseDep, 'eslint-plugin-vue@^9.21.1', '@typescript-eslint/parser@^5.30.7']
29 | }
30 | if (getEnv('isReact')) {
31 | devDependencies = [...baseDep, 'eslint-plugin-react@^7.30.1', 'eslint-plugin-jsx-a11y@^6.6.1', '@typescript-eslint/parser@^5.30.7', '@typescript-eslint/eslint-plugin@5.30.7']
32 | }
33 |
34 | if (getEnv('merge')) {
35 | // 合并操作
36 | const oldEslintConfig = await getEslintrc()
37 | if (oldEslintConfig) {
38 | // 存在旧版本eslint
39 | const nEslint = getEnv('especial') ? teepEslintConfig.rules : {}
40 | const mEslint = meageEslint(oldEslintConfig, nEslint)
41 | const eslintToString = JSON.stringify(mEslint, null, 2)
42 | writeEslintConfig(`module.exports = ${eslintToString}`)
43 | }
44 | return false
45 | }
46 |
47 | // 调用down直接可以把依赖安装好
48 | // await down(devDependencies, '-D');
49 | // writeInPkg 只是把依赖写入到package中
50 | await writeInPkg(devDependencies, 'devDependencies')
51 |
52 | writeEslintConfig(eslintrcFn(getEnv('especial') as boolean))
53 | // 合并 执行一次 eslint 把重复的对象合并
54 | const eslint2 = await getEslintrc()
55 | writeEslintConfig(`module.exports = ${JSON.stringify(eslint2, null, 2)}`)
56 | async function writeEslintConfig(eslintConfig: string) {
57 | fs.outputFileSync(getpath('./.eslintrc.js'), eslintConfig)
58 | fs.outputFileSync(getpath('./.prettierrc'), prettierrcInit)
59 | let pkgJson = await getPackageJson()
60 | if (pkgJson['eslintConfig']) {
61 | delete pkgJson.eslintConfig
62 | }
63 | fs.writeJsonSync(getpath('package.json'), pkgJson, { spaces: 2 })
64 | }
65 | }
66 |
67 | function meageEslint(oldEslintConfig: Obj, newEslintRules: Obj): Obj {
68 | const { rules } = oldEslintConfig
69 | if (oldEslintConfig && rules) {
70 | oldEslintConfig.rules = {
71 | ...oldEslintConfig.rules,
72 | ...newEslintRules
73 | }
74 | return oldEslintConfig
75 | } else {
76 | debugError('.eslintrc格式有误,请删除后再运行命令')
77 | return {}
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "web-norm",
3 | "version": "1.1.6",
4 | "description": "前端项目规范一键安装",
5 | "main": "dist/index.js",
6 | "scripts": {
7 | "dev": "nodemon ./index.ts",
8 | "tsc": "tsc",
9 | "build": "rm -rf dist && tsc && ts-node build/index.ts",
10 | "serve": "ts-node ./index.ts",
11 | "serve2": "ts-node ./index.ts --especial",
12 | "tsc-init": "tsc --init",
13 | "version": "ts-node build/version.ts",
14 | "commit": "git add . && git-cz",
15 | "prepare": "husky install",
16 | "release": "rm -rf dist && tsc && ts-node build/index.ts",
17 | "w": "web-norm1 --en",
18 | "pre-commit": "lint-staged",
19 | "postinstallmac": "git config core.hooksPath .husky && chmod 700 .husky/*",
20 | "eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,js,tsx}\" --fix",
21 | "prettierwrite": "prettier --write src/**/*.{vue,ts,js,tsx,jsx}",
22 | "prettiercheck": "prettier --check src/**/*.{vue,ts,js,tsx,jsx}"
23 | },
24 | "bin": {
25 | "web-norm": "./dist/index.js"
26 | },
27 | "config": {
28 | "commitizen": {
29 | "path": "@commitlint/cz-commitlint"
30 | }
31 | },
32 | "repository": {
33 | "type": "git",
34 | "url": "git+https://github.com/lyh0371/web-norm.git"
35 | },
36 | "keywords": [],
37 | "author": "",
38 | "license": "ISC",
39 | "bugs": {
40 | "url": "https://github.com/lyh0371/web-norm/issues"
41 | },
42 | "homepage": "https://github.com/lyh0371/web-norm#readme",
43 | "devDependencies": {
44 | "@commitlint/cli": "^17.0.3",
45 | "@commitlint/config-angular": "^17.0.3",
46 | "@commitlint/cz-commitlint": "^17.0.3",
47 | "@rollup/plugin-commonjs": "^22.0.0",
48 | "@rollup/plugin-node-resolve": "^13.3.0",
49 | "@types/cross-spawn": "^6.0.2",
50 | "@types/fs-extra": "^9.0.13",
51 | "@types/node": "^17.0.35",
52 | "babel-eslint": "^10.1.0",
53 | "commitizen": "^4.2.4",
54 | "cross-spawn": "^7.0.3",
55 | "cz-customizable": "^6.9.0",
56 | "eslint": "^7.25.0",
57 | "eslint-config-prettier": "^8.5.0",
58 | "eslint-friendly-formatter": "^4.0.1",
59 | "eslint-plugin-html": "^6.2.0",
60 | "eslint-plugin-prettier": "^4.0.0",
61 | "eslint-plugin-vue": "^9.20.1",
62 | "husky": "^8.0.1",
63 | "inquirer": "^8.0.0",
64 | "lint-staged": "^12.4.1",
65 | "minimist": "^1.2.6",
66 | "nodemon": "^2.0.16",
67 | "prettier": "^2.7.1",
68 | "rollup": "^2.75.6",
69 | "rollup-plugin-terser": "^7.0.2",
70 | "rollup-plugin-typescript2": "^0.32.1",
71 | "ts-node": "^10.7.0",
72 | "typescript": "^4.6.4"
73 | },
74 | "dependencies": {
75 | "cac": "^6.7.12",
76 | "chalk": "^4.0.1",
77 | "enquirer": "^2.4.1",
78 | "fs-extra": "^10.1.0",
79 | "load-json-file": "^7.0.1",
80 | "husky": "^8.0.1",
81 | "cross-spawn": "^7.0.3",
82 | "babel-eslint": "^10.1.0"
83 | },
84 | "lint-staged": {
85 | "*.{tsx}": [
86 | "npm run eslint"
87 | ]
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/play/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@commitlint/config-angular'],
3 | parserPreset: {
4 | parserOpts: {
5 | headerPattern: /^(.*?)(?:\((.*)\))?:?\s(.*)$/,
6 | headerCorrespondence: ['type', 'scope', 'subject']
7 | }
8 | },
9 | rules: {
10 | 'type-case': [0],
11 | 'type-empty': [2, 'never'],
12 | 'type-enum': [2, 'always', ['build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test']],
13 | 'scope-empty': [2, 'never'],
14 | 'subject-empty': [2, 'never']
15 | },
16 | prompt: {
17 | settings: {},
18 | skip: ['body', 'footer', 'issues'],
19 | messages: {
20 | skip: '回车直接跳过',
21 | max: '最大%d字符',
22 | min: '%d chars at least',
23 | emptyWarning: '内容不能为空,重新输入',
24 | upperLimitWarning: 'over limit',
25 | lowerLimitWarning: 'below limit'
26 | },
27 | questions: {
28 | type: {
29 | description: '请选择提交类型',
30 | enum: {
31 | feat: {
32 | description: '增加新功能',
33 | title: 'Features',
34 | emoji: '🌟'
35 | },
36 | fix: {
37 | description: '修复bug',
38 | title: 'Bug Fixes',
39 | emoji: '🐛'
40 | },
41 | docs: {
42 | description: '修改文档',
43 | title: 'Documentation',
44 | emoji: '📝'
45 | },
46 | style: {
47 | description: '样式修改不影响逻辑',
48 | title: 'Styles',
49 | emoji: '💎'
50 | },
51 | refactor: {
52 | description: '功能/代码重构',
53 | title: 'Code Refactoring',
54 | emoji: '🌠'
55 | },
56 | perf: {
57 | description: '性能优化',
58 | title: 'Performance Improvements',
59 | emoji: '🚀'
60 | },
61 | test: {
62 | description: '增删测试',
63 | title: 'Tests',
64 | emoji: '🚨'
65 | },
66 | build: {
67 | description: '打包',
68 | title: '打包',
69 | emoji: '📦'
70 | },
71 | ci: {
72 | description: 'CI部署',
73 | title: 'Continuous Integrations',
74 | emoji: '⚙️'
75 | },
76 |
77 | revert: {
78 | description: '版本回退',
79 | title: 'Reverts',
80 | emoji: '🔂'
81 | }
82 | }
83 | },
84 | scope: {
85 | description: '请输入修改的范围(必填)'
86 | },
87 | subject: {
88 | description: '请简要描述提交(必填)'
89 | },
90 | body: {
91 | description: '请输入详细描述(可选)'
92 | },
93 | isBreaking: {
94 | description: '有什么突破性的变化吗?'
95 | },
96 | breakingBody: {
97 | description: '一个破坏性的变更提交需要一个主体。 请输入提交本身的更长的描述 '
98 | },
99 | breaking: {
100 | description: 'Describe the breaking changes'
101 | },
102 | isIssueAffected: {
103 | description: '是否有未解决的问题?'
104 | },
105 | issuesBody: {
106 | description: 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
107 | },
108 | issues: {
109 | description: '请输入问题说明'
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/play/commitlint.config copy.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@commitlint/config-angular'],
3 | parserPreset: {
4 | parserOpts: {
5 | headerPattern: /^(.*?)(?:\((.*)\))?:?\s(.*)$/,
6 | headerCorrespondence: ['type', 'scope', 'subject']
7 | }
8 | },
9 | rules: {
10 | 'type-case': [0],
11 | 'type-empty': [2, 'never'],
12 | 'type-enum': [2, 'always', ['📦build', '👷ci', '📝docs', '🌟feat', '🐛fix', '🚀perf', '🌠refactor', '🔂revert', '💎style', '🚨test']],
13 | 'scope-empty': [2, 'never'],
14 | 'subject-empty': [2, 'never']
15 | },
16 | prompt: {
17 | settings: {},
18 | skip: ['body', 'footer', 'issues'],
19 | messages: {
20 | skip: '回车直接跳过',
21 | max: '最大%d字符',
22 | min: '%d chars at least',
23 | emptyWarning: '内容不能为空,重新输入',
24 | upperLimitWarning: 'over limit',
25 | lowerLimitWarning: 'below limit'
26 | },
27 | questions: {
28 | type: {
29 | description: '请选择提交类型',
30 | enum: {
31 | '🌟feat': {
32 | description: '增加新功能',
33 | title: 'Features',
34 | emoji: '🌟'
35 | },
36 | '🐛fix': {
37 | description: '修复bug',
38 | title: 'Bug Fixes',
39 | emoji: '🐛'
40 | },
41 | '📝docs': {
42 | description: '修改文档',
43 | title: 'Documentation',
44 | emoji: '📝'
45 | },
46 | '💎style': {
47 | description: '样式修改不影响逻辑',
48 | title: 'Styles',
49 | emoji: '💎'
50 | },
51 | '🌠refactor': {
52 | description: '功能/代码重构',
53 | title: 'Code Refactoring',
54 | emoji: '🌠'
55 | },
56 | '🚀perf': {
57 | description: '性能优化',
58 | title: 'Performance Improvements',
59 | emoji: '🚀'
60 | },
61 | '🚨test': {
62 | description: '增删测试',
63 | title: 'Tests',
64 | emoji: '🚨'
65 | },
66 | '📦build': {
67 | description: '打包',
68 | title: '打包',
69 | emoji: '📦'
70 | },
71 | '👷ci': {
72 | description: 'CI部署',
73 | title: 'Continuous Integrations',
74 | emoji: '⚙️'
75 | },
76 |
77 | '🔂revert': {
78 | description: '版本回退',
79 | title: 'Reverts',
80 | emoji: '🔂'
81 | }
82 | }
83 | },
84 | scope: {
85 | description: '请输入修改的范围(必填)'
86 | },
87 | subject: {
88 | description: '请简要描述提交(必填)'
89 | },
90 | body: {
91 | description: '请输入详细描述(可选)'
92 | },
93 | isBreaking: {
94 | description: '有什么突破性的变化吗?'
95 | },
96 | breakingBody: {
97 | description: '一个破坏性的变更提交需要一个主体。 请输入提交本身的更长的描述 '
98 | },
99 | breaking: {
100 | description: 'Describe the breaking changes'
101 | },
102 | isIssueAffected: {
103 | description: '是否有未解决的问题?'
104 | },
105 | issuesBody: {
106 | description: 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
107 | },
108 | issues: {
109 | description: '请输入问题说明'
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports={
3 | extends: ['@commitlint/config-angular'],
4 | parserPreset: {
5 | parserOpts: {
6 | headerPattern: /^(.*?)(?:\((.*)\))?:?\s(.*)$/,
7 | headerCorrespondence: ['type', 'scope', 'subject'],
8 | },
9 | },
10 | rules: {
11 | 'type-case': [0],
12 | 'type-empty': [2, 'never'],
13 | 'type-enum': [
14 | 2,
15 | 'always',
16 | [
17 | '📦build',
18 | '👷ci',
19 | '📝docs',
20 | '🌟feat',
21 | '🐛fix',
22 | '🚀perf',
23 | '🌠refactor',
24 | '🔂revert',
25 | '💎style',
26 | '🚨test',
27 | ],
28 | ],
29 | 'scope-empty': [2, 'never'],
30 | 'subject-empty': [2, 'never'],
31 | },
32 | prompt: {
33 | settings: {},
34 | skip: ['body', 'footer', 'issues'],
35 | messages: {
36 | skip: '回车直接跳过',
37 | max: '最大%d字符',
38 | min: '%d chars at least',
39 | emptyWarning: '内容不能为空,重新输入',
40 | upperLimitWarning: 'over limit',
41 | lowerLimitWarning: 'below limit',
42 | },
43 | questions: {
44 | type: {
45 | description: '请选择提交类型',
46 | enum: {
47 | '🌟feat': {
48 | description: '增加新功能',
49 | title: 'Features',
50 | emoji: '🌟',
51 | },
52 | '🐛fix': {
53 | description: '修复bug',
54 | title: 'Bug Fixes',
55 | emoji: '🐛',
56 | },
57 | '📝docs': {
58 | description: '修改文档',
59 | title: 'Documentation',
60 | emoji: '📝',
61 | },
62 | '💎style': {
63 | description: '样式修改不影响逻辑',
64 | title: 'Styles',
65 | emoji: '💎',
66 | },
67 | '🌠refactor': {
68 | description: '功能/代码重构',
69 | title: 'Code Refactoring',
70 | emoji: '🌠',
71 | },
72 | '🚀perf': {
73 | description: '性能优化',
74 | title: 'Performance Improvements',
75 | emoji: '🚀',
76 | },
77 | '🚨test': {
78 | description: '增删测试',
79 | title: 'Tests',
80 | emoji: '🚨',
81 | },
82 | '📦build': {
83 | description: '打包',
84 | title: '打包',
85 | emoji: '📦',
86 | },
87 | '👷ci': {
88 | description: 'CI部署',
89 | title: 'Continuous Integrations',
90 | emoji: '⚙️',
91 | },
92 |
93 | '🔂revert': {
94 | description: '版本回退',
95 | title: 'Reverts',
96 | emoji: '🔂',
97 | },
98 | },
99 | },
100 | scope: {
101 | description: '请输入修改的范围(必填)',
102 | },
103 | subject: {
104 | description: '请简要描述提交(必填)',
105 | },
106 | body: {
107 | description: '请输入详细描述(可选)',
108 | },
109 | isBreaking: {
110 | description: '有什么突破性的变化吗?',
111 | },
112 | breakingBody: {
113 | description:
114 | '一个破坏性的变更提交需要一个主体。 请输入提交本身的更长的描述 ',
115 | },
116 | breaking: {
117 | description: 'Describe the breaking changes',
118 | },
119 | isIssueAffected: {
120 | description: '是否有未解决的问题?',
121 | },
122 | issuesBody: {
123 | description:
124 | 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
125 | },
126 | issues: {
127 | description: '请输入问题说明',
128 | },
129 | },
130 | },
131 | }
--------------------------------------------------------------------------------
/src/templet/commitlint-no-emoji.config.ts:
--------------------------------------------------------------------------------
1 | export const commitLintConfigNoEmoji = `
2 | module.exports={
3 | extends: ['@commitlint/config-angular'],
4 | parserPreset: {
5 | parserOpts: {
6 | headerPattern: /^(.*?)(?:\\((.*)\\))?:?\\s(.*)$/,
7 | headerCorrespondence: ['type', 'scope', 'subject'],
8 | },
9 | },
10 | rules: {
11 | 'type-case': [0],
12 | 'type-empty': [2, 'never'],
13 | 'type-enum': [
14 | 2,
15 | 'always',
16 | [
17 | 'build',
18 | 'ci',
19 | 'docs',
20 | 'feat',
21 | 'fix',
22 | 'perf',
23 | 'refactor',
24 | 'revert',
25 | 'style',
26 | 'test',
27 | ],
28 | ],
29 | 'scope-empty': [2, 'never'],
30 | 'subject-empty': [2, 'never'],
31 | },
32 | prompt: {
33 | settings: {},
34 | skip: ['body', 'footer', 'issues'],
35 | messages: {
36 | skip: '回车直接跳过',
37 | max: '最大%d字符',
38 | min: '%d chars at least',
39 | emptyWarning: '内容不能为空,重新输入',
40 | upperLimitWarning: 'over limit',
41 | lowerLimitWarning: 'below limit',
42 | },
43 | questions: {
44 | type: {
45 | description: '请选择提交类型',
46 | enum: {
47 | 'feat': {
48 | description: '增加新功能',
49 | title: 'Features',
50 | emoji: '🌟',
51 | },
52 | 'fix': {
53 | description: '修复bug',
54 | title: 'Bug Fixes',
55 | emoji: '🐛',
56 | },
57 | 'docs': {
58 | description: '修改文档',
59 | title: 'Documentation',
60 | emoji: '📝',
61 | },
62 | 'style': {
63 | description: '样式修改不影响逻辑',
64 | title: 'Styles',
65 | emoji: '💎',
66 | },
67 | 'refactor': {
68 | description: '功能/代码重构',
69 | title: 'Code Refactoring',
70 | emoji: '🌠',
71 | },
72 | 'perf': {
73 | description: '性能优化',
74 | title: 'Performance Improvements',
75 | emoji: '🚀',
76 | },
77 | 'test': {
78 | description: '增删测试',
79 | title: 'Tests',
80 | emoji: '🚨',
81 | },
82 | 'build': {
83 | description: '打包',
84 | title: '打包',
85 | emoji: '📦',
86 | },
87 | 'ci': {
88 | description: 'CI部署',
89 | title: 'Continuous Integrations',
90 | emoji: '⚙️',
91 | },
92 |
93 | 'revert': {
94 | description: '版本回退',
95 | title: 'Reverts',
96 | emoji: '🔂',
97 | },
98 | },
99 | },
100 | scope: {
101 | description: '请输入修改的范围(必填)',
102 | },
103 | subject: {
104 | description: '请简要描述提交(必填)',
105 | },
106 | body: {
107 | description: '请输入详细描述(可选)',
108 | },
109 | isBreaking: {
110 | description: '有什么突破性的变化吗?',
111 | },
112 | breakingBody: {
113 | description:
114 | '一个破坏性的变更提交需要一个主体。 请输入提交本身的更长的描述 ',
115 | },
116 | breaking: {
117 | description: 'Describe the breaking changes',
118 | },
119 | isIssueAffected: {
120 | description: '是否有未解决的问题?',
121 | },
122 | issuesBody: {
123 | description:
124 | 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
125 | },
126 | issues: {
127 | description: '请输入问题说明',
128 | },
129 | },
130 | },
131 | }`;
132 |
--------------------------------------------------------------------------------
/src/templet/commitlint.config.ts:
--------------------------------------------------------------------------------
1 | export const commitLintConfig = `
2 | module.exports={
3 | extends: ['@commitlint/config-angular'],
4 | parserPreset: {
5 | parserOpts: {
6 | headerPattern: /^(.*?)(?:\\((.*)\\))?:?\\s(.*)$/,
7 | headerCorrespondence: ['type', 'scope', 'subject'],
8 | },
9 | },
10 | rules: {
11 | 'type-case': [0],
12 | 'type-empty': [2, 'never'],
13 | 'type-enum': [
14 | 2,
15 | 'always',
16 | [
17 | '📦build',
18 | '👷ci',
19 | '📝docs',
20 | '🌟feat',
21 | '🐛fix',
22 | '🚀perf',
23 | '🌠refactor',
24 | '🔂revert',
25 | '💎style',
26 | '🚨test',
27 | ],
28 | ],
29 | 'scope-empty': [2, 'never'],
30 | 'subject-empty': [2, 'never'],
31 | },
32 | prompt: {
33 | settings: {},
34 | skip: ['body', 'footer', 'issues'],
35 | messages: {
36 | skip: '回车直接跳过',
37 | max: '最大%d字符',
38 | min: '%d chars at least',
39 | emptyWarning: '内容不能为空,重新输入',
40 | upperLimitWarning: 'over limit',
41 | lowerLimitWarning: 'below limit',
42 | },
43 | questions: {
44 | type: {
45 | description: '请选择提交类型',
46 | enum: {
47 | '🌟feat': {
48 | description: '增加新功能',
49 | title: 'Features',
50 | emoji: '🌟',
51 | },
52 | '🐛fix': {
53 | description: '修复bug',
54 | title: 'Bug Fixes',
55 | emoji: '🐛',
56 | },
57 | '📝docs': {
58 | description: '修改文档',
59 | title: 'Documentation',
60 | emoji: '📝',
61 | },
62 | '💎style': {
63 | description: '样式修改不影响逻辑',
64 | title: 'Styles',
65 | emoji: '💎',
66 | },
67 | '🌠refactor': {
68 | description: '功能/代码重构',
69 | title: 'Code Refactoring',
70 | emoji: '🌠',
71 | },
72 | '🚀perf': {
73 | description: '性能优化',
74 | title: 'Performance Improvements',
75 | emoji: '🚀',
76 | },
77 | '🚨test': {
78 | description: '增删测试',
79 | title: 'Tests',
80 | emoji: '🚨',
81 | },
82 | '📦build': {
83 | description: '打包',
84 | title: '打包',
85 | emoji: '📦',
86 | },
87 | '👷ci': {
88 | description: 'CI部署',
89 | title: 'Continuous Integrations',
90 | emoji: '⚙️',
91 | },
92 |
93 | '🔂revert': {
94 | description: '版本回退',
95 | title: 'Reverts',
96 | emoji: '🔂',
97 | },
98 | },
99 | },
100 | scope: {
101 | description: '请输入修改的范围(必填)',
102 | },
103 | subject: {
104 | description: '请简要描述提交(必填)',
105 | },
106 | body: {
107 | description: '请输入详细描述(可选)',
108 | },
109 | isBreaking: {
110 | description: '有什么突破性的变化吗?',
111 | },
112 | breakingBody: {
113 | description:
114 | '一个破坏性的变更提交需要一个主体。 请输入提交本身的更长的描述 ',
115 | },
116 | breaking: {
117 | description: 'Describe the breaking changes',
118 | },
119 | isIssueAffected: {
120 | description: '是否有未解决的问题?',
121 | },
122 | issuesBody: {
123 | description:
124 | 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
125 | },
126 | issues: {
127 | description: '请输入问题说明',
128 | },
129 | },
130 | },
131 | }`;
132 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* 访问 https://aka.ms/tsconfig.json 查看更多 */
4 |
5 | /* 基本选项 */
6 | // "incremental": true, /* 启用增量编译 */
7 | "target": "es5", /* 指定 ECMAScript 目标版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 或者 'ESNEXT'. */
8 | "module": "commonjs", /* 指定使用模块: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', 或者 'ESNext'. */
9 | // "lib": [], /* 指定要包含在编译中的库文件 */
10 | // "allowJs": true, /* 允许编译 javascript 文件 */
11 | // "checkJs": true, /* 报告 javascript 文件中的错误 */
12 | // "jsx": "preserve", /* 指定 jsx 代码的生成: 'preserve', 'react-native', 'react', 'react-jsx' 或者 'react-jsxdev'. */
13 | // "declaration": true, /* 生成相应的 '.d.ts' 文件 */
14 | // "declarationMap": true, /* 对每个 '.d.ts' 文件进行遍历 */
15 | // "sourceMap": true, /* 生成相应的 '.map' 文件 */
16 | // "outFile": "./", /* 将输出文件合并为一个文件 */
17 | "outDir": "./dist", /* 指定输出目录 */
18 | // "rootDir": "./", /* 用来控制输出目录结构 --outDir */
19 | // "composite": true, /* 启用项目编译 */
20 | // "tsBuildInfoFile": "./", /* 指定文件来存储增量编译信息 */
21 | "removeComments": true, /* 删除编译后的所有的注释 */
22 | // "noEmit": true, /* 不生成输出文件 */
23 | // "importHelpers": true, /* 从 tslib 导入辅助工具函数 */
24 | // "downlevelIteration": true, /* 在 ES5 和 ES3 中全面支持 for-of */
25 | // "isolatedModules": true, /* 将每个文件作为单独的模块 (与 'ts.transpileModule' 类似) */
26 |
27 | /* 严格的类型检查选项 */
28 | "strict": true, /* 启用所有严格类型检查选项 */
29 | // "noImplicitAny": true, /* 在表达式和声明上有隐含的 any 类型时报错 */
30 | // "strictNullChecks": true, /* 启用严格的 null 检查 */
31 | // "strictFunctionTypes": true, /* 启用严格的 function 类型检查 */
32 | // "strictBindCallApply": true, /* 启用严格的 bind、call、apply 方法参数检查 */
33 | // "strictPropertyInitialization": true, /* 启用严格的类的属性初始化检查 */
34 | // "noImplicitThis": true, /* 当 this 表达式值为 any 类型的时候,生成一个错误 */
35 | // "alwaysStrict": true, /* 以严格模式检查每个模块,并在每个文件里加入 'use strict' */
36 |
37 | /* 额外的检查 */
38 | "noUnusedLocals": true, /* 有未使用的变量时,抛出错误 */
39 | "noUnusedParameters": true, /* 有未使用的参数时,抛出错误 */
40 | // "noImplicitReturns": true, /* 并不是所有函数里的代码都有返回值时,抛出错误 */
41 | // "noFallthroughCasesInSwitch": true, /* 报告 switch 语句的 fallthrough 错误。(即,不允许 switch 的 case 语句贯穿) */
42 | // "noUncheckedIndexedAccess": true, /* 在索引签名结果中包含 undefined */
43 | // "noPropertyAccessFromIndexSignature": true, /* 需要索引签名中未声明的属性才能使用元素访问 */
44 |
45 | /* Module Resolution Options */
46 | // "moduleResolution": "node", /* 选择模块解析策略: 'node' (Node.js) or 'classic' (TypeScript pre-1.6) */
47 | // "baseUrl": "./", /* 用于解析非相对模块名称的基目录 */
48 | // "paths": {}, /* 模块名到基于 baseUrl 的路径映射的列表 */
49 | // "rootDirs": [], /* 根文件夹列表,其组合内容表示项目运行时的结构内容 */
50 | // "typeRoots": [], /* 包含类型声明的文件列表 */
51 | // "types": [], /* 需要包含的类型声明文件名列表 */
52 | // "allowSyntheticDefaultImports": true, /* 允许从没有设置默认导出的模块中默认导入 */
53 | "esModuleInterop": true, /* 通过为所有导入创建名称空间对象,启用 CommonJS 和 ES 模块之间的的互动性 */
54 | // "preserveSymlinks": true, /* 不解析符号链接的真实路径 */
55 | // "allowUmdGlobalAccess": true, /* 允许从模块访问 UMD 全局变量 */
56 |
57 | /* Source Map Options */
58 | // "sourceRoot": "", /* 指定调试器应该找到 TypeScript 文件而不是源文件的位置 */
59 | // "mapRoot": "", /* 指定调试器应该找到映射文件而不是生成文件的位置 */
60 | // "inlineSourceMap": true, /* 生成单个 soucemaps 文件,而不是将 sourcemaps 生成不同的文件 */
61 | // "inlineSources": true, /* E将代码与 sourcemaps 生成到一个文件中,要求同时设置了 --inlineSourceMap 或 --sourceMap 属性 */
62 |
63 | /* Experimental Options */
64 | // "experimentalDecorators": true, /* 启用装饰器 */
65 | // "emitDecoratorMetadata": true, /* 为装饰器提供元数据的支持 */
66 |
67 | /* Advanced Options */
68 | "skipLibCheck": true, /* 跳过声明文件的类型检查 */
69 | "forceConsistentCasingInFileNames": true, /* 进制对同一文件使用大小写不一致的引用 */
70 | "resolveJsonModule":true,
71 | },
72 | "include": [
73 | "./index.ts",
74 | "src**/*.ts"
75 | ],
76 | }
77 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parserOptions: {
4 | ecmaVersion: 11,
5 | parser: 'babel-eslint',
6 | sourceType: 'module'
7 | },
8 | env: {
9 | browser: true,
10 | node: true,
11 | es6: true
12 | },
13 | plugins: ['prettier'],
14 | extends: ['plugin:vue/recommended', 'eslint:recommended', 'plugin:prettier/recommended'],
15 | rules: {
16 | 'vue/order-in-components': 'off',
17 | 'vue/html-self-closing': 'off',
18 | 'vue/require-default-prop': 'off',
19 | 'vue/max-attributes-per-line': [
20 | 0,
21 | {
22 | singleline: 10,
23 | multiline: {
24 | max: 1,
25 | allowFirstLine: false
26 | }
27 | }
28 | ],
29 | 'vue/singleline-html-element-content-newline': 'off',
30 | 'vue/multiline-html-element-content-newline': 'off',
31 | 'vue/name-property-casing': ['error', 'PascalCase'],
32 | 'vue/no-v-html': 'off',
33 | 'prettier/prettier': 'error',
34 | 'accessor-pairs': 2,
35 | 'arrow-spacing': [
36 | 2,
37 | {
38 | before: true,
39 | after: true
40 | }
41 | ],
42 | 'block-spacing': [2, 'always'],
43 | 'brace-style': [
44 | 2,
45 | '1tbs',
46 | {
47 | allowSingleLine: true
48 | }
49 | ],
50 | camelcase: [
51 | 0,
52 | {
53 | properties: 'always'
54 | }
55 | ],
56 | 'comma-dangle': [
57 | 'error',
58 | {
59 | arrays: 'never',
60 | objects: 'never',
61 | imports: 'never',
62 | exports: 'never',
63 | functions: 'never'
64 | }
65 | ],
66 | 'comma-spacing': [
67 | 2,
68 | {
69 | before: false,
70 | after: true
71 | }
72 | ],
73 | 'comma-style': [2, 'last'],
74 | 'constructor-super': 2,
75 | curly: [2, 'multi-line'],
76 | 'dot-location': [2, 'property'],
77 | 'eol-last': 2,
78 | eqeqeq: 'off',
79 | 'generator-star-spacing': [
80 | 2,
81 | {
82 | before: true,
83 | after: true
84 | }
85 | ],
86 | 'handle-callback-err': [2, '^(err|error)$'],
87 | indent: 'off',
88 | 'key-spacing': [
89 | 2,
90 | {
91 | beforeColon: false,
92 | afterColon: true
93 | }
94 | ],
95 | 'keyword-spacing': [
96 | 2,
97 | {
98 | before: true,
99 | after: true
100 | }
101 | ],
102 | 'new-cap': [
103 | 2,
104 | {
105 | newIsCap: true,
106 | capIsNew: false
107 | }
108 | ],
109 | 'new-parens': 2,
110 | 'no-array-constructor': 2,
111 | 'no-caller': 2,
112 | 'no-console': [
113 | 'error',
114 | {
115 | allow: ['warn', 'error']
116 | }
117 | ],
118 | 'no-class-assign': 2,
119 | 'no-cond-assign': 2,
120 | 'no-const-assign': 2,
121 | 'no-control-regex': 0,
122 | 'no-delete-var': 2,
123 | 'no-dupe-args': 2,
124 | 'no-dupe-class-members': 2,
125 | 'no-dupe-keys': 2,
126 | 'no-duplicate-case': 2,
127 | 'no-empty-character-class': 2,
128 | 'no-empty-pattern': 2,
129 | 'no-eval': 0,
130 | 'no-ex-assign': 2,
131 | 'no-extend-native': 2,
132 | 'no-extra-bind': 2,
133 | 'no-extra-boolean-cast': 2,
134 | 'no-extra-parens': [2, 'functions'],
135 | 'no-fallthrough': 2,
136 | 'no-floating-decimal': 2,
137 | 'no-func-assign': 2,
138 | 'no-implied-eval': 2,
139 | 'no-inner-declarations': [2, 'functions'],
140 | 'no-invalid-regexp': 2,
141 | 'no-irregular-whitespace': 2,
142 | 'no-iterator': 2,
143 | 'no-label-var': 2,
144 | 'no-labels': [
145 | 2,
146 | {
147 | allowLoop: false,
148 | allowSwitch: false
149 | }
150 | ],
151 | 'no-lone-blocks': 2,
152 | 'no-mixed-spaces-and-tabs': 2,
153 | 'no-multi-spaces': 2,
154 | 'no-multi-str': 2,
155 | 'no-multiple-empty-lines': [
156 | 2,
157 | {
158 | max: 1
159 | }
160 | ],
161 | 'no-native-reassign': 2,
162 | 'no-negated-in-lhs': 2,
163 | 'no-new-object': 2,
164 | 'no-new-require': 2,
165 | 'no-new-symbol': 2,
166 | 'no-new-wrappers': 2,
167 | 'no-obj-calls': 2,
168 | 'no-octal': 2,
169 | 'no-octal-escape': 2,
170 | 'no-path-concat': 2,
171 | 'no-proto': 2,
172 | 'no-redeclare': 2,
173 | 'no-regex-spaces': 2,
174 | 'no-return-assign': [2, 'except-parens'],
175 | 'no-self-assign': 2,
176 | 'no-self-compare': 2,
177 | 'no-sequences': 2,
178 | 'no-shadow-restricted-names': 2,
179 | 'no-spaced-func': 2,
180 | 'no-sparse-arrays': 2,
181 | 'no-this-before-super': 2,
182 | 'no-throw-literal': 2,
183 | 'no-trailing-spaces': 2,
184 | 'no-undef': 2,
185 | 'no-undef-init': 2,
186 | 'no-unexpected-multiline': 2,
187 | 'no-unmodified-loop-condition': 2,
188 | 'no-unneeded-ternary': [
189 | 2,
190 | {
191 | defaultAssignment: false
192 | }
193 | ],
194 | 'no-unreachable': 2,
195 | 'no-unsafe-finally': 2,
196 | 'no-unused-vars': [
197 | 2,
198 | {
199 | vars: 'all',
200 | args: 'none'
201 | }
202 | ],
203 | 'no-useless-call': 2,
204 | 'no-useless-computed-key': 2,
205 | 'no-useless-constructor': 2,
206 | 'no-useless-escape': 0,
207 | 'no-whitespace-before-property': 2,
208 | 'no-with': 2,
209 | 'one-var': [
210 | 2,
211 | {
212 | initialized: 'never'
213 | }
214 | ],
215 | 'operator-linebreak': [
216 | 2,
217 | 'after',
218 | {
219 | overrides: {
220 | '?': 'before',
221 | ':': 'before'
222 | }
223 | }
224 | ],
225 | 'padded-blocks': [2, 'never'],
226 | quotes: 'off',
227 | semi: 'off',
228 | 'semi-spacing': [
229 | 2,
230 | {
231 | before: false,
232 | after: true
233 | }
234 | ],
235 | 'space-before-blocks': [2, 'always'],
236 | 'space-before-function-paren': 'off',
237 | 'space-in-parens': [2, 'never'],
238 | 'space-infix-ops': 2,
239 | 'space-unary-ops': [
240 | 2,
241 | {
242 | words: true,
243 | nonwords: false
244 | }
245 | ],
246 | 'spaced-comment': 'off',
247 | 'template-curly-spacing': [2, 'never'],
248 | 'use-isnan': 2,
249 | 'valid-typeof': 2,
250 | 'wrap-iife': [2, 'any'],
251 | 'yield-star-spacing': [2, 'both'],
252 | yoda: [2, 'never'],
253 | 'prefer-const': 2,
254 | 'no-debugger': 0,
255 | 'object-curly-spacing': [
256 | 0,
257 | 'always',
258 | {
259 | objectsInObjects: false
260 | }
261 | ],
262 | 'array-bracket-spacing': [2, 'never']
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/play/.eslintrc.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | root: true,
4 | parserOptions: {
5 | ecmaVersion: 11,
6 | parser: 'babel-eslint',
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | node: true,
12 | es6: true
13 | },
14 | plugins: ['prettier'],
15 | extends: ['plugin:vue/recommended', 'eslint:recommended', 'plugin:prettier/recommended'],
16 | rules: {
17 | 'prettier/prettier': 'error',
18 | 'vue/order-in-components': 'off',
19 | 'vue/html-self-closing': 'off',
20 | 'vue/require-default-prop': 'off',
21 | 'vue/max-attributes-per-line': [
22 | 0,
23 | {
24 | singleline: 10,
25 | multiline: {
26 | max: 1,
27 | allowFirstLine: false
28 | }
29 | }
30 | ],
31 | 'vue/singleline-html-element-content-newline': 'off',
32 | 'vue/multiline-html-element-content-newline': 'off',
33 | 'vue/name-property-casing': ['error', 'PascalCase'],
34 | 'vue/no-v-html': 'off',
35 | 'accessor-pairs': 2,
36 | 'arrow-spacing': [
37 | 2,
38 | {
39 | before: true,
40 | after: true
41 | }
42 | ],
43 | 'block-spacing': [2, 'always'],
44 | 'brace-style': [
45 | 2,
46 | '1tbs',
47 | {
48 | allowSingleLine: true
49 | }
50 | ],
51 | camelcase: [
52 | 0,
53 | {
54 | properties: 'always'
55 | }
56 | ],
57 | 'comma-dangle': [
58 | 'error',
59 | {
60 | arrays: 'never',
61 | objects: 'never',
62 | imports: 'never',
63 | exports: 'never',
64 | functions: 'never'
65 | }
66 | ],
67 | 'comma-spacing': [
68 | 2,
69 | {
70 | before: false,
71 | after: true
72 | }
73 | ],
74 | 'comma-style': [2, 'last'],
75 | 'constructor-super': 2,
76 | curly: [2, 'multi-line'],
77 | 'dot-location': [2, 'property'],
78 | 'eol-last': 2,
79 | eqeqeq: 'off',
80 | 'generator-star-spacing': [
81 | 2,
82 | {
83 | before: true,
84 | after: true
85 | }
86 | ],
87 | 'handle-callback-err': [2, '^(err|error)$'],
88 | indent: 'off',
89 | // indent: [
90 | // 2,
91 | // 2,
92 | // {
93 | // SwitchCase: 1,
94 | // },
95 | // ],
96 | 'jsx-quotes': [2, 'prefer-single'],
97 | 'key-spacing': [
98 | 2,
99 | {
100 | beforeColon: false,
101 | afterColon: true
102 | }
103 | ],
104 | 'keyword-spacing': [
105 | 2,
106 | {
107 | before: true,
108 | after: true
109 | }
110 | ],
111 | 'new-cap': [
112 | 2,
113 | {
114 | newIsCap: true,
115 | capIsNew: false
116 | }
117 | ],
118 | 'new-parens': 2,
119 | 'no-array-constructor': 2,
120 | 'no-caller': 2,
121 | 'no-console': 'off',
122 | 'no-class-assign': 2,
123 | 'no-cond-assign': 2,
124 | 'no-const-assign': 2,
125 | 'no-control-regex': 0,
126 | 'no-delete-var': 2,
127 | 'no-dupe-args': 2,
128 | 'no-dupe-class-members': 2,
129 | 'no-dupe-keys': 2,
130 | 'no-duplicate-case': 2,
131 | 'no-empty-character-class': 2,
132 | 'no-empty-pattern': 2,
133 | 'no-eval': 0,
134 | 'no-ex-assign': 2,
135 | 'no-extend-native': 2,
136 | 'no-extra-bind': 2,
137 | 'no-extra-boolean-cast': 2,
138 | 'no-extra-parens': [2, 'functions'],
139 | 'no-fallthrough': 2,
140 | 'no-floating-decimal': 2,
141 | 'no-func-assign': 2,
142 | 'no-implied-eval': 2,
143 | 'no-inner-declarations': [2, 'functions'],
144 | 'no-invalid-regexp': 2,
145 | 'no-irregular-whitespace': 2,
146 | 'no-iterator': 2,
147 | 'no-label-var': 2,
148 | 'no-labels': [
149 | 2,
150 | {
151 | allowLoop: false,
152 | allowSwitch: false
153 | }
154 | ],
155 | 'no-lone-blocks': 2,
156 | 'no-mixed-spaces-and-tabs': 2,
157 | 'no-multi-spaces': 2,
158 | 'no-multi-str': 2,
159 | 'no-multiple-empty-lines': [
160 | 2,
161 | {
162 | max: 1
163 | }
164 | ],
165 | 'no-native-reassign': 2,
166 | 'no-negated-in-lhs': 2,
167 | 'no-new-object': 2,
168 | 'no-new-require': 2,
169 | 'no-new-symbol': 2,
170 | 'no-new-wrappers': 2,
171 | 'no-obj-calls': 2,
172 | 'no-octal': 2,
173 | 'no-octal-escape': 2,
174 | 'no-path-concat': 2,
175 | 'no-proto': 2,
176 | 'no-redeclare': 2,
177 | 'no-regex-spaces': 2,
178 | 'no-return-assign': [2, 'except-parens'],
179 | 'no-self-assign': 2,
180 | 'no-self-compare': 2,
181 | 'no-sequences': 2,
182 | 'no-shadow-restricted-names': 2,
183 | 'no-spaced-func': 2,
184 | 'no-sparse-arrays': 2,
185 | 'no-this-before-super': 2,
186 | 'no-throw-literal': 2,
187 | 'no-trailing-spaces': 2,
188 | 'no-undef': 2,
189 | 'no-undef-init': 2,
190 | 'no-unexpected-multiline': 2,
191 | 'no-unmodified-loop-condition': 2,
192 | 'no-unneeded-ternary': [
193 | 2,
194 | {
195 | defaultAssignment: false
196 | }
197 | ],
198 | 'no-unreachable': 2,
199 | 'no-unsafe-finally': 2,
200 | 'no-unused-vars': [
201 | 2,
202 | {
203 | vars: 'all',
204 | args: 'none'
205 | }
206 | ],
207 | 'no-useless-call': 2,
208 | 'no-useless-computed-key': 2,
209 | 'no-useless-constructor': 2,
210 | 'no-useless-escape': 0,
211 | 'no-whitespace-before-property': 2,
212 | 'no-with': 2,
213 | 'one-var': [
214 | 2,
215 | {
216 | initialized: 'never'
217 | }
218 | ],
219 | 'operator-linebreak': [
220 | 2,
221 | 'after',
222 | {
223 | overrides: {
224 | '?': 'before',
225 | ':': 'before'
226 | }
227 | }
228 | ],
229 | 'padded-blocks': [2, 'never'],
230 | quotes: 'off',
231 | semi: 'off',
232 | 'semi-spacing': [
233 | 2,
234 | {
235 | before: false,
236 | after: true
237 | }
238 | ],
239 | 'space-before-blocks': [2, 'always'],
240 | 'space-before-function-paren': 'off',
241 | 'space-in-parens': [2, 'never'],
242 | 'space-infix-ops': 2,
243 | 'space-unary-ops': [
244 | 2,
245 | {
246 | words: true,
247 | nonwords: false
248 | }
249 | ],
250 | 'spaced-comment': 'off',
251 | 'template-curly-spacing': [2, 'never'],
252 | 'use-isnan': 2,
253 | 'valid-typeof': 2,
254 | 'wrap-iife': [2, 'any'],
255 | 'yield-star-spacing': [2, 'both'],
256 | yoda: [2, 'never'],
257 | 'prefer-const': 2,
258 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
259 | 'object-curly-spacing': [
260 | 0,
261 | 'always',
262 | {
263 | objectsInObjects: false
264 | }
265 | ],
266 | 'array-bracket-spacing': [2, 'never']
267 | }
268 | }
269 |
270 |
--------------------------------------------------------------------------------
/.eslintcache:
--------------------------------------------------------------------------------
1 | [{"/Users/lyh/Desktop/prTemp/web-norm/src/cli.ts":"1","/Users/lyh/Desktop/prTemp/web-norm/src/core/commitlint.ts":"2","/Users/lyh/Desktop/prTemp/web-norm/src/core/eslint.ts":"3","/Users/lyh/Desktop/prTemp/web-norm/src/core/eslintignore.ts":"4","/Users/lyh/Desktop/prTemp/web-norm/src/core/husky.ts":"5","/Users/lyh/Desktop/prTemp/web-norm/src/core/special.ts":"6","/Users/lyh/Desktop/prTemp/web-norm/src/core/vscode.ts":"7","/Users/lyh/Desktop/prTemp/web-norm/src/especial.ts":"8","/Users/lyh/Desktop/prTemp/web-norm/src/start.ts":"9","/Users/lyh/Desktop/prTemp/web-norm/src/templet/commitlint-no-emoji.config.ts":"10","/Users/lyh/Desktop/prTemp/web-norm/src/templet/commitlint.config.ts":"11","/Users/lyh/Desktop/prTemp/web-norm/src/templet/eslintrc.ts":"12","/Users/lyh/Desktop/prTemp/web-norm/src/templet/prettierrc.ts":"13","/Users/lyh/Desktop/prTemp/web-norm/src/utils/check.ts":"14","/Users/lyh/Desktop/prTemp/web-norm/src/utils/debug.ts":"15","/Users/lyh/Desktop/prTemp/web-norm/src/utils/env.ts":"16","/Users/lyh/Desktop/prTemp/web-norm/src/utils/path.ts":"17","/Users/lyh/Desktop/prTemp/web-norm/src/utils/tool.ts":"18"},{"size":1393,"mtime":1706596616917,"results":"19","hashOfConfig":"20"},{"size":1618,"mtime":1706596115913,"results":"21","hashOfConfig":"20"},{"size":2288,"mtime":1706596770553,"results":"22","hashOfConfig":"20"},{"size":321,"mtime":1706596115914,"results":"23","hashOfConfig":"20"},{"size":1486,"mtime":1706596853068,"results":"24","hashOfConfig":"20"},{"size":465,"mtime":1706596115915,"results":"25","hashOfConfig":"20"},{"size":2600,"mtime":1706596115916,"results":"26","hashOfConfig":"20"},{"size":109,"mtime":1706596730619,"results":"27","hashOfConfig":"20"},{"size":1534,"mtime":1658718641264,"results":"28","hashOfConfig":"20"},{"size":3365,"mtime":1706596115917,"results":"29","hashOfConfig":"20"},{"size":3438,"mtime":1706596115917,"results":"30","hashOfConfig":"20"},{"size":6353,"mtime":1706596115918,"results":"31","hashOfConfig":"20"},{"size":158,"mtime":1706596115918,"results":"32","hashOfConfig":"20"},{"size":979,"mtime":1706596115940,"results":"33","hashOfConfig":"20"},{"size":1183,"mtime":1706596115963,"results":"34","hashOfConfig":"20"},{"size":2178,"mtime":1706596621561,"results":"35","hashOfConfig":"20"},{"size":182,"mtime":1706596115997,"results":"36","hashOfConfig":"20"},{"size":2300,"mtime":1706596115921,"results":"37","hashOfConfig":"20"},{"filePath":"38","messages":"39","suppressedMessages":"40","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"1qmntqh",{"filePath":"41","messages":"42","suppressedMessages":"43","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"44","messages":"45","suppressedMessages":"46","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"47","messages":"48","suppressedMessages":"49","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"50","messages":"51","suppressedMessages":"52","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"53","messages":"54","suppressedMessages":"55","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"56","messages":"57","suppressedMessages":"58","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"59","messages":"60","suppressedMessages":"61","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"62","messages":"63","suppressedMessages":"64","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"65","messages":"66","suppressedMessages":"67","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"68","messages":"69","suppressedMessages":"70","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"71","messages":"72","suppressedMessages":"73","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"74","messages":"75","suppressedMessages":"76","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"77","messages":"78","suppressedMessages":"79","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"80","messages":"81","suppressedMessages":"82","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"83","messages":"84","suppressedMessages":"85","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"86","messages":"87","suppressedMessages":"88","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"89","messages":"90","suppressedMessages":"91","errorCount":1,"fatalErrorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/lyh/Desktop/prTemp/web-norm/src/cli.ts",["92"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/commitlint.ts",["93"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/eslint.ts",["94"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/eslintignore.ts",["95"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/husky.ts",["96"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/special.ts",["97"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/core/vscode.ts",["98"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/especial.ts",["99"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/start.ts",["100"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/templet/commitlint-no-emoji.config.ts",["101"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/templet/commitlint.config.ts",["102"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/templet/eslintrc.ts",["103"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/templet/prettierrc.ts",["104"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/utils/check.ts",["105"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/utils/debug.ts",["106"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/utils/env.ts",["107"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/utils/path.ts",["108"],[],"/Users/lyh/Desktop/prTemp/web-norm/src/utils/tool.ts",["109"],[],{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},{"ruleId":null,"fatal":true,"severity":2,"message":"110"},"Parsing error: Cannot find module 'babel-eslint'\nRequire stack:\n- /Users/lyh/Desktop/prTemp/web-norm/node_modules/vue-eslint-parser/index.js\n- /Users/lyh/Desktop/prTemp/web-norm/node_modules/eslint-plugin-vue/lib/utils/index.js\n- /Users/lyh/Desktop/prTemp/web-norm/node_modules/eslint-plugin-vue/lib/rules/array-bracket-newline.js\n- /Users/lyh/Desktop/prTemp/web-norm/node_modules/eslint-plugin-vue/lib/index.js\n- /Users/lyh/Desktop/prTemp/web-norm/node_modules/@eslint/eslintrc/dist/eslintrc.cjs"]
--------------------------------------------------------------------------------
/src/templet/eslintrc.ts:
--------------------------------------------------------------------------------
1 | import { getEnv } from '../utils/env'
2 | import { teepEslintConfig } from '../especial'
3 | function formatObject(obj: Object) {
4 | const objStr = JSON.stringify(obj, null, 2)
5 | return objStr.slice(1, -1).replace(/"/g, "'")
6 | }
7 | const especialRules = formatObject(teepEslintConfig.rules)
8 | function getBaseEslint(especial: boolean = false) {
9 | return `
10 | 'prettier/prettier': 'error',
11 | 'accessor-pairs': 2,
12 | 'arrow-spacing': [
13 | 2,
14 | {
15 | before: true,
16 | after: true
17 | }
18 | ],
19 | 'block-spacing': [2, 'always'],
20 | 'brace-style': [
21 | 2,
22 | '1tbs',
23 | {
24 | allowSingleLine: true
25 | }
26 | ],
27 | camelcase: [
28 | 0,
29 | {
30 | properties: 'always'
31 | }
32 | ],
33 | 'comma-dangle': [
34 | 'error',
35 | {
36 | arrays: 'never',
37 | objects: 'never',
38 | imports: 'never',
39 | exports: 'never',
40 | functions: 'never'
41 | }
42 | ],
43 | 'comma-spacing': [
44 | 2,
45 | {
46 | before: false,
47 | after: true
48 | }
49 | ],
50 | 'comma-style': [2, 'last'],
51 | 'constructor-super': 2,
52 | curly: [2, 'multi-line'],
53 | 'dot-location': [2, 'property'],
54 | 'eol-last': 2,
55 | eqeqeq: 2,
56 | 'generator-star-spacing': [
57 | 2,
58 | {
59 | before: true,
60 | after: true
61 | }
62 | ],
63 | 'handle-callback-err': [2, '^(err|error)$'],
64 | indent: 'off',
65 | 'key-spacing': [
66 | 2,
67 | {
68 | beforeColon: false,
69 | afterColon: true
70 | }
71 | ],
72 | 'keyword-spacing': [
73 | 2,
74 | {
75 | before: true,
76 | after: true
77 | }
78 | ],
79 | 'new-cap': [
80 | 2,
81 | {
82 | newIsCap: true,
83 | capIsNew: false
84 | }
85 | ],
86 | 'new-parens': 2,
87 | 'no-array-constructor': 2,
88 | 'no-caller': 2,
89 | 'no-console': 'off',
90 | 'no-class-assign': 2,
91 | 'no-cond-assign': 2,
92 | 'no-const-assign': 2,
93 | 'no-control-regex': 0,
94 | 'no-delete-var': 2,
95 | 'no-dupe-args': 2,
96 | 'no-dupe-class-members': 2,
97 | 'no-dupe-keys': 2,
98 | 'no-duplicate-case': 2,
99 | 'no-empty-character-class': 2,
100 | 'no-empty-pattern': 2,
101 | 'no-eval': 0,
102 | 'no-ex-assign': 2,
103 | 'no-extend-native': 2,
104 | 'no-extra-bind': 2,
105 | 'no-extra-boolean-cast': 2,
106 | 'no-extra-parens': [2, 'functions'],
107 | 'no-fallthrough': 2,
108 | 'no-floating-decimal': 2,
109 | 'no-func-assign': 2,
110 | 'no-implied-eval': 2,
111 | 'no-inner-declarations': [2, 'functions'],
112 | 'no-invalid-regexp': 2,
113 | 'no-irregular-whitespace': 2,
114 | 'no-iterator': 2,
115 | 'no-label-var': 2,
116 | 'no-labels': [
117 | 2,
118 | {
119 | allowLoop: false,
120 | allowSwitch: false
121 | }
122 | ],
123 | 'no-lone-blocks': 2,
124 | 'no-mixed-spaces-and-tabs': 2,
125 | 'no-multi-spaces': 2,
126 | 'no-multi-str': 2,
127 | 'no-multiple-empty-lines': [
128 | 2,
129 | {
130 | max: 1
131 | }
132 | ],
133 | 'no-native-reassign': 2,
134 | 'no-negated-in-lhs': 2,
135 | 'no-new-object': 2,
136 | 'no-new-require': 2,
137 | 'no-new-symbol': 2,
138 | 'no-new-wrappers': 2,
139 | 'no-obj-calls': 2,
140 | 'no-octal': 2,
141 | 'no-octal-escape': 2,
142 | 'no-path-concat': 2,
143 | 'no-proto': 2,
144 | 'no-redeclare': 2,
145 | 'no-regex-spaces': 2,
146 | 'no-return-assign': [2, 'except-parens'],
147 | 'no-self-assign': 2,
148 | 'no-self-compare': 2,
149 | 'no-sequences': 2,
150 | 'no-shadow-restricted-names': 2,
151 | 'no-spaced-func': 2,
152 | 'no-sparse-arrays': 2,
153 | 'no-this-before-super': 2,
154 | 'no-throw-literal': 2,
155 | 'no-trailing-spaces': 2,
156 | 'no-undef': 2,
157 | 'no-undef-init': 2,
158 | 'no-unexpected-multiline': 2,
159 | 'no-unmodified-loop-condition': 2,
160 | 'no-unneeded-ternary': [
161 | 2,
162 | {
163 | defaultAssignment: false
164 | }
165 | ],
166 | 'no-unreachable': 2,
167 | 'no-unsafe-finally': 2,
168 | 'no-unused-vars': [
169 | 2,
170 | {
171 | vars: 'all',
172 | args: 'none',
173 | varsIgnorePattern: '^_'
174 | }
175 | ],
176 | 'no-useless-call': 2,
177 | 'no-useless-computed-key': 2,
178 | 'no-useless-constructor': 2,
179 | 'no-useless-escape': 0,
180 | 'no-whitespace-before-property': 2,
181 | 'no-with': 2,
182 | 'one-var': [
183 | 2,
184 | {
185 | initialized: 'never'
186 | }
187 | ],
188 | 'operator-linebreak': [
189 | 2,
190 | 'after',
191 | {
192 | overrides: {
193 | '?': 'before',
194 | ':': 'before'
195 | }
196 | }
197 | ],
198 | 'padded-blocks': [2, 'never'],
199 | quotes: 'off',
200 | semi: 'off',
201 | 'semi-spacing': [
202 | 2,
203 | {
204 | before: false,
205 | after: true
206 | }
207 | ],
208 | 'space-before-blocks': [2, 'always'],
209 | 'space-before-function-paren': 'off',
210 | 'space-in-parens': [2, 'never'],
211 | 'space-infix-ops': 2,
212 | 'space-unary-ops': [
213 | 2,
214 | {
215 | words: true,
216 | nonwords: false
217 | }
218 | ],
219 | 'spaced-comment': 'off',
220 | 'template-curly-spacing': [2, 'never'],
221 | 'use-isnan': 2,
222 | 'valid-typeof': 2,
223 | 'wrap-iife': [2, 'any'],
224 | 'yield-star-spacing': [2, 'both'],
225 | yoda: [2, 'never'],
226 | 'prefer-const': 2,
227 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
228 | 'object-curly-spacing': [
229 | 0,
230 | 'always',
231 | {
232 | objectsInObjects: false
233 | }
234 | ],
235 | 'array-bracket-spacing': [2, 'never'],
236 | ${especial ? especialRules : ''}
237 | `
238 | }
239 |
240 | export const eslintrcFn = (especial?: boolean) => {
241 | // 其他
242 | let eslintrcInit = `
243 | module.exports = {
244 | root: true,
245 | parserOptions: {
246 | ecmaVersion: 11,
247 | parser: 'babel-eslint',
248 | sourceType: 'module',
249 | "ecmaFeatures": {
250 | "legacyDecorators": true
251 | }
252 | },
253 | env: {
254 | browser: true,
255 | node: true,
256 | es6: true
257 | },
258 | plugins: ['prettier'],
259 | extends: [ 'eslint:recommended', 'plugin:prettier/recommended'],
260 | rules: {
261 | ${getBaseEslint(especial)}
262 | }
263 | }
264 |
265 | `
266 | // vue2
267 | if (getEnv('isVue2')) {
268 | eslintrcInit = `
269 | module.exports = {
270 | root: true,
271 | parserOptions: {
272 | ecmaVersion: 11,
273 | parser: 'babel-eslint',
274 | sourceType: 'module',
275 | "ecmaFeatures": {
276 | "legacyDecorators": true
277 | }
278 | },
279 | env: {
280 | browser: true,
281 | node: true,
282 | es6: true
283 | },
284 | plugins: ['prettier'],
285 | extends: ['plugin:vue/recommended', 'eslint:recommended', 'plugin:prettier/recommended'],
286 | rules: {
287 | 'vue/order-in-components': 'off',
288 | 'vue/html-self-closing': 'off',
289 | 'vue/require-default-prop': 'off',
290 | 'vue/max-attributes-per-line': [
291 | 0,
292 | {
293 | singleline: 10,
294 | multiline: {
295 | max: 1,
296 | allowFirstLine: false
297 | }
298 | }
299 | ],
300 | 'vue/singleline-html-element-content-newline': 'off',
301 | 'vue/multiline-html-element-content-newline': 'off',
302 | 'vue/name-property-casing': ['error', 'PascalCase'],
303 | 'vue/no-v-html': 'off',
304 | ${getBaseEslint(especial)}
305 | }
306 | }`
307 | }
308 | if (getEnv('isVue3')) {
309 | // vue3
310 | eslintrcInit = `
311 | module.exports = {
312 | root: true,
313 | parserOptions: {
314 | ecmaVersion: 11,
315 | sourceType: 'module',
316 | parser: '@typescript-eslint/parser',
317 | "ecmaFeatures": {
318 | "legacyDecorators": true
319 | }
320 | },
321 | env: {
322 | browser: true,
323 | node: true,
324 | es6: true
325 | },
326 | plugins: ['prettier'],
327 | extends: ['plugin:vue/vue3-recommended', 'eslint:recommended', 'plugin:prettier/recommended'],
328 | rules: {
329 | 'vue/order-in-components': 'off',
330 | 'vue/html-self-closing': 'off',
331 | 'vue/require-default-prop': 'off',
332 | 'vue/max-attributes-per-line': [
333 | 0,
334 | {
335 | singleline: 10,
336 | multiline: {
337 | max: 1,
338 | allowFirstLine: false
339 | }
340 | }
341 | ],
342 | 'vue/singleline-html-element-content-newline': 'off',
343 | 'vue/multiline-html-element-content-newline': 'off',
344 | 'vue/name-property-casing': 'off',
345 | 'vue/no-v-html': 'off',
346 | ${getBaseEslint(especial)}
347 | }
348 | }
349 | `
350 | }
351 | if (getEnv('isReact')) {
352 | eslintrcInit = `
353 | module.exports = {
354 | root: true,
355 | parserOptions: {
356 | ecmaVersion: 11,
357 | sourceType: 'module',
358 | parser: '@typescript-eslint/parser',
359 | "ecmaFeatures": {
360 | "legacyDecorators": true
361 | }
362 | },
363 | env: {
364 | browser: true,
365 | node: true,
366 | es6: true
367 | },
368 | plugins: ['react', 'prettier', '@typescript-eslint/eslint-plugin', 'jsx-a11y'],
369 | extends: ['plugin:react/recommended', 'plugin:@typescript-eslint/recommended', 'eslint:recommended', 'plugin:prettier/recommended'],
370 | rules: {
371 | 'react/react-in-jsx-scope': 0,
372 | ${getBaseEslint(especial)}
373 | }
374 | }
375 | `
376 | }
377 | return eslintrcInit
378 | }
379 |
--------------------------------------------------------------------------------