Skip to content

Commit 6601129

Browse files
committed
refactor: migrate config files to ES modules
1 parent 5fc5860 commit 6601129

File tree

6 files changed

+1296
-34
lines changed

6 files changed

+1296
-34
lines changed

commitlint.config.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
module.exports = {
1+
export default {
22
extends: ['@commitlint/config-conventional'],
33
rules: {
4-
// type 类型定义,表示 git 提交的 type 必须在以下类型范围内
54
'type-enum': [
65
2,
76
'always',
87
[
9-
'feat', // 新功能
10-
'fix', // 修复
11-
'docs', // 文档变更
12-
'style', // 代码格式
13-
'refactor', // 重构
14-
'perf', // 性能优化
15-
'test', // 增加测试
16-
'build', // 构建
17-
'ci', // CI配置
18-
'chore', // 构建过程或辅助工具的变动
19-
'revert', // 回退
20-
'build', // 打包
21-
'release', // 发版
8+
'feat',
9+
'fix',
10+
'docs',
11+
'style',
12+
'refactor',
13+
'perf',
14+
'test',
15+
'build',
16+
'ci',
17+
'chore',
18+
'revert',
19+
'build',
20+
'release',
2221
],
2322
],
24-
// subject 大小写不做校验
2523
'subject-case': [0],
2624
},
2725
}

eslint.config.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// import tseslint from 'typescript-eslint';
2-
// import prettierPlugin from 'eslint-plugin-prettier';
3-
const tseslint = require('typescript-eslint');
4-
const prettierPlugin = require('eslint-plugin-prettier');
1+
import tsParser from '@typescript-eslint/parser'
2+
import tseslint from 'typescript-eslint';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin'
4+
import importPlugin from 'eslint-plugin-import'
5+
import prettierPlugin from 'eslint-plugin-prettier';
6+
import globals from 'globals'
57

6-
module.exports = [
7-
// 应用 TypeScript ESLint 推荐配置
8+
export default [
89
...tseslint.configs.recommended,
910

1011
{
@@ -16,24 +17,20 @@ module.exports = [
1617
ignores: ['config/**/*.{js,ts}'],
1718
},
1819

19-
// 全局配置
2020
{
2121
files: ['packages/**/*.{js,ts}'],
2222

2323
languageOptions: {
24-
ecmaVersion: 2020,
25-
sourceType: 'module',
24+
parser: tsParser,
2625
parserOptions: {
27-
ecmaVersion: 2020,
26+
ecmaVersion: 'latest',
2827
sourceType: 'module',
2928
},
3029
globals: {
31-
// 浏览器环境
32-
window: 'readonly',
33-
document: 'readonly',
34-
navigator: 'readonly',
35-
// Chrome 扩展 API
36-
chrome: 'readonly',
30+
...globals.es2022,
31+
...globals.node,
32+
...globals.browser,
33+
...globals.devtools,
3734
},
3835
},
3936

@@ -46,6 +43,8 @@ module.exports = [
4643
},
4744

4845
plugins: {
46+
'@typescript-eslint': tsPlugin,
47+
import: importPlugin,
4948
prettier: prettierPlugin,
5049
},
5150
},

lint-staged.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = {
1+
export default {
22
'packages/**/*.{ts,js}': ['npx eslint'],
33
}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "vue-devtools-unlocker",
33
"version": "1.0.0",
44
"description": "Enable Vue DevTools in production environments",
5+
"type": "module",
56
"author": "zhensherlock",
67
"license": "MIT",
78
"scripts": {
@@ -29,13 +30,16 @@
2930
"@commitlint/cli": "^19.8.1",
3031
"@commitlint/config-conventional": "^19.8.1",
3132
"@types/chrome": "^0.1.4",
33+
"@typescript-eslint/eslint-plugin": "^8.42.0",
3234
"@typescript-eslint/parser": "^8.41.0",
3335
"adm-zip": "^0.5.16",
3436
"copy-webpack-plugin": "^13.0.1",
3537
"css-loader": "^7.1.2",
3638
"eslint": "^9.34.0",
39+
"eslint-plugin-import": "^2.32.0",
3740
"eslint-plugin-prettier": "^5.5.4",
3841
"file-loader": "^6.2.0",
42+
"globals": "^16.3.0",
3943
"husky": "^9.1.7",
4044
"mini-css-extract-plugin": "^2.9.4",
4145
"prettier": "^3.6.2",

0 commit comments

Comments
 (0)