1
1
'use strict' ;
2
2
3
3
const RuleTester = require ( 'eslint' ) . RuleTester ;
4
- const tester = new RuleTester ( {
5
- parserOptions : {
6
- ecmaVersion : 13 ,
7
- sourceType : 'module' ,
8
- } ,
9
- } ) ;
4
+ const tester = new RuleTester ( ) ;
10
5
11
6
const ruleName = 'detect-non-literal-fs-filename' ;
12
7
@@ -33,8 +28,10 @@ tester.run(ruleName, require(`../../rules/${ruleName}`), {
33
28
const index = await fsp.readFile(path.resolve(__dirname, './index.html'), 'utf-8');
34
29
const key = fs.readFileSync(path.join(__dirname, './ssl.key'));
35
30
await fsp.writeFile(path.resolve(__dirname, './sitemap.xml'), sitemap);` ,
36
- globals : {
37
- __dirname : 'readonly' ,
31
+ languageOptions : {
32
+ globals : {
33
+ __dirname : 'readonly' ,
34
+ } ,
38
35
} ,
39
36
} ,
40
37
{
@@ -43,16 +40,20 @@ tester.run(ruleName, require(`../../rules/${ruleName}`), {
43
40
import path from 'path';
44
41
const dirname = path.dirname(__filename)
45
42
const key = fs.readFileSync(path.resolve(dirname, './index.html'));` ,
46
- globals : {
47
- __filename : 'readonly' ,
43
+ languageOptions : {
44
+ globals : {
45
+ __filename : 'readonly' ,
46
+ } ,
48
47
} ,
49
48
} ,
50
49
{
51
50
code : `
52
51
import fs from 'fs';
53
52
const key = fs.readFileSync(\`\${process.cwd()}/path/to/foo.json\`);` ,
54
- globals : {
55
- process : 'readonly' ,
53
+ languageOptions : {
54
+ globals : {
55
+ process : 'readonly' ,
56
+ } ,
56
57
} ,
57
58
} ,
58
59
`
@@ -65,8 +66,10 @@ tester.run(ruleName, require(`../../rules/${ruleName}`), {
65
66
code : `
66
67
import fs from 'fs';
67
68
const pkg = fs.readFileSync(require.resolve('eslint/package.json'), 'utf-8');` ,
68
- globals : {
69
- require : 'readonly' ,
69
+ languageOptions : {
70
+ globals : {
71
+ require : 'readonly' ,
72
+ } ,
70
73
} ,
71
74
} ,
72
75
] ,
@@ -191,8 +194,10 @@ tester.run(ruleName, require(`../../rules/${ruleName}`), {
191
194
import fs from 'fs';
192
195
import path from 'path';
193
196
const key = fs.readFileSync(path.resolve(__dirname, foo));` ,
194
- globals : {
195
- __filename : 'readonly' ,
197
+ languageOptions : {
198
+ globals : {
199
+ __filename : 'readonly' ,
200
+ } ,
196
201
} ,
197
202
errors : [ { message : 'Found readFileSync from package "fs" with non literal argument at index 0' } ] ,
198
203
} ,
0 commit comments