File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed
packages/plugin-eslint/lib/remove-parser-options Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,19 @@ const options = {
88 }
99 }
1010} ;
11+
12+ const options2 = {
13+ languageOptions : {
14+ parserOptions : {
15+ projectService : true ,
16+ }
17+ } ,
18+ } ;
19+
20+ const options3 = {
21+ languageOptions : {
22+ parserOptions : {
23+ tsconfigRootDir : import . meta. dirname
24+ }
25+ } ,
26+ } ;
Original file line number Diff line number Diff line change 11import { operator } from 'putout' ;
22
3+ const { keys} = Object ;
34const {
45 traverseProperties,
6+ getProperties,
57 replaceWith,
68} = operator ;
79
8- export const report = ( ) => `Avoid " parserOptions" in FlatConfig` ;
10+ export const report = ( ) => `Avoid ' parserOptions' in FlatConfig` ;
911
1012export const fix = ( path ) => {
1113 replaceWith ( path . parentPath , path . node . value ) ;
@@ -28,10 +30,18 @@ export const traverse = ({push}) => ({
2830 if ( parserPath )
2931 return false ;
3032
31- const [ babelOptionsPath ] = traverseProperties ( parserOptionsPath , 'babelOptions' ) ;
32- const [ ecmaFeatures ] = traverseProperties ( parserOptionsPath , 'ecmaFeatures' ) ;
33+ const names = [
34+ 'babelOptions' ,
35+ 'ecmaFeatures' ,
36+ 'projectService' ,
37+ 'tsconfigRootDir' ,
38+ ] ;
3339
34- if ( ecmaFeatures || babelOptionsPath )
40+ const parserOptionsValuePath = parserOptionsPath . get ( 'value' ) ;
41+ const properties = getProperties ( parserOptionsValuePath , names ) ;
42+ const count = keys ( properties ) . length ;
43+
44+ if ( count )
3545 return ;
3646
3747 push ( parserOptionsPath ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const test = createTest(import.meta.url, {
88} ) ;
99
1010test ( 'eslint: remove-parser-options: report' , ( t ) => {
11- t . report ( 'remove-parser-options' , `Avoid " parserOptions" in FlatConfig` ) ;
11+ t . report ( 'remove-parser-options' , `Avoid ' parserOptions' in FlatConfig` ) ;
1212 t . end ( ) ;
1313} ) ;
1414
You can’t perform that action at this time.
0 commit comments