pl-preset 0.0.1 → 0.0.2
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 +1 -1
- package/package.json +14 -3
- package/template/.prettierrc +19 -0
- package/template/.stylelintrc.js +119 -0
- package/template/.vscode/extensions.json +12 -0
- package/template/.vscode/settings.json +53 -0
- package/template/commitlint.config.js +3 -0
- package/template/eslint.config.js +182 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pl-preset",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"bin": {
|
|
5
5
|
"plp": "dist/cli.js"
|
|
6
6
|
},
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rollup -c rollup.config.js",
|
|
9
9
|
"dev": "rollup -c rollup.config.js -w",
|
|
10
|
-
"c": "cz"
|
|
10
|
+
"c": "cz",
|
|
11
|
+
"beta": "run-p build publish:beta",
|
|
12
|
+
"release": "run-p build publish:prod",
|
|
13
|
+
"publish:prod": "npm publish",
|
|
14
|
+
"publish:beta": "npm publish --tag beta"
|
|
11
15
|
},
|
|
12
16
|
"files": [
|
|
13
17
|
"dist",
|
|
14
|
-
"
|
|
18
|
+
"template",
|
|
15
19
|
"package.json",
|
|
16
20
|
"README.md"
|
|
17
21
|
],
|
|
@@ -19,6 +23,12 @@
|
|
|
19
23
|
"author": "Chad.Ding",
|
|
20
24
|
"license": "MIT",
|
|
21
25
|
"description": "A cli tool to generate project common settings quickly.",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"prettier",
|
|
28
|
+
"commitlint",
|
|
29
|
+
"eslint",
|
|
30
|
+
"stylelint"
|
|
31
|
+
],
|
|
22
32
|
"devDependencies": {
|
|
23
33
|
"@babel/eslint-parser": "^7.28.5",
|
|
24
34
|
"@babel/preset-env": "^7.28.5",
|
|
@@ -29,6 +39,7 @@
|
|
|
29
39
|
"@rollup/plugin-json": "^6.1.0",
|
|
30
40
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
31
41
|
"cz-conventional-changelog": "^3.3.0",
|
|
42
|
+
"npm-run-all": "^4.1.5",
|
|
32
43
|
"prettier": "^3.6.2",
|
|
33
44
|
"rollup": "^4.52.5"
|
|
34
45
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"semi": false,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"trailingComma": "none",
|
|
5
|
+
"printWidth": 100,
|
|
6
|
+
"arrowParens": "avoid",
|
|
7
|
+
"useTabs": true,
|
|
8
|
+
"tabWidth": 4<%= styleSheets != supportedStyleSheets.others ? ',' : ''%>
|
|
9
|
+
<%_ if (styleSheets != supportedStyleSheets.others) { _%>
|
|
10
|
+
"overrides": [
|
|
11
|
+
{
|
|
12
|
+
"files": ["**/*.css", "**/*.scss", "**/*.less"],
|
|
13
|
+
"options": {
|
|
14
|
+
"singleQuote": false
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
<%_ } _%>
|
|
19
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
<%_ if (styleSheets == supportedStyleSheets.less) { _%>
|
|
4
|
+
'stylelint-config-recommended-less',
|
|
5
|
+
<%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
6
|
+
'stylelint-config-recommended-scss',
|
|
7
|
+
<%_ } _%>
|
|
8
|
+
<%_ if (vue) { _%>
|
|
9
|
+
'stylelint-config-html/vue',
|
|
10
|
+
<%_ } _%>
|
|
11
|
+
'stylelint-config-standard',
|
|
12
|
+
'stylelint-config-recess-order'
|
|
13
|
+
],
|
|
14
|
+
plugins: [
|
|
15
|
+
<%_ if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
16
|
+
'stylelint-scss',
|
|
17
|
+
<%_ } else if (styleSheets == supportedStyleSheets.less) { _%>
|
|
18
|
+
'stylelint-less',
|
|
19
|
+
<%_ } _%>
|
|
20
|
+
'stylelint-order'
|
|
21
|
+
],
|
|
22
|
+
rules: {
|
|
23
|
+
<%_ if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
24
|
+
// SCSS嵌套语法检查
|
|
25
|
+
'scss/at-extend-no-missing-placeholder': true,
|
|
26
|
+
'scss/at-import-no-partial-leading-underscore': true,
|
|
27
|
+
'scss/at-import-partial-extension-blacklist': ['scss', 'sass'],
|
|
28
|
+
'scss/dollar-variable-pattern': [
|
|
29
|
+
'^[a-z0-9\\-_]+$',
|
|
30
|
+
{
|
|
31
|
+
message: '变量名只能由小写字母、数字、中划线和下划线组成'
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
<%_ } else if (styleSheets == supportedStyleSheets.less) {_%>
|
|
35
|
+
// Less 语法检查规则
|
|
36
|
+
'less/color-no-invalid-hex': true,
|
|
37
|
+
'less/color-hex-case': 'lower',
|
|
38
|
+
<%_ } _%>
|
|
39
|
+
'value-keyword-case': null,
|
|
40
|
+
// 处理 Tailwind CSS 的 at-rule
|
|
41
|
+
'at-rule-no-unknown': [
|
|
42
|
+
true,
|
|
43
|
+
{
|
|
44
|
+
ignoreAtRules: ['apply', 'layer', 'responsive', 'screen', 'tailwind', 'variants']
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
'declaration-block-trailing-semicolon': null,
|
|
48
|
+
'no-descending-specificity': null,
|
|
49
|
+
// 不支持浏览器前缀,自行使用autoprefixer添加
|
|
50
|
+
'at-rule-no-vendor-prefix': true,
|
|
51
|
+
'media-feature-name-no-vendor-prefix': true,
|
|
52
|
+
'property-no-vendor-prefix': true,
|
|
53
|
+
'selector-no-vendor-prefix': true,
|
|
54
|
+
'value-no-vendor-prefix': true,
|
|
55
|
+
// 多行规则前总是有空行
|
|
56
|
+
'rule-empty-line-before': [
|
|
57
|
+
'always-multi-line',
|
|
58
|
+
{
|
|
59
|
+
except: ['first-nested'],
|
|
60
|
+
ignore: ['after-comment']
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
// 最大嵌套深度
|
|
64
|
+
'max-nesting-depth': [
|
|
65
|
+
5,
|
|
66
|
+
{
|
|
67
|
+
ignoreAtRules: ['media', 'each', 'supports', 'include']
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
// 匹配规则中不限制选择器的个数
|
|
71
|
+
'selector-max-compound-selectors': null,
|
|
72
|
+
// 匹配规则中最多只能出现一个id选择器
|
|
73
|
+
'selector-max-id': 1,
|
|
74
|
+
// 禁止用元素选择器来修饰某个选择器
|
|
75
|
+
'selector-no-qualifying-type': [
|
|
76
|
+
true,
|
|
77
|
+
{
|
|
78
|
+
ignore: ['attribute', 'class']
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
// 类选择器模式,类名只能由小写字母、数字和连字符组成
|
|
82
|
+
'selector-class-pattern': [
|
|
83
|
+
'^[a-z0-9\\-_]+$',
|
|
84
|
+
{
|
|
85
|
+
message: '类名只能由小写字母、数字、中划线和下划线组成'
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
// 禁止未知的伪元素
|
|
89
|
+
'selector-pseudo-element-no-unknown': [true],
|
|
90
|
+
// 禁止颜色名称
|
|
91
|
+
'color-named': 'never',
|
|
92
|
+
// url()中地址必须使用引号
|
|
93
|
+
'function-url-quotes': 'always',
|
|
94
|
+
// 能简写的属性尽量简写,禁止冗余的值
|
|
95
|
+
'shorthand-property-no-redundant-values': true,
|
|
96
|
+
// 规则集大括号里的内容排序方式
|
|
97
|
+
'order/properties-order': null,
|
|
98
|
+
'order/properties-alphabetical-order': true
|
|
99
|
+
},
|
|
100
|
+
overrides: [
|
|
101
|
+
<%_ if (vue) { _%>
|
|
102
|
+
{
|
|
103
|
+
files: ['**/*.vue'],
|
|
104
|
+
customSyntax: 'postcss-html'
|
|
105
|
+
}<%= styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss ? ',' : ''%>
|
|
106
|
+
<%_ } _%>
|
|
107
|
+
<%_ if (styleSheets == supportedStyleSheets.less) { _%>
|
|
108
|
+
{
|
|
109
|
+
files: ['**/*.less'],
|
|
110
|
+
customSyntax: 'postcss-less'
|
|
111
|
+
}
|
|
112
|
+
<%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
|
|
113
|
+
{
|
|
114
|
+
files: ['**/*.scss'],
|
|
115
|
+
customSyntax: 'postcss-scss'
|
|
116
|
+
}
|
|
117
|
+
<%_ } _%>
|
|
118
|
+
]
|
|
119
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
<%_ if (framework == supportedFramework.vue2 || framework == supportedFramework.vue3) { _%>
|
|
3
|
+
"[vue]": {
|
|
4
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
5
|
+
},
|
|
6
|
+
<%_ } _%>
|
|
7
|
+
<%_ if (language == supportedLanguage.typescript) { _%>
|
|
8
|
+
"[typescript]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
<%_ } else if (language == supportedLanguage.javascript) { _%>
|
|
12
|
+
"[javascript]": {
|
|
13
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
14
|
+
},
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
<%_ if (styleSheets == supportedStyleSheets.css) { _%>
|
|
17
|
+
"css.validate": false,
|
|
18
|
+
"[css]": {
|
|
19
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
20
|
+
},
|
|
21
|
+
<%_ } else if (styleSheets === supportedStyleSheets.scss) { _%>
|
|
22
|
+
"scss.validate": false,
|
|
23
|
+
"[scss]": {
|
|
24
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
25
|
+
},
|
|
26
|
+
<%_ } else if (styleSheets === supportedStyleSheets.less) { _%>
|
|
27
|
+
"less.validate": false,
|
|
28
|
+
"[less]": {
|
|
29
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
30
|
+
},
|
|
31
|
+
<%_ } _%>
|
|
32
|
+
"eslint.validate": [
|
|
33
|
+
<%_ if (framework == supportedFramework.react) { _%>
|
|
34
|
+
"javascriptreact",
|
|
35
|
+
"typescriptreact",
|
|
36
|
+
<%_ } _%>
|
|
37
|
+
"javascript",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"stylelint.validate": ["css", "scss", "vue", "less", "postcss"],
|
|
41
|
+
"files.eol": "\n",
|
|
42
|
+
"files.insertFinalNewline": true,
|
|
43
|
+
"editor.formatOnSave": true,
|
|
44
|
+
"editor.codeActionsOnSave": {
|
|
45
|
+
"source.fixAll": "explicit"
|
|
46
|
+
},
|
|
47
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
48
|
+
"javascript.format.enable": false,
|
|
49
|
+
"vetur.format.enable": false,
|
|
50
|
+
"editor.formatOnPaste": true,
|
|
51
|
+
"editor.formatOnType": true,
|
|
52
|
+
"prettier.useTabs": true
|
|
53
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
const js = require('@eslint/js')
|
|
2
|
+
const globals = require('globals')
|
|
3
|
+
const eslintParser = require('@babel/eslint-parser')
|
|
4
|
+
const eslintPretterPlugin = require('eslint-plugin-prettier')
|
|
5
|
+
<%_ if(language == supportedLanguage.typescript) { _%>
|
|
6
|
+
const tsParser = require('@typescript-eslint/parser')
|
|
7
|
+
const tsPlugin = require('@typescript-eslint/eslint-plugin')
|
|
8
|
+
<%_ } _%>
|
|
9
|
+
<%_ if (framework == supportedFramework.vue2 || framework == supportedFramework.vue3) { _%>
|
|
10
|
+
const vuePlugin = require('eslint-plugin-vue')
|
|
11
|
+
const vueParser = require('vue-eslint-parser')
|
|
12
|
+
<%_ } else if (framework == supportedFramework.react) { _%>
|
|
13
|
+
const reactHooks = require('eslint-plugin-react-hooks')
|
|
14
|
+
const reactPlugin = require('eslint-plugin-react')
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
|
|
17
|
+
module.exports = [
|
|
18
|
+
// 忽略文件配置
|
|
19
|
+
{
|
|
20
|
+
ignores: ['node_modules/', 'dist/', 'test/', 'coverage/']
|
|
21
|
+
},
|
|
22
|
+
<%_ if(language == supportedLanguage.typescript) { _%>
|
|
23
|
+
// TypeScript 配置
|
|
24
|
+
{
|
|
25
|
+
files: ['**/*.ts', <%- framework == supportedFramework.react ? '\'**/*.tsx\'' : ''-%>],
|
|
26
|
+
plugins: {
|
|
27
|
+
<%_ if (framework == supportedFramework.react) { _%>
|
|
28
|
+
react: reactPlugin,
|
|
29
|
+
'react-hooks': reactHooks,
|
|
30
|
+
<%_ } _%>
|
|
31
|
+
prettier: eslintPretterPlugin,
|
|
32
|
+
'@typescript-eslint': tsPlugin
|
|
33
|
+
},
|
|
34
|
+
languageOptions: {
|
|
35
|
+
parser: tsParser,
|
|
36
|
+
ecmaVersion: 'latest',
|
|
37
|
+
parserOptions: {
|
|
38
|
+
<%_ if(framework == supportedFramework.react) { _%>
|
|
39
|
+
ecmaFeatures: {
|
|
40
|
+
jsx: true
|
|
41
|
+
},
|
|
42
|
+
<%_ } _%>
|
|
43
|
+
project: "./tsconfig.json"
|
|
44
|
+
},
|
|
45
|
+
sourceType: 'module',
|
|
46
|
+
globals: { ...globals.browser, ...globals.node, ...globals.es2020 }
|
|
47
|
+
},
|
|
48
|
+
rules: {
|
|
49
|
+
...tsPlugin.configs.recommended.rules,
|
|
50
|
+
<%_ if(framework == supportedFramework.react) { _%>
|
|
51
|
+
"react/jsx-uses-react": "error",
|
|
52
|
+
"react/jsx-uses-vars": "error",
|
|
53
|
+
"react/react-in-jsx-scope": "off",
|
|
54
|
+
// React Hooks 规则
|
|
55
|
+
"react-hooks/rules-of-hooks": "error",
|
|
56
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
57
|
+
<%_ } _%>
|
|
58
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
59
|
+
'@typescript-eslint/explicit-function-return-type': 'off'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
<%_ } _%>
|
|
63
|
+
<%_ if (framework == supportedFramework.vue2 || framework == supportedFramework.vue3) { _%>
|
|
64
|
+
// Vue 文件配置
|
|
65
|
+
{
|
|
66
|
+
files: ['**/*.vue'],
|
|
67
|
+
languageOptions: {
|
|
68
|
+
parser: vueParser,
|
|
69
|
+
parserOptions: {
|
|
70
|
+
parser: <%= language == supportedLanguage.typescript ? 'tsParser' : 'eslintParser'%>,
|
|
71
|
+
requireConfigFile: false,
|
|
72
|
+
ecmaVersion: 'latest',
|
|
73
|
+
sourceType: 'module'
|
|
74
|
+
},
|
|
75
|
+
globals: { ...globals.browser, ...globals.node }
|
|
76
|
+
<%_ if (language == supportedLanguage.javascript) { _%>
|
|
77
|
+
babelOptions: {
|
|
78
|
+
presets: ['@babel/preset-env']
|
|
79
|
+
}
|
|
80
|
+
<%_ } _%>
|
|
81
|
+
},
|
|
82
|
+
plugins: {
|
|
83
|
+
<%_ if (language == supportedLanguage.typescript) { _%>
|
|
84
|
+
'@typescript-eslint': tsPlugin,
|
|
85
|
+
<%_ } _%>
|
|
86
|
+
vue: vuePlugin
|
|
87
|
+
},
|
|
88
|
+
rules: {
|
|
89
|
+
<%_ if (language == supportedLanguage.typescript) { _%>
|
|
90
|
+
...tsPlugin.configs.recommended.rules,
|
|
91
|
+
<%_ } else { _%>
|
|
92
|
+
...js.configs.recommended.rules,
|
|
93
|
+
<%_ } _%>
|
|
94
|
+
...vuePlugin.configs['flat/base'].rules,
|
|
95
|
+
<%_ if (framework == supportedFramework.vue2) { _%>
|
|
96
|
+
...vuePlugin.configs['flat/vue2-recommended'].rules,
|
|
97
|
+
...vuePlugin.configs['flat/vue2-strongly-recommended'].rules,
|
|
98
|
+
...vuePlugin.configs['flat/vue2-essential'].rules,
|
|
99
|
+
<%_ } else { _%>
|
|
100
|
+
...vuePlugin.configs['vue3-recommended'].rules,
|
|
101
|
+
...vuePlugin.configs['vue3-strongly-recommended'].rules,
|
|
102
|
+
...vuePlugin.configs['vue3-essential'].rules,
|
|
103
|
+
<%_ } _%>
|
|
104
|
+
'vue/multi-word-component-names': 'off',
|
|
105
|
+
'vue/comment-directive': 'off',
|
|
106
|
+
'vue/html-indent': 'off',
|
|
107
|
+
'vue/max-attributes-per-line': 'off',
|
|
108
|
+
'vue/require-default-prop': 'off',
|
|
109
|
+
'vue/html-closing-bracket-newline': 'off',
|
|
110
|
+
'vue/html-self-closing': [
|
|
111
|
+
'error',
|
|
112
|
+
{
|
|
113
|
+
html: {
|
|
114
|
+
void: 'always',
|
|
115
|
+
normal: 'always',
|
|
116
|
+
component: 'always'
|
|
117
|
+
},
|
|
118
|
+
svg: 'always',
|
|
119
|
+
math: 'always'
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
<%_ } _%>
|
|
125
|
+
// 基础 JavaScript 配置
|
|
126
|
+
{
|
|
127
|
+
files: ['**/*.js', <%- framework == supportedFramework.react ? '\'**/*.jsx\'' : '' -%>],
|
|
128
|
+
languageOptions: {
|
|
129
|
+
ecmaVersion: 'latest',
|
|
130
|
+
sourceType: 'module',
|
|
131
|
+
parser: eslintParser,
|
|
132
|
+
parserOptions: {
|
|
133
|
+
requireConfigFile: false,
|
|
134
|
+
<%_ if (framework == supportedFramework.react) { _%>
|
|
135
|
+
ecmaFeatures: {
|
|
136
|
+
jsx: true
|
|
137
|
+
},
|
|
138
|
+
<%_ } _%>
|
|
139
|
+
babelOptions: {
|
|
140
|
+
babelrc: false,
|
|
141
|
+
configFile: false,
|
|
142
|
+
presets: ['@babel/preset-env']
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
globals: { ...globals.browser, ...globals.node, ...globals.es2020 }
|
|
146
|
+
},
|
|
147
|
+
plugins: {
|
|
148
|
+
<%_ if (framework == supportedFramework.react) { _%>
|
|
149
|
+
react: reactPlugin,
|
|
150
|
+
'react-hooks': reactHooks,
|
|
151
|
+
<%_ } _%>
|
|
152
|
+
prettier: eslintPretterPlugin
|
|
153
|
+
},
|
|
154
|
+
<%_ if (framework == supportedFramework.react) { _%>
|
|
155
|
+
settings: {
|
|
156
|
+
react: {
|
|
157
|
+
version: "detect"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
<%_ } _%>
|
|
161
|
+
rules: {
|
|
162
|
+
...js.configs.recommended.rules,
|
|
163
|
+
<%_ if(framework == supportedFramework.react) { _%>
|
|
164
|
+
"react/jsx-uses-react": "error",
|
|
165
|
+
"react/jsx-uses-vars": "error",
|
|
166
|
+
"react/react-in-jsx-scope": "off",
|
|
167
|
+
// React Hooks 规则
|
|
168
|
+
"react-hooks/rules-of-hooks": "error",
|
|
169
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
170
|
+
<%_ } _%>
|
|
171
|
+
'prettier/prettier': [
|
|
172
|
+
'error',
|
|
173
|
+
{
|
|
174
|
+
singleQuote: true,
|
|
175
|
+
semi: false
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
179
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
]
|