Skip to content

Commit

Permalink
test(scope-manager): tweak fixture tests (#2389)
Browse files Browse the repository at this point in the history
- Add `isWrite` and `isRead` to the `Reference` output
- allow JSX parsing
- regenerate libs
  • Loading branch information
bradzacher committed Aug 12, 2020
1 parent 092c969 commit 8318c36
Show file tree
Hide file tree
Showing 206 changed files with 1,053 additions and 21 deletions.
32 changes: 23 additions & 9 deletions packages/scope-manager/src/lib/dom.ts
Expand Up @@ -6578,11 +6578,11 @@ export const dom = {
name: 'SharedWorker',
writeable: false,
},
Slotable: {
Slottable: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'Slotable',
name: 'Slottable',
writeable: false,
},
SourceBufferEventMap: {
Expand Down Expand Up @@ -7068,6 +7068,20 @@ export const dom = {
name: 'VideoPlaybackQuality',
writeable: false,
},
VisualViewportEventMap: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'VisualViewportEventMap',
writeable: false,
},
VisualViewport: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: true,
name: 'VisualViewport',
writeable: false,
},
WEBGL_color_buffer_float: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
Expand Down Expand Up @@ -8426,6 +8440,13 @@ export const dom = {
name: 'CredentialMediationRequirement',
writeable: false,
},
DOMParserSupportedType: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'DOMParserSupportedType',
writeable: false,
},
DirectionSetting: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
Expand Down Expand Up @@ -9126,13 +9147,6 @@ export const dom = {
name: 'SpeechSynthesisErrorCode',
writeable: false,
},
SupportedType: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'SupportedType',
writeable: false,
},
TextTrackKind: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
Expand Down
14 changes: 14 additions & 0 deletions packages/scope-manager/src/lib/es2020.bigint.ts
Expand Up @@ -5,6 +5,13 @@
import { ImplicitLibVariableOptions } from '../variable';

export const es2020_bigint = {
BigIntToLocaleStringOptions: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'BigIntToLocaleStringOptions',
writeable: false,
},
BigInt: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
Expand Down Expand Up @@ -54,4 +61,11 @@ export const es2020_bigint = {
name: 'DataView',
writeable: false,
},
Intl: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: true,
name: 'Intl',
writeable: false,
},
} as Record<string, ImplicitLibVariableOptions>;
15 changes: 15 additions & 0 deletions packages/scope-manager/src/lib/es2020.intl.ts
@@ -0,0 +1,15 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:lib

import { ImplicitLibVariableOptions } from '../variable';

export const es2020_intl = {
Intl: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: true,
name: 'Intl',
writeable: false,
},
} as Record<string, ImplicitLibVariableOptions>;
2 changes: 2 additions & 0 deletions packages/scope-manager/src/lib/es2020.ts
Expand Up @@ -8,11 +8,13 @@ import { es2020_bigint } from './es2020.bigint';
import { es2020_promise } from './es2020.promise';
import { es2020_string } from './es2020.string';
import { es2020_symbol_wellknown } from './es2020.symbol.wellknown';
import { es2020_intl } from './es2020.intl';

export const es2020 = {
...es2019,
...es2020_bigint,
...es2020_promise,
...es2020_string,
...es2020_symbol_wellknown,
...es2020_intl,
} as Record<string, ImplicitLibVariableOptions>;
14 changes: 14 additions & 0 deletions packages/scope-manager/src/lib/esnext.bigint.ts
Expand Up @@ -5,6 +5,13 @@
import { ImplicitLibVariableOptions } from '../variable';

