pl-preset 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/dist/cli.js +1 -1
- package/package.json +12 -17
- package/template/.changelogrc.js +45 -0
- package/template/.czrc +66 -0
- package/template/.husky/commit-msg +1 -0
- package/template/.husky/pre-commit +1 -0
- package/template/.prettierrc +1 -1
- package/template/.stylelintrc.js +25 -21
- package/template/.vscode/extensions.json +2 -2
- package/template/eslint.config.js +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pl-preset
|
|
2
2
|
|
|
3
|
-
一键生成web
|
|
3
|
+
一键生成web项目常用设置简化配置过程
|
|
4
4
|
|
|
5
5
|
## 使用方式
|
|
6
6
|
|
|
@@ -11,3 +11,37 @@ npm install -g pl-preset
|
|
|
11
11
|
// 在项目根路径下执行
|
|
12
12
|
plp
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## 主要功能
|
|
16
|
+
|
|
17
|
+
### prettier
|
|
18
|
+
|
|
19
|
+
以prettier作为代码格式化工具,在项目根目录下生成.prettierrc文件
|
|
20
|
+
|
|
21
|
+
### Git设置
|
|
22
|
+
|
|
23
|
+
如果项目仓库是git那么会为项目配置husky进行提交前校验同时使用cz-conventional-changelog规范commit信息,通过`npm run c`进行代码提交
|
|
24
|
+
|
|
25
|
+
### 生成changelog
|
|
26
|
+
|
|
27
|
+
对于使用cz-conventional-changelog进行git提交的项目,可以选择性接入conventional-changelog-cli工具生成changelog文件,通过执行`npm run clog`生成changelog文件
|
|
28
|
+
|
|
29
|
+
### vscode设置
|
|
30
|
+
|
|
31
|
+
当前仅支持vscode编辑器相关设置,选择vscode后自动生成插件以及代码格式化相关配置信息
|
|
32
|
+
|
|
33
|
+
### 开发语言
|
|
34
|
+
|
|
35
|
+
支持选择javascript、typescript,自动生成eslint相关配置进行校验
|
|
36
|
+
|
|
37
|
+
### 样式语言
|
|
38
|
+
|
|
39
|
+
支持选择css、less、scss,自动生成stylelint配置对代码进行校验
|
|
40
|
+
|
|
41
|
+
### 框架
|
|
42
|
+
|
|
43
|
+
支持选择vue2、vue3、react,自动在eslint和stylelint中插入框架相关设置进行校验
|
|
44
|
+
|
|
45
|
+
### html文件校验
|
|
46
|
+
|
|
47
|
+
选择项目中是否包含html文件,在eslint和prettier配置中增加html相关内容
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("commander"),
|
|
2
|
+
"use strict";var e=require("commander"),s=require("chalk"),t=require("fs-extra"),r=require("path"),n=require("inquirer"),o=require("fs"),c=require("ejs"),l=require("child_process"),i=require("ora");function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,u,d,g,y,m,S,h,f,v,w,j,k,F,_={};function b(){if(u)return p;u=1;return p={SupportedEditor:{vscode:1,others:0},SupportedLanguage:{javascript:1,typescript:2,others:0},SupportedStyleSheets:{css:1,less:2,scss:3,others:0},SupportedFramework:{vue2:1,vue3:2,react:3,others:0}}}function L(){if(g)return d;g=1;const e=t,n=s,l=r,i=o,a=c,{SupportedEditor:p,SupportedLanguage:u,SupportedStyleSheets:y,SupportedFramework:m}=b();return d={apply:s=>{console.log(n.blue("生成编辑器设置..."));const{editorType:t}=s;t!==p.others&&t===p.VSCode&&(({language:s,framework:t,styleSheets:r,includeHtml:n})=>{const o=l.resolve(__dirname,"../template/.vscode/settings.json"),c=a.render(i.readFileSync(o,"utf-8"),{supportedLanguage:u,language:s,styleSheets:r,supportedStyleSheets:y,framework:t,supportedFramework:m,html:n}),p=l.resolve(process.cwd(),"./.vscode/settings.json");e.ensureFileSync(p),i.writeFileSync(p,c,"utf-8");const d=l.resolve(__dirname,"../template/.vscode/extensions.json"),g=a.render(i.readFileSync(d,"utf-8"),{style:r!==y.others,vue:t===m.vue2||t===m.vue3}),S=l.resolve(process.cwd(),"./.vscode/extensions.json");e.ensureFileSync(S),i.writeFileSync(S,g,"utf-8")})(s)}}}function O(){if(v)return f;v=1;const e=c,n=r,l=o,i=t,a=s,{SupportedLanguage:p,SupportedStyleSheets:u,SupportedFramework:d}=b();return f={apply:({framework:s,styleSheets:t,language:r})=>{if(r!==p.others){console.log(a.blue("生成 ESLint 配置文件..."));try{(()=>{const t="module"===i.readJSONSync(n.resolve(process.cwd(),"./package.json")).type?"eslint.config.cjs":"eslint.config.js",o=n.resolve(__dirname,"../template/eslint.config.js"),c=e.render(l.readFileSync(o,"utf-8"),{language:r,framework:s,supportedFramework:d,supportedLanguage:p}),a=n.resolve(process.cwd(),"./",t);i.ensureFileSync(a),i.writeFileSync(a,c,"utf-8")})()}catch(e){throw new Error("生成ESLint配置文件失败: ",e.message)}}if(t!==u.others){console.log(a.blue("生成 Stylelint 配置文件..."));try{(()=>{const r=n.resolve(__dirname,"../template/.stylelintrc.js"),o=e.render(l.readFileSync(r,"utf-8"),{supportedStyleSheets:u,styleSheets:t,vue:s===d.vue2||s===d.vue3}),c=n.resolve(process.cwd(),"./.stylelintrc.js");i.ensureFileSync(c),i.writeFileSync(c,o,"utf-8")})()}catch(e){throw new Error("生成Stylelint配置文件失败: ",e.message)}}}}}function x(){if(F)return k;F=1;const e=s,a=t,p=r,u=n,{SupportedEditor:d,SupportedLanguage:g,SupportedStyleSheets:f,SupportedFramework:v}=b(),{apply:_}=L(),{apply:x}=function(){if(m)return y;m=1;const e=r,s=t,{SupportedStyleSheets:n}=b();return y={apply:({styleSheets:t,isUseGit:r,isNeedChangeLog:o})=>{if(!r||!o)return;const c=e.resolve(process.cwd(),"./package.json"),l=s.readJsonSync(c);if(l.scripts=Object.assign({},l.scripts,{c:"cz"}),l["lint-staged"]={"*.{js,ts,tsx,jsx}":"eslint"},t!==n.others&&(l["lint-staged"]["*.{css,less,scss}"]="stylelint"),o){l.scripts=Object.assign({},l.scripts,{clog:"conventional-changelog -n ./.changelogrc.js -p angular -i CHANGELOG.md -s"});const t=e.resolve(__dirname,"../template/.changelogrc.js");s.copyFileSync(t,e.resolve(process.cwd(),"./.changelogrc.js"))}s.writeJsonSync(c,l,{spaces:"\t"});const i=e.resolve(__dirname,"../template/.czrc");s.copyFileSync(i,e.resolve(process.cwd(),"./.czrc"));const a=e.resolve(__dirname,"../template/commitlint.config.js");s.copyFileSync(a,e.resolve(process.cwd(),"./commitlint.config.js"));const p=e.resolve(__dirname,"../template/.husky");s.copySync(p,e.resolve(process.cwd(),"./.husky"))}}}(),{apply:q}=function(){if(h)return S;h=1;const e=t,n=s,l=r,i=o,a=c,{SupportedStyleSheets:p}=b();return S={apply:({styleSheets:s})=>{console.log(n.blue("生成 Prettier 配置文件..."));const t=l.resolve(__dirname,"../template/.prettierrc"),r=a.render(i.readFileSync(t,"utf-8"),{supportedStyleSheets:p,styleSheets:s}),o=l.resolve(process.cwd(),"./.prettierrc");e.ensureFileSync(o),i.writeFileSync(o,r,"utf-8")}}}(),{apply:E}=O(),{apply:N}=function(){if(j)return w;j=1;const{exec:e}=l,n=t,o=r,c=s,a=i,{SupportedLanguage:p,SupportedFramework:u,SupportedStyleSheets:d}=b(),g=[["prettier","^3.6.2"]],y=[["@commitlint/cli","^19.8.1"],["@commitlint/config-conventional","^19.8.1"],["@commitlint/prompt-cli","^20.1.0"],["commitizen","^4.3.1"],["cz-conventional-changelog","^3.3.0"],["husky","^9.1.7"],["lint-staged","^16.1.2"]],m=[["conventional-changelog-cli","^4.1.0"]],S=[["stylelint-config-html","^1.1.0"]],h=[["eslint","^9.39.1"],["eslint-config-prettier","^9.1.2"],["eslint-plugin-prettier","^5.5.4"],["@babel/eslint-parser","^7.12.16"],["@babel/preset-env","^7.28.5"]],f=[["@typescript-eslint/eslint-plugin","^8.46.3"],["@typescript-eslint/parser","^8.46.3"]],v=[["stylelint","^15.10.3"],["stylelint-config-recess-order","^4.6.0"],["stylelint-config-standard","^34.0.0"]],k=[["postcss-scss","^4.0.9"],["stylelint-config-recommended-scss","^12.0.0"],["stylelint-scss","^5.3.2"]],F=[["postcss-less","^6.0.0"],["stylelint-config-recommended-less","^2.0.0"],["stylelint-less","^1.0.6"]],_=[["postcss-html","^1.8.0"],["eslint-plugin-vue","^9.33.0"],["stylelint-config-html","^1.1.0"],["vue-eslint-parser","^9.4.3"]],L=[["postcss-html","^1.8.0"],["stylelint-config-html","^1.1.0"],["eslint-plugin-vue","^9.33.0"],["vue-eslint-parser","^9.4.3"]],O=[["eslint-plugin-react","^7.37.5"],["eslint-plugin-react-hooks","^5.2.0"]];return w={apply:({language:s,framework:t,styleSheets:r,includeHtml:l,isUseGit:i,isNeedChangeLog:w})=>{console.log(c.blue("安装依赖包..."));const j=g.slice();i&&(j.push(...y),w&&j.push(...m)),l&&j.push(...S),s!==p.others&&j.push(...h),s===p.typescript&&j.push(...f),t===u.vue2?j.push(..._):t===u.vue3?j.push(...L):t===u.react&&j.push(...O),r!==d.others&&(j.push(...v),r===d.scss?j.push(...k):r===d.less&&j.push(...F));const b=o.join(process.cwd(),"package.json");if(!n.existsSync(b))return void console.log(c.red("缺少package.json文件"));const x=n.readJSONSync(b),q=x.devDependencies=x.devDependencies||{},E=x.dependencies=x.dependencies||{};for(let[e,s]of j)q[e]=s,delete E[e];n.writeJSONSync(b,x,{encoding:"utf-8",spaces:"\t"});const N=["pnpm-lock.yaml","yarn.lock","package-lock.json"];let G="npm install";for(const e of N)if(n.existsSync(o.resolve(process.cwd(),`./${e}`))){"pnpm-lock.yaml"===e?G="pnpm install":"yarn.lock"===e&&(G="yarn install");break}const z=a(">>>>>> 安装依赖 >>>>>>\n").start();e(G,e=>{e&&(console.log(c.red(e)),z.fail("安装失败")),z.succeed("安装完成")}).on("close",e=>{0===e?z.succeed("安装完成"):z.fail("安装失败")})}},w}();return k={run:async()=>{const s=p.resolve(process.cwd(),"./package.json");if(!a.existsSync(s))return void console.log(e.red("请在工程目录下执行命令"));const t=p.resolve(process.cwd(),".editorconfig");if(a.existsSync(t)){(await u.prompt([{type:"confirm",name:"remove",message:"默认采用Prettier进行代码格式化,项目中检测到的.editorconfig文件可能会造成干扰,是否删除:",default:!1}])).remove&&a.removeSync(t)}const r=await u.prompt([{type:"confirm",name:"isUseGit",message:"是否使用git作为代码仓库:",default:!0},{type:"confirm",name:"isNeedChangeLog",message:"是否需要生成changelog:",default:!1,when:e=>!0===e.isUseGit},{type:"list",name:"editor",message:"请选择使用的编辑器:",choices:()=>Object.entries(d).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"language",message:"请选择编程语音:",choices:()=>Object.entries(g).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"styleSheets",message:"请选择样式语言:",choices:()=>Object.entries(f).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"framework",message:"请选择编程框架:",choices:()=>Object.entries(v).map(([e,s])=>({name:e,value:s}))},{type:"confirm",name:"includeHtml",message:"是否包含html:",default:!1}]);try{_(r)}catch(s){console.log(e.red("编辑器配置生成失败:"),s)}try{x(r)}catch(s){console.log(e.red("配置git校验失败:"),s)}try{q(r)}catch(s){console.log(e.red("Prettier配置生成失败:"),s)}try{E(r)}catch(s){console.log(e.red(s))}try{N(r)}catch(s){console.log(e.red("依赖安装失败:"),s)}}}}var q,E={version:"0.0.9"};var N=a(function(){if(q)return _;q=1;const{program:s}=e,{run:t}=x(),r=E;return s.version(r.version),s.usage("<command>"),s.command("default",{isDefault:!0}).action(()=>{t()}),s.parse(process.argv),_}());module.exports=N;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pl-preset",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"bin": {
|
|
5
5
|
"plp": "dist/cli.js"
|
|
6
6
|
},
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"beta": "run-s build publish:beta",
|
|
12
12
|
"release": "run-s build publish:prod",
|
|
13
13
|
"publish:prod": "npm publish",
|
|
14
|
-
"publish:beta": "npm publish --tag beta"
|
|
14
|
+
"publish:beta": "npm publish --tag beta",
|
|
15
|
+
"clog": "conventional-changelog -n ./.changelogrc.js -p angular -i CHANGELOG.md -s"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"dist",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"stylelint"
|
|
31
32
|
],
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@babel/eslint-parser": "^7.
|
|
34
|
+
"@babel/eslint-parser": "^7.12.16",
|
|
34
35
|
"@babel/preset-env": "^7.28.5",
|
|
35
36
|
"@commitlint/cli": "^19.8.1",
|
|
36
37
|
"@commitlint/config-conventional": "^19.8.1",
|
|
@@ -40,11 +41,16 @@
|
|
|
40
41
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
41
42
|
"@rollup/plugin-terser": "^0.4.4",
|
|
42
43
|
"cz-conventional-changelog": "^3.3.0",
|
|
43
|
-
"eslint": "^9.39.
|
|
44
|
-
"eslint-plugin-prettier": "^5.5.
|
|
44
|
+
"eslint": "^9.39.1",
|
|
45
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
45
46
|
"npm-run-all": "^4.1.5",
|
|
46
47
|
"prettier": "^3.6.2",
|
|
47
|
-
"rollup": "^4.52.5"
|
|
48
|
+
"rollup": "^4.52.5",
|
|
49
|
+
"commitizen": "^4.3.1",
|
|
50
|
+
"husky": "^9.1.7",
|
|
51
|
+
"lint-staged": "^16.1.2",
|
|
52
|
+
"conventional-changelog-cli": "^4.1.0",
|
|
53
|
+
"eslint-config-prettier": "^9.1.2"
|
|
48
54
|
},
|
|
49
55
|
"dependencies": {
|
|
50
56
|
"chalk": "^4.1.2",
|
|
@@ -54,17 +60,6 @@
|
|
|
54
60
|
"inquirer": "^8.2.4",
|
|
55
61
|
"ora": "^5.4.1"
|
|
56
62
|
},
|
|
57
|
-
"husky": {
|
|
58
|
-
"hooks": {
|
|
59
|
-
"pre-commit": "lint-staged",
|
|
60
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"config": {
|
|
64
|
-
"commitizen": {
|
|
65
|
-
"path": "cz-conventional-changelog"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
63
|
"lint-staged": {
|
|
69
64
|
"*.{js,ts,tsx,jsx}": "eslint"
|
|
70
65
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// 内容格式模板
|
|
2
|
+
const mainTemplate = `{{> header}}
|
|
3
|
+
|
|
4
|
+
{{#each commitGroups}}
|
|
5
|
+
|
|
6
|
+
{{#if title}}
|
|
7
|
+
### {{title}}
|
|
8
|
+
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#each commits}}
|
|
11
|
+
{{> commit root=@root}}
|
|
12
|
+
{{/each}}
|
|
13
|
+
{{/each}}
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
const headerPartial = `{{#if isPatch}}##{{else}}#{{/if}} {{#if @root.linkCompare}}[{{version}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/compare/{{previousTag}}...{{currentTag}}){{else}}{{version}}{{/if}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}}`
|
|
17
|
+
const commitPartial = `* {{#if message}}{{message}}{{else}}{{header}}{{/if}}
|
|
18
|
+
|
|
19
|
+
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{shortHash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
|
|
20
|
+
|
|
21
|
+
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}
|
|
22
|
+
`
|
|
23
|
+
// 需要输出到changelog的提交类型
|
|
24
|
+
const types = ['feat', 'fix']
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
writerOpts: {
|
|
28
|
+
mainTemplate,
|
|
29
|
+
headerPartial,
|
|
30
|
+
commitPartial,
|
|
31
|
+
transform: commit => {
|
|
32
|
+
commit.shortHash = commit.hash.substring(0, 8)
|
|
33
|
+
|
|
34
|
+
if (types.includes(commit.type)) {
|
|
35
|
+
return commit
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null
|
|
39
|
+
},
|
|
40
|
+
// 自定义分组
|
|
41
|
+
groupBy: 'type',
|
|
42
|
+
// 提交排序
|
|
43
|
+
commitsSort: ['scope', 'subject']
|
|
44
|
+
}
|
|
45
|
+
}
|
package/template/.czrc
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"path": "cz-conventional-changelog",
|
|
3
|
+
"disableScopeLowerCase": false,
|
|
4
|
+
"disableSubjectLowerCase": false,
|
|
5
|
+
"maxHeaderWidth": 100,
|
|
6
|
+
"maxLineWidth": 100,
|
|
7
|
+
"defaultType": "",
|
|
8
|
+
"defaultScope": "",
|
|
9
|
+
"defaultSubject": "",
|
|
10
|
+
"defaultBody": "",
|
|
11
|
+
"defaultIssues": "",
|
|
12
|
+
"types": {
|
|
13
|
+
"refactor": {
|
|
14
|
+
"description": "🤡 代码重构(常规保存性提交)",
|
|
15
|
+
"title": "Code Refactoring",
|
|
16
|
+
"hidden": true
|
|
17
|
+
},
|
|
18
|
+
"feat": {
|
|
19
|
+
"description": "✨ 新增功能",
|
|
20
|
+
"title": "Features"
|
|
21
|
+
},
|
|
22
|
+
"fix": {
|
|
23
|
+
"description": "🐛 修复bug",
|
|
24
|
+
"title": "Bug Fixes"
|
|
25
|
+
},
|
|
26
|
+
"docs": {
|
|
27
|
+
"description": "📝 文档更新",
|
|
28
|
+
"title": "Documentation",
|
|
29
|
+
"hidden": true
|
|
30
|
+
},
|
|
31
|
+
"style": {
|
|
32
|
+
"description": "💎 代码格式调整(不影响代码运行)",
|
|
33
|
+
"title": "Styles",
|
|
34
|
+
"hidden": true
|
|
35
|
+
},
|
|
36
|
+
"perf": {
|
|
37
|
+
"description": "🚀 性能优化",
|
|
38
|
+
"title": "Performance Improvements"
|
|
39
|
+
},
|
|
40
|
+
"test": {
|
|
41
|
+
"description": "✅ 测试相关",
|
|
42
|
+
"title": "Tests",
|
|
43
|
+
"hidden": true
|
|
44
|
+
},
|
|
45
|
+
"build": {
|
|
46
|
+
"description": "📦 构建系统或外部依赖的更改",
|
|
47
|
+
"title": "Build System",
|
|
48
|
+
"hidden": true
|
|
49
|
+
},
|
|
50
|
+
"ci": {
|
|
51
|
+
"description": "👷 CI配置文件和脚本的更改",
|
|
52
|
+
"title": "Continuous Integration",
|
|
53
|
+
"hidden": true
|
|
54
|
+
},
|
|
55
|
+
"chore": {
|
|
56
|
+
"description": "🔧 其他不修改src或测试文件的更改",
|
|
57
|
+
"title": "Chores",
|
|
58
|
+
"hidden": true
|
|
59
|
+
},
|
|
60
|
+
"revert": {
|
|
61
|
+
"description": "⏪ 回滚提交",
|
|
62
|
+
"title": "Reverts",
|
|
63
|
+
"hidden": true
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
commitlint --edit $1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lint-staged
|
package/template/.prettierrc
CHANGED
package/template/.stylelintrc.js
CHANGED
|
@@ -11,13 +11,36 @@ module.exports = {
|
|
|
11
11
|
'stylelint-config-standard',
|
|
12
12
|
'stylelint-config-recess-order'
|
|
13
13
|
],
|
|
14
|
+
<%_ if (styleSheets == supportedStyleSheets.scss || styleSheets == supportedStyleSheets.less) { _%>
|
|
14
15
|
plugins: [
|
|
15
16
|
<%_ if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
16
17
|
'stylelint-scss'
|
|
17
|
-
<%_ } else
|
|
18
|
+
<%_ } else { _%>
|
|
18
19
|
'stylelint-less'
|
|
19
20
|
<%_ } _%>
|
|
20
21
|
],
|
|
22
|
+
<%_ } _%>
|
|
23
|
+
<%_ if (vue || styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss) { _%>
|
|
24
|
+
overrides: [
|
|
25
|
+
<%_ if (vue) { _%>
|
|
26
|
+
{
|
|
27
|
+
files: ['**/*.vue'],
|
|
28
|
+
customSyntax: 'postcss-html'
|
|
29
|
+
}<%= styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss ? ',' : ''%>
|
|
30
|
+
<%_ } _%>
|
|
31
|
+
<%_ if (styleSheets == supportedStyleSheets.less) { _%>
|
|
32
|
+
{
|
|
33
|
+
files: ['**/*.less'],
|
|
34
|
+
customSyntax: 'postcss-less'
|
|
35
|
+
}
|
|
36
|
+
<%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
37
|
+
{
|
|
38
|
+
files: ['**/*.scss'],
|
|
39
|
+
customSyntax: 'postcss-scss'
|
|
40
|
+
}
|
|
41
|
+
<%_ } _%>
|
|
42
|
+
],
|
|
43
|
+
<%_ } _%>
|
|
21
44
|
rules: {
|
|
22
45
|
<%_ if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
23
46
|
// SCSS嵌套语法检查
|
|
@@ -104,24 +127,5 @@ module.exports = {
|
|
|
104
127
|
// 规则集大括号里的内容排序方式
|
|
105
128
|
'order/properties-order': null,
|
|
106
129
|
'order/properties-alphabetical-order': true
|
|
107
|
-
}
|
|
108
|
-
overrides: [
|
|
109
|
-
<%_ if (vue) { _%>
|
|
110
|
-
{
|
|
111
|
-
files: ['**/*.vue'],
|
|
112
|
-
customSyntax: 'postcss-html'
|
|
113
|
-
}<%= styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss ? ',' : ''%>
|
|
114
|
-
<%_ } _%>
|
|
115
|
-
<%_ if (styleSheets == supportedStyleSheets.less) { _%>
|
|
116
|
-
{
|
|
117
|
-
files: ['**/*.less'],
|
|
118
|
-
customSyntax: 'postcss-less'
|
|
119
|
-
}
|
|
120
|
-
<%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
121
|
-
{
|
|
122
|
-
files: ['**/*.scss'],
|
|
123
|
-
customSyntax: 'postcss-scss'
|
|
124
|
-
}
|
|
125
|
-
<%_ } _%>
|
|
126
|
-
]
|
|
130
|
+
}
|
|
127
131
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"recommendations": [
|
|
3
3
|
"esbenp.prettier-vscode",
|
|
4
|
-
"dbaeumer.vscode-eslint",
|
|
5
4
|
<%_ if (style) { _%>
|
|
6
5
|
"stylelint.vscode-stylelint",
|
|
7
6
|
<%_ } _%>
|
|
8
7
|
<%_ if (vue) { _%>
|
|
9
|
-
"octref.vetur"
|
|
8
|
+
"octref.vetur",
|
|
10
9
|
<%_ } _%>
|
|
10
|
+
"dbaeumer.vscode-eslint"
|
|
11
11
|
]
|
|
12
12
|
}
|
|
@@ -22,7 +22,7 @@ module.exports = [
|
|
|
22
22
|
<%_ if(language == supportedLanguage.typescript) { _%>
|
|
23
23
|
// TypeScript 配置
|
|
24
24
|
{
|
|
25
|
-
files: [
|
|
25
|
+
files: [<%- framework == supportedFramework.react ? '\'**/*.tsx\', ' : ''-%>'**/*.ts'],
|
|
26
26
|
plugins: {
|
|
27
27
|
<%_ if (framework == supportedFramework.react) { _%>
|
|
28
28
|
react: reactPlugin,
|
|
@@ -40,7 +40,7 @@ module.exports = [
|
|
|
40
40
|
jsx: true
|
|
41
41
|
},
|
|
42
42
|
<%_ } _%>
|
|
43
|
-
project:
|
|
43
|
+
project: './tsconfig.json'
|
|
44
44
|
},
|
|
45
45
|
sourceType: 'module',
|
|
46
46
|
globals: { ...globals.browser, ...globals.node, ...globals.es2020 }
|
|
@@ -124,7 +124,7 @@ module.exports = [
|
|
|
124
124
|
<%_ } _%>
|
|
125
125
|
// 基础 JavaScript 配置
|
|
126
126
|
{
|
|
127
|
-
files: ['**/*.js'
|
|
127
|
+
files: ['**/*.js'<%- framework == supportedFramework.react ? ' ,\'**/*.jsx\'' : '' -%>],
|
|
128
128
|
languageOptions: {
|
|
129
129
|
ecmaVersion: 'latest',
|
|
130
130
|
sourceType: 'module',
|