@@ -217,6 +217,45 @@ const execute = async (cmd) => {
217217 }
218218} ;
219219
220+ const lintCheckFiles = async ( dir ) => {
221+ const { default : prettier } = await import ( 'prettier' ) ;
222+ const prettierConfig = await getPrettierConfig ( ) ;
223+
224+ const filePaths = [ ] ;
225+ [ '.ts' , '.tsx' , '.js' , '.d.ts' ] . forEach ( ( extension ) =>
226+ forEachDeepFile ( dir , ( filePath ) => filePaths . push ( filePath ) , extension ) ,
227+ ) ;
228+ await allOf ( filePaths , async ( filePath ) => {
229+ const code = await promises . readFile ( filePath , UTF8 ) ;
230+ if (
231+ ! ( await prettier . check ( code , { ...prettierConfig , filepath : filePath } ) )
232+ ) {
233+ writeFileSync (
234+ filePath ,
235+ await prettier . format (
236+ code ,
237+ { ...prettierConfig , filepath : filePath } ,
238+ UTF8 ,
239+ ) ,
240+ ) ;
241+ }
242+ } ) ;
243+
244+ const {
245+ default : { ESLint} ,
246+ } = await import ( 'eslint' ) ;
247+ const esLint = new ESLint ( { } ) ;
248+ const results = await esLint . lintFiles ( [ dir ] ) ;
249+ if (
250+ results . filter ( ( result ) => result . errorCount > 0 || result . warningCount > 0 )
251+ . length > 0
252+ ) {
253+ const formatter = await esLint . loadFormatter ( ) ;
254+ const errors = await formatter . format ( results ) ;
255+ throw errors ;
256+ }
257+ } ;
258+
220259const lintCheckDocs = async ( dir ) => {
221260 const {
222261 default : { ESLint} ,
@@ -283,45 +322,6 @@ const lintCheckDocs = async (dir) => {
283322 } ) ;
284323} ;
285324
286- const lintCheckFiles = async ( dir ) => {
287- const { default : prettier } = await import ( 'prettier' ) ;
288- const prettierConfig = await getPrettierConfig ( ) ;
289-
290- const filePaths = [ ] ;
291- [ '.ts' , '.tsx' , '.js' , '.d.ts' ] . forEach ( ( extension ) =>
292- forEachDeepFile ( dir , ( filePath ) => filePaths . push ( filePath ) , extension ) ,
293- ) ;
294- await allOf ( filePaths , async ( filePath ) => {
295- const code = await promises . readFile ( filePath , UTF8 ) ;
296- if (
297- ! ( await prettier . check ( code , { ...prettierConfig , filepath : filePath } ) )
298- ) {
299- writeFileSync (
300- filePath ,
301- await prettier . format (
302- code ,
303- { ...prettierConfig , filepath : filePath } ,
304- UTF8 ,
305- ) ,
306- ) ;
307- }
308- } ) ;
309-
310- const {
311- default : { ESLint} ,
312- } = await import ( 'eslint' ) ;
313- const esLint = new ESLint ( { } ) ;
314- const results = await esLint . lintFiles ( [ dir ] ) ;
315- if (
316- results . filter ( ( result ) => result . errorCount > 0 || result . warningCount > 0 )
317- . length > 0
318- ) {
319- const formatter = await esLint . loadFormatter ( ) ;
320- const errors = await formatter . format ( results ) ;
321- throw errors ;
322- }
323- } ;
324-
325325const spellCheck = async ( dir , deep = false ) =>
326326 await execute ( `cspell "${ dir } /*${ deep ? '*' : '' } "` ) ;
327327
0 commit comments