@@ -13,7 +13,7 @@ import type { ResolvedFmtConfig } from './types.ts';
1313 * Prettier already skips other generated lock files when it cannot infer a parser, so this list
1414 * contains only the additional defaults owned by `rs fmt`.
1515 */
16- const defaultIgnoreNames = [
16+ const defaultIgnorePatterns = [
1717 'package-lock.json' ,
1818 'pnpm-lock.yaml' ,
1919 'skills-lock.json' ,
@@ -44,20 +44,6 @@ interface CreateIgnoreMatcherOptions {
4444 precheck ?: IgnorePredicate ;
4545}
4646
47- const createDefaultMatcher = ( ) : IgnoreMatcher => {
48- const suffixes = defaultIgnoreNames . map ( ( name ) => `${ path . sep } ${ name } ` ) ;
49-
50- return ( filePath ) => suffixes . some ( ( suffix ) => filePath . endsWith ( suffix ) ) ;
51- } ;
52-
53- const combineIgnorePredicates = (
54- first : IgnorePredicate ,
55- second : IgnorePredicate ,
56- ) : IgnorePredicate => {
57- return ( filePath , isDirectory = false ) =>
58- first ( filePath , isDirectory ) || second ( filePath , isDirectory ) ;
59- } ;
60-
6147const createSourceMatcher = (
6248 sources : IgnoreSource [ ] ,
6349 precheck ?: IgnorePredicate ,
@@ -107,30 +93,18 @@ const createIgnoreMatcher = async ({
10793 const ignoreFileSources = await Promise . all (
10894 ignorePaths . map ( ( ignorePath ) => loadIgnoreSource ( cwd , ignorePath ) ) ,
10995 ) ;
110- if ( config . ignorePatterns . length ) {
111- return createSourceMatcher (
112- [
113- {
114- rootPath : config . rootPath ,
115- patterns : [ ...defaultIgnoreNames , ...config . ignorePatterns ] . join (
116- '\n' ,
117- ) ,
118- } ,
119- ...ignoreFileSources ,
120- ] ,
121- precheck ,
122- ) ;
123- }
124-
125- const defaultMatcher = createDefaultMatcher ( ) ;
126- const matcher = precheck
127- ? combineIgnorePredicates ( precheck , defaultMatcher )
128- : defaultMatcher ;
129- if ( ignoreFileSources . length === 0 ) {
130- return matcher ;
131- }
132-
133- return createSourceMatcher ( ignoreFileSources , matcher ) ;
96+ return createSourceMatcher (
97+ [
98+ {
99+ rootPath : config . rootPath ,
100+ patterns : [ ...defaultIgnorePatterns , ...config . ignorePatterns ] . join (
101+ '\n' ,
102+ ) ,
103+ } ,
104+ ...ignoreFileSources ,
105+ ] ,
106+ precheck ,
107+ ) ;
134108} ;
135109
136110export { createIgnoreMatcher } ;
0 commit comments