Skip to content

Commit 5b3e466

Browse files
author
linfeng
committed
feat: support eslint ignore to eslint
1 parent 171c240 commit 5b3e466

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/utils/lint.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ export async function lint(options?: Partial<DefaultOptions>) {
2929
const { CLIEngine } = await import('eslint');
3030
const lintRules = fs.readJsonSync(path.join(globalState.projectRootPath, '.eslintrc'));
3131
const mergedOptions = _.defaults(options || {}, new DefaultOptions());
32-
const cli = new CLIEngine({ ...(lintRules as any), fix: mergedOptions.needFix });
32+
const eslintIgnorePath = path.join(globalState.projectRootPath, '.eslintignore');
33+
const eslintIgnoreExist = fs.existsSync(eslintIgnorePath);
34+
const cli = new CLIEngine({
35+
...(lintRules as any),
36+
fix: mergedOptions.needFix,
37+
ignore: true,
38+
ignorePath: eslintIgnoreExist ? eslintIgnorePath : null,
39+
globals: ['API', 'defs']
40+
});
41+
3342
let lintFiles: string[] = [];
3443

3544
if (mergedOptions.lintAll) {
@@ -48,6 +57,8 @@ export async function lint(options?: Partial<DefaultOptions>) {
4857
});
4958
}
5059

60+
lintFiles = lintFiles.filter(file => !cli.isPathIgnored(file));
61+
5162
const lintResult = await spinner(
5263
`Lint ${mergedOptions.lintAll ? 'all' : ''} ${lintFiles.length} files.`,
5364
async () => {

0 commit comments

Comments
 (0)