@apdesign/code-style-react 1.2.2 → 1.2.4

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.
@@ -27,6 +27,8 @@ module.exports = {
27
27
  'import/first': 'off',
28
28
  'import/extensions': 'off',
29
29
  'import/prefer-default-export': 'off',
30
+ 'import/newline-after-import': 'warn',
31
+ 'react/jsx-curly-brace-presence': 'warn',
30
32
 
31
33
  'jsx-a11y/click-events-have-key-events': 'off',
32
34
  'jsx-a11y/no-static-element-interactions': 'off',
@@ -40,6 +42,8 @@ module.exports = {
40
42
  'no-undef': 'off',
41
43
  'no-plusplus': 'off',
42
44
 
45
+ 'prefer-template': 'warn',
46
+
43
47
  'react/function-component-definition': 'off',
44
48
  'react-hooks/exhaustive-deps': 'off',
45
49
  'react/prop-types': 'off',
@@ -50,6 +54,9 @@ module.exports = {
50
54
  'react/jsx-props-no-spreading': 'off',
51
55
  'react/self-closing-comp': 'off',
52
56
  'react/jsx-no-useless-fragment': 'off',
57
+ 'react/no-array-index-key': 'warn',
58
+
59
+ 'spaced-comment': 'warn',
53
60
 
54
61
  '@typescript-eslint/no-explicit-any': 'warn',
55
62
 
@@ -27,6 +27,7 @@ module.exports = {
27
27
  'import/first': 'off',
28
28
  'import/extensions': 'off',
29
29
  'import/prefer-default-export': 'off',
30
+ 'import/newline-after-import': 'warn',
30
31
 
31
32
  'jsx-a11y/click-events-have-key-events': 'off',
32
33
  'jsx-a11y/no-static-element-interactions': 'off',
@@ -40,6 +41,8 @@ module.exports = {
40
41
  'no-undef': 'off',
41
42
  'no-plusplus': 'off',
42
43
 
44
+ 'prefer-template': 'warn',
45
+
43
46
  'react/function-component-definition': 'off',
44
47
  'react-hooks/exhaustive-deps': 'off',
45
48
  'react/prop-types': 'off',
@@ -50,6 +53,10 @@ module.exports = {
50
53
  'react/jsx-props-no-spreading': 'off',
51
54
  'react/self-closing-comp': 'off',
52
55
  'react/jsx-no-useless-fragment': 'off',
56
+ 'react/no-array-index-key': 'warn',
57
+ 'react/jsx-curly-brace-presence': 'warn',
58
+
59
+ 'spaced-comment': 'warn',
53
60
 
54
61
  '@typescript-eslint/no-explicit-any': 'warn',
55
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/code-style-react",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "scripts": {},
5
5
  "bin": {
6
6
  "apdesign-code-style": "cli.js"
@@ -75,16 +75,6 @@ async function runEslint(targetPathArg) {
75
75
 
76
76
  const gitRoot = gitRootResult.stdout.trim();
77
77
 
78
- let targetBranch = 'master';
79
- if (targetPath !== process.cwd()) {
80
- const pkgName = path.basename(targetPath); // 直接取传入的目录名
81
- if (pkgName && pkgName.includes('-')) {
82
- const suffix = pkgName.split('-').pop();
83
- targetBranch = `master-${suffix}`;
84
- }
85
- }
86
-
87
- // 获取当前分支
88
78
  const currentBranchResult = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
89
79
  cwd: gitRoot,
90
80
  encoding: 'utf-8',
@@ -98,12 +88,14 @@ async function runEslint(targetPathArg) {
98
88
 
99
89
  const currentBranch = currentBranchResult.stdout.trim();
100
90
 
101
- const branchToUse = branchArg || targetBranch;
91
+ const branchToUse = branchArg || currentBranch;
102
92
 
103
93
  console.log(`[Git 信息]`);
104
94
  console.log(`仓库根目录: ${gitRoot}`);
105
95
  console.log(`当前分支: ${currentBranch}`);
106
- console.log(`目标分支: ${branchToUse}`);
96
+ if (branchArg) {
97
+ console.log(`目标分支: ${branchToUse}`);
98
+ }
107
99
  console.log('');
108
100
 
109
101
  if (currentBranch !== branchToUse) {
@@ -161,7 +153,7 @@ async function runEslint(targetPathArg) {
161
153
  const files = glob.sync('**/*.{js,jsx,ts,tsx}', { cwd: eslintTarget, absolute: true });
162
154
  if (files.length === 0) {
163
155
  console.log('- 没有需要检查的文件');
164
- return;
156
+ return [];
165
157
  }
166
158
 
167
159
  console.log(`[ESLint 执行]`);
@@ -170,12 +162,11 @@ async function runEslint(targetPathArg) {
170
162
  console.log('🚀 开始执行 ESLint ...\n');
171
163
 
172
164
  const results = await eslint.lintFiles(files);
165
+
173
166
  const formatter = await eslint.loadFormatter('stylish');
174
167
  const resultText = formatter.format(results);
175
168
  console.log(resultText);
176
-
177
- const hasError = results.some((r) => r.errorCount > 0);
178
- process.exit(hasError ? 1 : 0);
169
+ return results;
179
170
  } catch (err) {
180
171
  console.error('❌ 脚本执行出错:', err);
181
172
  process.exit(1);