export const esnext_bigint = {
BigIntToLocaleStringOptions: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: false,
name: 'BigIntToLocaleStringOptions',
writeable: false,
},
BigInt: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
Expand Down Expand Up @@ -54,4 +61,11 @@ export const esnext_bigint = {
name: 'DataView',
writeable: false,
},
Intl: {
eslintImplicitGlobalSetting: 'readonly',
isTypeVariable: true,
isValueVariable: true,
name: 'Intl',
writeable: false,
},
} as Record<string, ImplicitLibVariableOptions>;
2 changes: 2 additions & 0 deletions packages/scope-manager/src/lib/index.ts
Expand Up @@ -45,6 +45,7 @@ import { es2020_bigint } from './es2020.bigint';
import { es2020_promise } from './es2020.promise';
import { es2020_string } from './es2020.string';
import { es2020_symbol_wellknown } from './es2020.symbol.wellknown';
import { es2020_intl } from './es2020.intl';
import { esnext_array } from './esnext.array';
import { esnext_symbol } from './esnext.symbol';
import { esnext_asynciterable } from './esnext.asynciterable';
Expand Down Expand Up @@ -104,6 +105,7 @@ const lib = {
'es2020.promise': es2020_promise,
'es2020.string': es2020_string,
'es2020.symbol.wellknown': es2020_symbol_wellknown,
'es2020.intl': es2020_intl,
'esnext.array': esnext_array,
'esnext.symbol': esnext_symbol,
'esnext.asynciterable': esnext_asynciterable,
Expand Down
12 changes: 11 additions & 1 deletion packages/scope-manager/tests/fixtures.test.ts
Expand Up @@ -24,6 +24,7 @@ const fixtures = glob
return {
absolute,
name,
ext,
segments,
snapshotPath,
snapshotFile: path.join(snapshotPath, `${name}${ext}.shot`),
Expand Down Expand Up @@ -59,6 +60,13 @@ function nestDescribe(
const options: Record<string, unknown> = {
lib: [],
};

/*
* What's all this!?
*
* To help with configuring individual tests, each test may use a four-slash comment to configure the scope manager
* This is just a rudimentary "parser" for said comments.
*/
for (const line of lines) {
if (!line.startsWith('////')) {
continue;
Expand Down Expand Up @@ -137,7 +145,9 @@ function nestDescribe(
}

try {
const { scopeManager } = parseAndAnalyze(contents, options);
const { scopeManager } = parseAndAnalyze(contents, options, {
jsx: fixture.ext.endsWith('x'),
});
expect(scopeManager).toMatchSpecificSnapshot(fixture.snapshotFile);
} catch (e) {
expect(e).toMatchSpecificSnapshot(fixture.snapshotFile);
Expand Down
Expand Up @@ -15,15 +15,19 @@ ScopeManager {
Reference$1 {
identifier: Identifier<"a">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$1,
writeExpr: Literal$2,
},
Reference$2 {
identifier: Identifier<"a">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$1,
},
],
Expand Down
8 changes: 8 additions & 0 deletions packages/scope-manager/tests/fixtures/block/scope.ts.shot
Expand Up @@ -15,15 +15,19 @@ ScopeManager {
Reference$1 {
identifier: Identifier<"i">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$1,
writeExpr: Literal$2,
},
Reference$3 {
identifier: Identifier<"i">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$1,
},
],
Expand All @@ -42,8 +46,10 @@ ScopeManager {
Reference$2 {
identifier: Identifier<"j">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$2,
writeExpr: Literal$4,
},
Expand All @@ -59,8 +65,10 @@ ScopeManager {
references: Array [
Reference$4 {
identifier: Identifier<"j">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: null,
},
],
Expand Down
Expand Up @@ -15,21 +15,27 @@ ScopeManager {
Reference$1 {
identifier: Identifier<"foo">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$1,
writeExpr: ArrowFunctionExpression$2,
},
Reference$3 {
identifier: Identifier<"foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$1,
},
Reference$5 {
identifier: Identifier<"foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$1,
},
],
Expand All @@ -48,21 +54,27 @@ ScopeManager {
Reference$2 {
identifier: Identifier<"a">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$2,
writeExpr: Literal$4,
},
Reference$4 {
identifier: Identifier<"a">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$2,
},
Reference$6 {
identifier: Identifier<"a">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$2,
},
],
Expand Down
Expand Up @@ -14,8 +14,10 @@ ScopeManager {
references: Array [
Reference$2 {
identifier: Identifier<"T">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: Variable$1,
},
],
Expand All @@ -30,8 +32,10 @@ ScopeManager {
references: Array [
Reference$1 {
identifier: Identifier<"foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: null,
},
Reference$2,
Expand Down
Expand Up @@ -15,8 +15,10 @@ ScopeManager {
Reference$1 {
identifier: Identifier<"T">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$1,
writeExpr: Literal$2,
},
Expand All @@ -33,14 +35,18 @@ ScopeManager {
Reference$1,
Reference$2 {
identifier: Identifier<"foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: null,
},
Reference$3 {
identifier: Identifier<"T">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: null,
},
],
Expand Down
Expand Up @@ -15,15 +15,19 @@ ScopeManager {
Reference$1 {
identifier: Identifier<"a">,
init: true,
isRead: false,
isTypeReference: false,
isValueReference: true,
isWrite: true,
resolved: Variable$1,
writeExpr: Literal$2,
},
Reference$2 {
identifier: Identifier<"a">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$1,
},
],
Expand Down

0 comments on commit 8318c36

Please sign in to comment.