File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,13 +29,16 @@ const resolvedLintConfig: RslintConfig = lintEntries.map((entry) => ({
2929 ...entry ,
3030} ) ) ;
3131
32- const hasExplicitProject = lintEntries . some (
33- ( entry ) => entry . languageOptions ?. parserOptions ?. project !== undefined ,
34- ) ;
32+ const hasExplicitProjectMode = lintEntries . some ( ( entry ) => {
33+ const options = entry . languageOptions ?. parserOptions ;
34+ return (
35+ options ?. project !== undefined || options ?. projectService !== undefined
36+ ) ;
37+ } ) ;
3538
3639// Rslint's implicit tsconfig lookup also follows the internal config directory.
37- // Preserve the CWD lookup without overriding user projects .
38- if ( ! hasExplicitProject && existsSync ( join ( basePath , 'tsconfig.json' ) ) ) {
40+ // Preserve the CWD lookup only when neither project option is explicitly set .
41+ if ( ! hasExplicitProjectMode && existsSync ( join ( basePath , 'tsconfig.json' ) ) ) {
3942 resolvedLintConfig . push ( {
4043 basePath,
4144 languageOptions : {
Original file line number Diff line number Diff line change @@ -168,6 +168,40 @@ test('enables type checking only with --type-check', () => {
168168 expect ( withTypeCheck . stdout ) . toContain ( 'Format check passed in' ) ;
169169} ) ;
170170
171+ test . each ( [ true , false ] ) (
172+ 'respects explicit projectService: %s with a root tsconfig' ,
173+ ( projectService ) => {
174+ writeProjectFile (
175+ 'rstack.config.ts' ,
176+ `import { define } from 'rstack';
177+
178+ define.lint([
179+ {
180+ files: ['**/*.ts'],
181+ languageOptions: {
182+ parserOptions: { projectService: ${ projectService } },
183+ },
184+ rules: { 'no-debugger': 'error' },
185+ },
186+ ]);
187+ ` ,
188+ ) ;
189+ writeProjectFile ( 'tsconfig.json' , '{"include":["src"]}\n' ) ;
190+ writeProjectFile ( 'src/index.ts' , 'const value: string = 1;\n' ) ;
191+
192+ const result = runCheck ( [ '--type-check' , 'src/index.ts' ] ) ;
193+
194+ expect ( result . status ) . toBe ( projectService ? 1 : 0 ) ;
195+ const output = `${ result . stdout } \n${ result . stderr } ` ;
196+ if ( projectService ) {
197+ expect ( output ) . toContain ( 'TS2322' ) ;
198+ } else {
199+ expect ( output ) . not . toContain ( 'TS2322' ) ;
200+ }
201+ expect ( result . stdout ) . toContain ( 'Format check passed in' ) ;
202+ } ,
203+ ) ;
204+
171205test . each ( [
172206 { source : 'debugger;\n' , formatted : true } ,
173207 { source : 'debugger;const value=true' , formatted : false } ,
You can’t perform that action at this time.
0 commit comments