11import { minimatch } from 'minimatch' ;
2- import type { Options } from './options' ;
2+ import { TYPES , type Type } from './options' ;
33
4- const TYPE_PATTERNS = {
5- service : '**/services/**/*.js' ,
6- services : '**/services/**/*.js' ,
7- controller : '**/controllers/**/*.js' ,
8- controllers : '**/controllers/**/*.js' ,
9- component : '**/components/**/*.js' ,
10- components : '**/components/**/*.js' ,
11- route : '**/routes/**/*.js' ,
12- routes : '**/routes/**/*.js' ,
13- } as const ;
4+ const TYPE_PATTERNS = Object . fromEntries (
5+ TYPES . map ( ( type ) => [ type , `**/${ type } /**/*.js` ] as const )
6+ ) as Record < Type , string > ;
147
158const TEST_FILE_PATTERN = '**/*-test.js' as const ;
169
@@ -23,10 +16,6 @@ export function isTestFile(file: string): boolean {
2316 * Returns true if the given path matches the type of ember object
2417 * The glob patterns are specified by `TYPE_PATTERNS`
2518 */
26- export function isFileOfType ( file : string , type : Options [ 'type' ] ) : boolean {
27- return (
28- // False positive
29- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
30- ! ! type && ! ! TYPE_PATTERNS [ type ] && minimatch ( file , TYPE_PATTERNS [ type ] )
31- ) ;
19+ export function isFileOfType ( file : string , type : Type ) : boolean {
20+ return minimatch ( file , TYPE_PATTERNS [ type ] ) ;
3221}
0 commit comments