@apdesign/code-style-react 1.1.8 → 1.2.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/cli.js CHANGED
@@ -9,7 +9,7 @@ if (command === 'init') {
9
9
  main();
10
10
  } else if (command === 'eslint') {
11
11
  const runEslint = require('./scripts/runEslint');
12
- runEslint(args[1]);
12
+ runEslint(args.slice(1));
13
13
  } else {
14
14
  console.log(`Unknown command: "${command}"`);
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/code-style-react",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "scripts": {},
5
5
  "bin": {
6
6
  "apdesign-code-style": "cli.js"
@@ -6,7 +6,7 @@ let fs;
6
6
  let glob;
7
7
  let ESLint;
8
8
 
9
- async function runEslint() {
9
+ async function runEslint(targetPathArg) {
10
10
  try {
11
11
  if (typeof require !== 'undefined') {
12
12
  // CommonJS
@@ -14,7 +14,7 @@ async function runEslint() {
14
14
  path = require('path');
15
15
  fs = require('fs');
16
16
  glob = require('glob');
17
- ESLint = require('eslint').ESLint;
17
+ ESLint = require('eslint').ESLint;
18
18
  } else {
19
19
  // ESM
20
20
  spawnSync = await import('node:child_process').spawnSync;
@@ -25,7 +25,7 @@ async function runEslint() {
25
25
  }
26
26
 
27
27
  // 参数解析
28
- const args = process.argv.slice(2);
28
+ const args = targetPathArg || process.argv.slice(2);
29
29
 
30
30
  // 检查是否有分支参数 (--branch <branchName>)
31
31
  let branchArg = null;
@@ -148,7 +148,11 @@ async function runEslint() {
148
148
  console.log(`🔍 检查目录: ${eslintTarget}`);
149
149
  }
150
150
 
151
- const eslint = new ESLint({ cwd: rootDir });
151
+ const eslint = new ESLint({
152
+ cwd: gitRoot,
153
+ extensions: ['.js', '.jsx', '.ts', '.tsx'], // 等效于 --ext
154
+ reportUnusedDisableDirectives: 'error', // 等效于 --report-unused-disable-directives
155
+ });
152
156
  const files = glob.sync('**/*.{js,jsx,ts,tsx}', { cwd: eslintTarget, absolute: true });
153
157
  if (files.length === 0) {
154
158
  console.log('- 没有需要检查的文件');