@jianhe/linter-configs 1.0.0
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/.editorconfig +23 -0
- package/.vscode/settings.json +12 -0
- package/README.md +89 -0
- package/eslint/es6.js +10 -0
- package/eslint/html.js +11 -0
- package/eslint/modules/common.js +105 -0
- package/eslint/modules/extends-standard.js +8 -0
- package/eslint/modules/parser-babel.js +8 -0
- package/eslint/modules/plugins-html.js +8 -0
- package/eslint/modules/plugins-vue.js +45 -0
- package/eslint/vue2.js +11 -0
- package/eslint/vue3.js +11 -0
- package/package.json +47 -0
- package/prettier/index.js +68 -0
- package/publish.js +27 -0
- package/stylelint/css.js +10 -0
- package/stylelint/html-css.js +11 -0
- package/stylelint/html-scss.js +11 -0
- package/stylelint/modules/common.js +25 -0
- package/stylelint/modules/extends-html.js +8 -0
- package/stylelint/modules/extends-recess-order.js +8 -0
- package/stylelint/modules/extends-standard-scss.js +9 -0
- package/stylelint/modules/extends-standard.js +8 -0
- package/stylelint/scss.js +10 -0
- package/test/index.vue +58 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# EditorConfig
|
|
2
|
+
# https://editorconfig.org/
|
|
3
|
+
|
|
4
|
+
# 是否是顶级目录
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
# 匹配的文件类型
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# 字符编码
|
|
11
|
+
charset = utf-8
|
|
12
|
+
# 缩进方式
|
|
13
|
+
indent_style = space
|
|
14
|
+
# 缩进大小
|
|
15
|
+
indent_size = 2
|
|
16
|
+
# 制表符宽度
|
|
17
|
+
tab_width = 2
|
|
18
|
+
# 换行方式
|
|
19
|
+
end_of_line = lf
|
|
20
|
+
# 是否删除行尾空白字符
|
|
21
|
+
trim_trailing_whitespace = true
|
|
22
|
+
# 是否在文件末尾插入一个最终新行
|
|
23
|
+
insert_final_newline = true
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# FE Linter Configs
|
|
2
|
+
|
|
3
|
+
## 当前仓库
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
# 安装依赖
|
|
7
|
+
npm install
|
|
8
|
+
npm install yalc -g
|
|
9
|
+
|
|
10
|
+
# 发布
|
|
11
|
+
npm run pub
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 项目仓库
|
|
15
|
+
|
|
16
|
+
### 安装
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
# 从 npm 安装
|
|
20
|
+
npm install linter-configs -D
|
|
21
|
+
# 从 GitHub 安装
|
|
22
|
+
npm install https://github.com/jianhee/linter-configs.git -D
|
|
23
|
+
# 从 yalc 安装
|
|
24
|
+
yalc add linter-configs -D
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 配置 VS Code
|
|
28
|
+
|
|
29
|
+
把 `.vscode` 文件夹复制到项目根目录下
|
|
30
|
+
|
|
31
|
+
### 配置 EditorConfig
|
|
32
|
+
|
|
33
|
+
把 `.editorconfig` 文件复制到项目根目录下
|
|
34
|
+
|
|
35
|
+
### 配置 Prettier
|
|
36
|
+
|
|
37
|
+
在 `package.json` 中
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"prettier": "linter-configs/prettier"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
在配置文件中,比如 `.prettierrc`, `.prettierrc.json`, `.prettierrc.js`, `prettier.config.js`
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
module.exports = require('linter-configs/prettier');
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 配置 ESlint
|
|
52
|
+
|
|
53
|
+
在 `package.json` 中
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"eslintConfig": {
|
|
58
|
+
"extends": ["./node_moules/linter-configs/eslint/es6|html|vue2|vue3"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
在配置文件中,比如 `.eslintrc.js`, `.eslintrc.json`
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
module.exports = {
|
|
67
|
+
extends: ['./node_moules/linter-configs/eslint/es6|html|vue2|vue3']
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 配置 StyleLint
|
|
72
|
+
|
|
73
|
+
在 `package.json` 中
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"stylelint": {
|
|
78
|
+
"extends": ["linter-configs/stylelint/css|scss|html-css|html-scss"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
在配置文件中,比如 `stylelint.config.js`, `.stylelint.js`, `.stylelint.json`
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
module.exports = {
|
|
87
|
+
extends: ['linter-configs/stylelint/css|scss|html-css|html-scss']
|
|
88
|
+
};
|
|
89
|
+
```
|
package/eslint/es6.js
ADDED
package/eslint/html.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ESLint Config For ES6 + HTML
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: [
|
|
5
|
+
// ...
|
|
6
|
+
require.resolve('./modules/extends-standard'),
|
|
7
|
+
require.resolve('./modules/parser-babel'),
|
|
8
|
+
require.resolve('./modules/plugins-html'),
|
|
9
|
+
require.resolve('./modules/common')
|
|
10
|
+
]
|
|
11
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// ESLint 基础配置
|
|
2
|
+
// 文档:https://eslint.org/
|
|
3
|
+
// 安装:npm install -D eslint
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
// 是否是顶级目录
|
|
7
|
+
// ESLint 会自动在文件目录中查找配置文件,从直系父目录开始,沿着目录结构依次向上,直到项目根目录或指定 `root: true` 时停止
|
|
8
|
+
root: true,
|
|
9
|
+
|
|
10
|
+
// 脚本的运行环境提供的预定义的全局变量
|
|
11
|
+
// 默认都是关闭的,常用的有以下几种
|
|
12
|
+
env: {
|
|
13
|
+
// 是否启用浏览器全局变量
|
|
14
|
+
browser: true,
|
|
15
|
+
// 是否启用 Node.js 全局变量和作用域
|
|
16
|
+
node: true,
|
|
17
|
+
// 是否启用除 modules 以外的所有 ECMAScript 6 特性
|
|
18
|
+
es6: true,
|
|
19
|
+
// 是否启用 jQuery 全局变量
|
|
20
|
+
jquery: true
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// 脚本在执行期间访问的自定义的全局变量
|
|
24
|
+
// 默认为空,添加的变量可以设置为以下三种值
|
|
25
|
+
globals: {
|
|
26
|
+
// var1: "off", // 禁用
|
|
27
|
+
// var2: "readonly", // 只读
|
|
28
|
+
// var3: "writable", // 可读写
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
// 可共享配置
|
|
32
|
+
// 添加可共享配置可以继承另一个配置文件的所有特征(包括规则、插件和语言选项)并修改所有选项
|
|
33
|
+
// 格式:数组,后一项的优先级大于前一项,后一项的规则会覆盖前一项
|
|
34
|
+
// 值:默认为空,可选的值有以下三种
|
|
35
|
+
extends: [
|
|
36
|
+
'eslint:recommended' // 官方配置的名称:'recommended'(推荐规则)'all'(全部规则)
|
|
37
|
+
// 'standard', // 第三方配置的名称
|
|
38
|
+
// './common.js' // 本地配置文件的路径
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
// 解析器
|
|
42
|
+
// 添加第三方解析器可以解析特定的语法
|
|
43
|
+
// 默认为 'Espree',设置后需要同时配置 `parserOptions` 字段
|
|
44
|
+
parser: '',
|
|
45
|
+
|
|
46
|
+
// 解析器选项
|
|
47
|
+
parserOptions: {
|
|
48
|
+
// ECMAScript 版本:默认为 '3,5',可设置为一个版本或一个年份
|
|
49
|
+
ecmaVersion: 'latest',
|
|
50
|
+
// ECMAScript 模式:默认为 'script',可设置为 'module'(如果代码是 ECMAScript 模块)
|
|
51
|
+
sourceType: 'module',
|
|
52
|
+
// 额外的语言特性:默认都是关闭的
|
|
53
|
+
ecmaFeatures: {
|
|
54
|
+
// 是否允许在全局作用域下使用 return 语句
|
|
55
|
+
globalReturn: false,
|
|
56
|
+
// 是否开启全局 script 模式
|
|
57
|
+
impliedStrict: true,
|
|
58
|
+
// 是否支持 JSX 语法
|
|
59
|
+
jsx: true
|
|
60
|
+
},
|
|
61
|
+
// 使用 @babel/eslint-parser 解析时,是否需要 .babelrc 配置文件
|
|
62
|
+
requireConfigFile: false,
|
|
63
|
+
// 是否允许 import 和 export 语句出现在模块顶层以外的任意位置
|
|
64
|
+
allowImportExportEverywhere: false
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// 插件
|
|
68
|
+
// 添加第三方插件可以提供额外的环境、配置和规则,或者提供额外的处理器从特定的文件中提取或转换 JavaScript 代码
|
|
69
|
+
// 默认为空,只能检测 .js 文件中的代码
|
|
70
|
+
plugins: [
|
|
71
|
+
// html
|
|
72
|
+
// vue
|
|
73
|
+
// ...
|
|
74
|
+
],
|
|
75
|
+
|
|
76
|
+
// 启用或覆盖的规则及其各自的错误级别
|
|
77
|
+
// 默认所有规则都是禁用的,添加的规则可以设置为以下三种值
|
|
78
|
+
// 0/'off' 关闭规则
|
|
79
|
+
// 1/'warn' 启用并警告,不会导致程序退出
|
|
80
|
+
// 2/'error' 启用并报错,触发时会导致程序退出
|
|
81
|
+
rules: {
|
|
82
|
+
// 风格相关
|
|
83
|
+
// 对象属性的引号:如果有一个属性需要使用引号,那就全部都使用引号
|
|
84
|
+
'quote-props': ['error', 'consistent-as-needed'],
|
|
85
|
+
// 函数左括号之前的空格:禁止使用
|
|
86
|
+
'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
|
|
87
|
+
// 语句末尾的分号:必须使用
|
|
88
|
+
'semi': ['error', 'always'],
|
|
89
|
+
// 换行风格
|
|
90
|
+
'linebreak-style': ['error', 'unix'],
|
|
91
|
+
|
|
92
|
+
// ES6 语法
|
|
93
|
+
// 使用模板字面量而非字符串连接
|
|
94
|
+
'prefer-template': 'error',
|
|
95
|
+
// 使用箭头函数作为回调
|
|
96
|
+
'prefer-arrow-callback': 'error',
|
|
97
|
+
// 箭头函数的参数圆括号:只有一个参数时不使用括号
|
|
98
|
+
'arrow-parens': ['error', 'as-needed'],
|
|
99
|
+
|
|
100
|
+
// 建议
|
|
101
|
+
// console/debugger:生产环境禁用
|
|
102
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
103
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Standard 可共享配置
|
|
2
|
+
// 文档:https://www.npmjs.com/package/eslint-config-standard
|
|
3
|
+
// 安装:npm install -D eslint-config-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-n
|
|
4
|
+
// 说明:用于 JavaScript Standard 风格的配置
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
extends: ['standard']
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Babel 解析器
|
|
2
|
+
// 文档:https://www.npmjs.com/package/@babel/eslint-parser
|
|
3
|
+
// 安装:npm install -D @babel/core @babel/eslint-parser
|
|
4
|
+
// 说明:用于检查所有有效的 Babel 代码。ESLint 默认的解析器和核心规则仅支持最新的正式 ECMAScript 标准,不支持 Babel 提供的实验性语法(如新特性)和非标准语法(如 Flow 或 TypeScript 类型)。Babel 解析器能让 ESLint 在 Babel 转换后的源代码上运行。
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
parser: '@babel/eslint-parser'
|
|
8
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Vue 插件
|
|
2
|
+
// 文档:https://eslint.vuejs.org/
|
|
3
|
+
// 安装:npm install -D eslint-plugin-vue
|
|
4
|
+
// 1.用于解析 .vue 文件的 <script> 和 <template> 标签中的代码
|
|
5
|
+
// 2.提供针对 Vue 语法的 `vue-eslint-parser` 解析器
|
|
6
|
+
// 3.提供针对 Vue 语法的的规则
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
// Vue 解析器
|
|
10
|
+
// 如果在 `parser` 字段中使用了其它解析器,需要移入 `parserOptions` 字段中以避免两个解析器产生冲突
|
|
11
|
+
parser: 'vue-eslint-parser',
|
|
12
|
+
|
|
13
|
+
// Babel 解析器移入这里
|
|
14
|
+
parserOptions: {
|
|
15
|
+
parser: '@babel/eslint-parser'
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// Vue 插件
|
|
19
|
+
// 它和 HTML 插件都会从 <script> 标签中提取代码,所以需要在 `plugins` 字段中移除 'html' 以避免两个插件产生冲突
|
|
20
|
+
plugins: ['vue'],
|
|
21
|
+
|
|
22
|
+
// Vue 推荐规则
|
|
23
|
+
extends: [
|
|
24
|
+
// 'plugin:vue/recommended', // Vue2 使用
|
|
25
|
+
// 'plugin:vue/vue3-recommended' // Vue3 使用
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
// Vue 规则
|
|
29
|
+
rules: {
|
|
30
|
+
// 目录和文件名:必须使用 kebab-case 写法
|
|
31
|
+
// 组件的命名:必须使用两个以上的单词
|
|
32
|
+
'vue/multi-word-component-names': 'off',
|
|
33
|
+
// 组件名称的写法:在单文件组件和字符串模板中使用 PascalCase 写法,在 DOM 模板中使用 kebab-case 写法
|
|
34
|
+
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
|
|
35
|
+
// 使用 === 而不是 ==
|
|
36
|
+
'vue/eqeqeq': ['error', 'always'],
|
|
37
|
+
// 使用模板字面量而非字符串连接
|
|
38
|
+
'vue/prefer-template': 'error',
|
|
39
|
+
// HTML 元素中的内容是否换行:多行时换行,单行时关闭校验
|
|
40
|
+
'vue/multiline-html-element-content-newline': 'error',
|
|
41
|
+
'vue/singleline-html-element-content-newline': 'off',
|
|
42
|
+
// HTML 闭合元素
|
|
43
|
+
'vue/html-self-closing': ['error', { html: { void: 'always' } }]
|
|
44
|
+
}
|
|
45
|
+
};
|
package/eslint/vue2.js
ADDED
package/eslint/vue3.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jianhe/linter-configs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Linter Configs",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "jianhe",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"homepage": "https://github.com/jianhee/linter-configs#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/jianhee/linter-configs.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/jianhee/linter-configs/issues"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"pub": "node publish.js"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@babel/core": "^7.26.9",
|
|
22
|
+
"@babel/eslint-parser": "^7.26.8",
|
|
23
|
+
"eslint": "^8.57.1",
|
|
24
|
+
"eslint-config-standard": "^17.1.0",
|
|
25
|
+
"eslint-plugin-import": "^2.31.0",
|
|
26
|
+
"eslint-plugin-n": "^15.7.0",
|
|
27
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
28
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
29
|
+
"postcss-html": "^1.8.0",
|
|
30
|
+
"prettier": "^3.5.3",
|
|
31
|
+
"stylelint": "^16.15.0",
|
|
32
|
+
"stylelint-config-html": "^1.1.0",
|
|
33
|
+
"stylelint-config-recess-order": "^6.0.0",
|
|
34
|
+
"stylelint-config-standard": "^37.0.0",
|
|
35
|
+
"stylelint-config-standard-scss": "^14.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"shelljs": "^0.10.0"
|
|
39
|
+
},
|
|
40
|
+
"prettier": "./prettier",
|
|
41
|
+
"eslintConfig": {
|
|
42
|
+
"extends": "./eslint/vue3"
|
|
43
|
+
},
|
|
44
|
+
"stylelint": {
|
|
45
|
+
"extends": "./stylelint/html-scss"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Prettier Config
|
|
2
|
+
// 文档:https://prettier.io/
|
|
3
|
+
// 安装:npm install -D prettier
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
// 关联 JSON Schema 定义,提供智能提示和验证
|
|
7
|
+
$schema: 'https://json.schemastore.org/prettierrc',
|
|
8
|
+
// 每行最大字符数
|
|
9
|
+
printWidth: Infinity,
|
|
10
|
+
// 制表符宽度
|
|
11
|
+
tabWidth: 2,
|
|
12
|
+
// 是否使用制表符缩进(否则使用空格)
|
|
13
|
+
useTabs: false,
|
|
14
|
+
// 是否在语句末尾使用分号
|
|
15
|
+
semi: true,
|
|
16
|
+
// 是否使用单引号
|
|
17
|
+
singleQuote: true,
|
|
18
|
+
// 对象属性的引号:如果有一个属性需要使用引号,那就全部都使用引号
|
|
19
|
+
quoteProps: 'consistent',
|
|
20
|
+
// 是否在 JSX 中使用单引号
|
|
21
|
+
jsxSingleQuote: false,
|
|
22
|
+
// 对象和数组中的拖尾逗号:不使用
|
|
23
|
+
trailingComma: 'none',
|
|
24
|
+
// 是否在大括号内首尾添加空格
|
|
25
|
+
bracketSpacing: true,
|
|
26
|
+
// 是否将标签的反尖括号放在最后一行的末尾(否则需要换行)
|
|
27
|
+
bracketSameLine: false,
|
|
28
|
+
// 箭头函数的参数圆括号:只有一个参数时不使用括号
|
|
29
|
+
arrowParens: 'avoid',
|
|
30
|
+
// 文件格式化的范围:全部内容
|
|
31
|
+
rangeStart: 0,
|
|
32
|
+
rangeEnd: Infinity,
|
|
33
|
+
// 是否在文件开头写特殊注释 @prettier
|
|
34
|
+
requirePragma: false,
|
|
35
|
+
// 是否在文件开头自动插入特殊注释 @prettier
|
|
36
|
+
insertPragma: false,
|
|
37
|
+
// Markdown 的折行标准:使用默认标准
|
|
38
|
+
proseWrap: 'preserve',
|
|
39
|
+
// HTML 的空格格式:可选的值有 1.'css'(根据显示样式)2.'strict'(保留空格)3.'ignore'(忽略空格)
|
|
40
|
+
htmlWhitespaceSensitivity: 'css',
|
|
41
|
+
// Vue 的 <script> 和 <style> 标签是否缩进
|
|
42
|
+
vueIndentScriptAndStyle: false,
|
|
43
|
+
// 换行方式
|
|
44
|
+
endOfLine: 'lf',
|
|
45
|
+
// 识别并格式化内嵌代码:自动
|
|
46
|
+
embeddedLanguageFormatting: 'auto',
|
|
47
|
+
// 是否给属性换行
|
|
48
|
+
singleAttributePerLine: false,
|
|
49
|
+
// 为指定的文件类型重写配置
|
|
50
|
+
overrides: [
|
|
51
|
+
// CSS 相关
|
|
52
|
+
{
|
|
53
|
+
files: ['*.css', '*.scss', '*.less'],
|
|
54
|
+
options: {
|
|
55
|
+
// 是否使用单引号
|
|
56
|
+
singleQuote: false
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
// Vue 相关
|
|
60
|
+
{
|
|
61
|
+
files: '*.vue',
|
|
62
|
+
options: {
|
|
63
|
+
// 是否给属性换行
|
|
64
|
+
singleAttributePerLine: true
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
package/publish.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// 发布
|
|
2
|
+
import shell from 'shelljs';
|
|
3
|
+
|
|
4
|
+
// 出错时退出进程
|
|
5
|
+
shell.set('-e');
|
|
6
|
+
|
|
7
|
+
// 更新版本号
|
|
8
|
+
// shell.exec('npm version patch --no-git-tag-version'); // 小修复:1.0.0 → 1.0.1
|
|
9
|
+
// shell.exec('npm version minor --no-git-tag-version'); // 新功能:1.0.0 → 1.1.0
|
|
10
|
+
// shell.exec('npm version major --no-git-tag-version'); // 破坏性更新:1.0.0 → 2.0.0
|
|
11
|
+
|
|
12
|
+
// Git 提交 + 推送
|
|
13
|
+
// shell.exec('git add .');
|
|
14
|
+
// shell.exec('git commit -m "update"');
|
|
15
|
+
// shell.exec('git push');
|
|
16
|
+
// console.log('✅ 已成功推送到 linter-configs 仓库');
|
|
17
|
+
|
|
18
|
+
// npm 发布
|
|
19
|
+
shell.exec('nrm use npm');
|
|
20
|
+
shell.exec('npm publish --access public');
|
|
21
|
+
shell.exec('npm info @jianhe/linter-configs');
|
|
22
|
+
shell.exec('nrm use taobao');
|
|
23
|
+
console.log('✅ 已成功推送到 npm');
|
|
24
|
+
|
|
25
|
+
// yalc 发布
|
|
26
|
+
// shell.exec('yalc push');
|
|
27
|
+
console.log('✅ 已成功推送到 yalc');
|
package/stylelint/css.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// StyleLint Config For SCSS + HTML/Vue
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: [
|
|
5
|
+
// ...
|
|
6
|
+
require.resolve('./modules/extends-recess-order'),
|
|
7
|
+
require.resolve('./modules/extends-standard'),
|
|
8
|
+
require.resolve('./modules/extends-html'),
|
|
9
|
+
require.resolve('./modules/common')
|
|
10
|
+
]
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// StyleLint Config For CSS + HTML/Vue
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: [
|
|
5
|
+
// ...
|
|
6
|
+
require.resolve('./modules/extends-recess-order'),
|
|
7
|
+
require.resolve('./modules/extends-standard-scss'),
|
|
8
|
+
require.resolve('./modules/extends-html'),
|
|
9
|
+
require.resolve('./modules/common')
|
|
10
|
+
]
|
|
11
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// StyleLint 基础配置
|
|
2
|
+
// 文档:https://stylelint.io/
|
|
3
|
+
// 安装:npm install -D stylelint
|
|
4
|
+
// 说明:和 ESLint 规则类似
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
// 插件
|
|
8
|
+
plugins: [],
|
|
9
|
+
|
|
10
|
+
// 可共享配置
|
|
11
|
+
extends: [],
|
|
12
|
+
|
|
13
|
+
// 规则
|
|
14
|
+
rules: {
|
|
15
|
+
// 规则块前的空行:不使用
|
|
16
|
+
'rule-empty-line-before': 'never',
|
|
17
|
+
// 字体列表中是否缺少通用系列:不校验
|
|
18
|
+
'font-family-no-missing-generic-family-keyword': null,
|
|
19
|
+
// 是否允许特异性较低的选择器在特异性较高的选择器之后出现:不校验
|
|
20
|
+
'no-descending-specificity': null,
|
|
21
|
+
// 类名校验规则:必须以小写字母开头,后跟字母、数字、短横线、短横线
|
|
22
|
+
// 例如:.block, .block123, .block-modifier, .block--modifier, .block__element, .block__element--modifier
|
|
23
|
+
'selector-class-pattern': ['^[a-z][a-z0-9-_]+$']
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Standard SCSS 可共享配置
|
|
2
|
+
// 文档:https://www.npmjs.com/package/stylelint-config-standard-scss
|
|
3
|
+
// 安装:npm install -D stylelint-config-standard-scss
|
|
4
|
+
// 1.扩展 stylelint-config-standard 共享配置,并针对 SCSS 调整其规则
|
|
5
|
+
// 2.扩展 stylelint-config-recommended-scss 共享配置
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
extends: ['stylelint-config-standard-scss']
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Standard 可共享配置
|
|
2
|
+
// 文档:https://www.npmjs.com/package/stylelint-config-standard
|
|
3
|
+
// 安装:npm install -D stylelint-config-standard
|
|
4
|
+
// 说明:扩展 stylelint-config-recommended 共享配置,并启用额外规则,以强制实施 CSS 和 Baseline Wider Available 中的现代规范
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
extends: ['stylelint-config-standard']
|
|
8
|
+
};
|
package/test/index.vue
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
a="1"
|
|
4
|
+
b="2"
|
|
5
|
+
c="3"
|
|
6
|
+
d="4"
|
|
7
|
+
>
|
|
8
|
+
{{ var1 }}
|
|
9
|
+
{{ var2 === 1 ? `a${1}` : '' }}
|
|
10
|
+
<TodoItem>123</TodoItem>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
import { ref, computed, onMounted } from 'vue';
|
|
16
|
+
import TodoItem from './TodoItem';
|
|
17
|
+
|
|
18
|
+
// 变量
|
|
19
|
+
const var1 = ref(1);
|
|
20
|
+
const var2 = ref({ a: 1, b: 1 });
|
|
21
|
+
|
|
22
|
+
// 计算属性
|
|
23
|
+
const foo = computed(() => {
|
|
24
|
+
return 1;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// 生命周期
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
document.addEventListener('onscroll', event => {});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 方法
|
|
33
|
+
const fn1 = () => {
|
|
34
|
+
const a = `a${1}`;
|
|
35
|
+
if (a === 1) {
|
|
36
|
+
console.log(a);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const fn2 = a => {
|
|
40
|
+
switch (a) {
|
|
41
|
+
case 1:
|
|
42
|
+
break;
|
|
43
|
+
case 2:
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="scss">
|
|
50
|
+
a {
|
|
51
|
+
margin: 0 auto;
|
|
52
|
+
color: #fff;
|
|
53
|
+
}
|
|
54
|
+
p {
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
color: rgb(0 0 0 / 50%);
|
|
57
|
+
}
|
|
58
|
+
</style>
|