Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 6, 2024
1 parent 6dde0ac commit 51845d9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
54 changes: 44 additions & 10 deletions test/prevent-abbreviations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ const noExtendDefaultAllowListOptions = [
];

const tests = {
testerOptions: {
languageOptions: {
globals: {
document: 'readonly',
event: 'readonly',
Response: 'readonly',
},
},
},
valid: [
'let x',
'({x: 1})',
Expand Down Expand Up @@ -1303,12 +1312,15 @@ test.typescript(avoidTestTitleConflict(tests, 'typescript'));

test({
testerOptions: {
parserOptions: {
sourceType: 'script',
ecmaVersion: 5,
},
env: {
browser: true,
languageOptions: {
parserOptions: {
sourceType: 'script',
ecmaVersion: 5,
},
globals: {
document: 'readonly',
event: 'readonly',
},
},
},
valid: [],
Expand Down Expand Up @@ -1785,6 +1797,15 @@ test.babel({
});

test.typescript({
testerOptions: {
languageOptions: {
globals: {
document: 'readonly',
event: 'readonly',
Response: 'readonly',
},
},
},
valid: [],
invalid: [
// Types
Expand Down Expand Up @@ -1894,9 +1915,11 @@ test.typescript({
// JSX
test.typescript({
testerOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
Expand Down Expand Up @@ -1963,7 +1986,18 @@ test({
},
{
code: 'foo();',
filename: '/path/to/doc/__prev-Attr$1Err__.conf.js',
/*
There should be a bug in `RuleTester`, if we use `/path/to/doc/__prev-Attr$1Err__.conf.js`,
There will be an error
```
No matching configuration found for /path/to/doc/__prev-Attr$1Err__.conf.js.
```
TODO[@fisker]: investigate the root cause
*/
// filename: '/path/to/doc/__prev-Attr$1Err__.conf.js',
filename: 'path/to/doc/__prev-Attr$1Err__.conf.js',
errors: createErrors('The filename `__prev-Attr$1Err__.conf.js` should be named `__previous-Attribute$1Error__.config.js`. A more descriptive name will do too.'),
},
{
Expand Down
8 changes: 6 additions & 2 deletions test/utils/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Tester {
parser: testerOptions.languageOptions?.parser ?? defaultOptions.languageOptions.parser,
globals: {
...defaultOptions.globals,
...testerOptions.globals,
...testerOptions.languageOptions?.globals,
},
},
};
Expand Down Expand Up @@ -139,7 +139,7 @@ class Tester {
parser: testerOptions.languageOptions.parser ?? defaultOptions.languageOptions.parser,
globals: {
...defaultOptions.globals,
...testerOptions.globals,
...testerOptions.languageOptions.globals,
},
parserOptions: {
...defaultOptions.parserOptions,
Expand Down Expand Up @@ -171,6 +171,10 @@ function getTester(importMeta) {
...testerOptions,
languageOptions: {
parserOptions: mergeParserOptions(testerOptions.languageOptions?.parserOptions),
globals: {
...defaultOptions.globals,
...testerOptions.languageOptions?.globals,
},
parser: parserSettings.__todo_fix_this_parser,
},
},
Expand Down

0 comments on commit 51845d9

Please sign in to comment.