@@ -2,12 +2,14 @@ import type { Options } from '@cspell/eslint-plugin'
22import cspellRecommended from '@cspell/eslint-plugin/recommended'
33import js from '@eslint/js'
44import react from '@eslint-react/eslint-plugin'
5+ import { logger } from '@rspress/shared/logger'
56import { Command } from 'commander'
67import { merge } from 'es-toolkit/compat'
78import { ESLint } from 'eslint'
89import * as mdx from 'eslint-plugin-mdx'
910import tseslint from 'typescript-eslint'
1011
12+ import type { NormalizedTermItem } from '../terms.js'
1113import type { GlobalCliOptions } from '../types.js'
1214
1315import { parseTerms } from './helpers.js'
@@ -23,7 +25,13 @@ export const lintCommand = new Command('lint')
2325
2426 const docsDir = config . root !
2527
26- const parsedTerms = await parseTerms ( )
28+ let parsedTerms : NormalizedTermItem [ ] = [ ]
29+
30+ try {
31+ parsedTerms = await parseTerms ( )
32+ } catch ( err ) {
33+ logger . error ( 'Failed to parse terms.yaml' , err )
34+ }
2735
2836 const eslint = new ESLint ( {
2937 cwd : docsDir ,
@@ -83,15 +91,30 @@ export const lintCommand = new Command('lint')
8391 ] ) ,
8492 } )
8593
94+ logger . start ( 'Linting...' )
95+
8696 const results = await eslint . lintFiles ( '**/*.{js,jsx,ts,tsx,md,mdx}' )
8797
8898 if ( ! results . length ) {
8999 return
90100 }
91101
92- process . exitCode = 1
102+ const errorCount = results . reduce (
103+ ( count , result ) => count + result . errorCount ,
104+ 0 ,
105+ )
106+ const warningCount = results . reduce (
107+ ( count , result ) => count + result . warningCount ,
108+ 0 ,
109+ )
110+
111+ logger . error (
112+ `Linting completed with ${ errorCount } errors and ${ warningCount } warnings` ,
113+ )
93114
94115 const formatter = await eslint . loadFormatter ( 'stylish' )
95116
96117 process . stderr . write ( await formatter . format ( results ) )
118+
119+ process . exitCode = 1
97120 } )
0 commit comments