@@ -57,6 +57,7 @@ describe('should pass lint without error in new projects', () => {
5757 'with-vitest' ,
5858 'type-checked' ,
5959 'api-before-14.3' ,
60+ 'custom-type-checked-rules-on-and-off' ,
6061 ] ) {
6162 test ( projectName , async ( ) => {
6263 const { stdout } = await runLintAgainst ( projectName )
@@ -83,6 +84,7 @@ describe('should report error on recommended rule violations in .vue files', ()
8384 'with-vitest' ,
8485 'type-checked' ,
8586 'api-before-14.3' ,
87+ 'custom-type-checked-rules-on-and-off' ,
8688 ] ) {
8789 test ( `src/App.vue in ${ projectName } ` , async ( ) => {
8890 const appVuePath = path . join (
@@ -210,3 +212,23 @@ test('(API before 14.3) should guide user to use camelCase names in "extends"',
210212 expect ( failed ) . toBe ( true )
211213 expect ( stderr ) . contain ( 'Please use "recommendedTypeChecked"' )
212214} )
215+
216+ test ( 'should allow users to turn on/off type-aware rules by just targeting `**/*.vue` files' , async ( ) => {
217+ const appVuePath = path . join ( __dirname , '../examples/custom-type-checked-rules-on-and-off/src/App.vue' )
218+ const { modify, restore } = setupFileMutations ( appVuePath )
219+ modify ( ( oldContents ) => oldContents . replace ( '</script>' , `
220+ // Should not cause lint error
221+ export type UnionUnknown = unknown | 'foo';
222+
223+ const array: number[] = [];
224+ // Should cause lint error
225+ array.sort();
226+ </script>` ) )
227+
228+ const { failed, stdout } = await runLintAgainst ( 'custom-type-checked-rules-on-and-off' )
229+ restore ( )
230+
231+ expect ( failed ) . toBe ( true )
232+ expect ( stdout ) . not . toContain ( 'no-redundant-type-constituents' )
233+ expect ( stdout ) . toContain ( 'require-array-sort-compare' )
234+ } )
0 commit comments