Skip to content

Commit

Permalink
test(typescript-estree): update ast-alignment tests (#2938)
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jan 19, 2021
1 parent a241b25 commit 1932c8b
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 216 deletions.
6 changes: 3 additions & 3 deletions packages/typescript-estree/package.json
Expand Up @@ -51,9 +51,9 @@
"tsutils": "^3.17.1"
},
"devDependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/parser": "^7.12.7",
"@babel/types": "^7.12.6",
"@babel/code-frame": "^7.12.11",
"@babel/parser": "^7.12.11",
"@babel/types": "^7.12.12",
"@types/babel__code-frame": "^7.0.2",
"@types/debug": "*",
"@types/glob": "*",
Expand Down
85 changes: 7 additions & 78 deletions packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
Expand Up @@ -141,15 +141,7 @@ tester.addFixturePatternConfig('javascript/arrayLiteral');

tester.addFixturePatternConfig('javascript/simple-literals');

tester.addFixturePatternConfig('javascript/directives', {
ignore: [
/**
* Babel errors on accessors:
* https://github.com/babel/babel/issues/12335
*/
'directive-in-class',
],
});
tester.addFixturePatternConfig('javascript/directives');

tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread');

Expand Down Expand Up @@ -184,15 +176,7 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', {
'error-strict-param-no-paren-eval',
],
});
tester.addFixturePatternConfig('javascript/function', {
ignore: [
/**
* Babel has invalid end range of multiline SequenceExpression
* TODO: report it to babel
*/
'return-multiline-sequence',
],
});
tester.addFixturePatternConfig('javascript/function');

tester.addFixturePatternConfig('javascript/bigIntLiterals');
tester.addFixturePatternConfig('javascript/binaryLiterals');
Expand All @@ -203,20 +187,15 @@ tester.addFixturePatternConfig('javascript/callExpression');
tester.addFixturePatternConfig('javascript/classes', {
ignore: [
/**
* super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this.
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* super() is being used outside of constructor.
* Other parsers (e.g. espree, acorn) do not error on this.
*/
'class-one-method-super', // babel parse errors
'class-one-method-super',
/**
* TS3.6 made computed constructors parse as actual constructors.
*/
'class-two-methods-computed-constructor',
/**
* Babel errors on accessors:
* https://github.com/babel/babel/issues/12335
*/
'class-accessor-properties',
'class-static-methods-and-accessor-properties',
'invalid-class-setter-declaration',
],
});

Expand Down Expand Up @@ -287,15 +266,7 @@ tester.addFixturePatternConfig('javascript/modules', {
tester.addFixturePatternConfig('javascript/newTarget');

tester.addFixturePatternConfig('javascript/objectLiteral');
tester.addFixturePatternConfig('javascript/objectLiteralComputedProperties', {
ignore: [
/**
* Babel errors on accessors:
* https://github.com/babel/babel/issues/12335
*/
'computed-getter-and-setter',
],
});
tester.addFixturePatternConfig('javascript/objectLiteralComputedProperties');

tester.addFixturePatternConfig('javascript/objectLiteralDuplicateProperties', {
ignore: [
Expand Down Expand Up @@ -415,13 +386,6 @@ tester.addFixturePatternConfig('typescript/basics', {
'type-guard-in-arrow-function',
'type-guard-in-function',
'type-guard-in-interface',
/**
* TS 3.7: declare class properties
* Babel: declare is not allowed with accessibility modifiers
* TODO: report this to babel
*/
'abstract-class-with-declare-properties',
'class-with-declare-properties',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* This is intentional; we don't error on semantic problems for these cases
Expand All @@ -431,16 +395,6 @@ tester.addFixturePatternConfig('typescript/basics', {
'catch-clause-with-invalid-annotation',
'export-type-star-from',
'import-type-error',
/**
* Babel reports incorrect location
* https://github.com/babel/babel/issues/11939
*/
'catch-clause-with-annotation',
/**
* Babel errors on accessors:
* https://github.com/babel/babel/issues/12335
*/
'object-with-typed-methods',
],
ignoreSourceType: [
/**
Expand Down Expand Up @@ -470,16 +424,6 @@ tester.addFixturePatternConfig('typescript/basics', {

tester.addFixturePatternConfig('typescript/decorators/accessor-decorators', {
fileType: 'ts',
ignore: [
/**
* Babel errors on accessors:
* https://github.com/babel/babel/issues/12335
*/
'accessor-decorator-factory-instance-member',
'accessor-decorator-factory-static-member',
'accessor-decorator-instance-member',
'accessor-decorator-static-member',
],
});
tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
fileType: 'ts',
Expand Down Expand Up @@ -514,20 +458,6 @@ tester.addFixturePatternConfig('typescript/errorRecovery', {
* TODO: enable error code TS1019: An index signature parameter cannot have a question mark.
*/
'interface-with-optional-index-signature',
/**
* Expected error on empty type arguments and type parameters
* TypeScript report diagnostics correctly but babel not
* https://github.com/babel/babel/issues/9462
*/
'empty-type-arguments',
'empty-type-arguments-in-call-expression',
'empty-type-arguments-in-new-expression',
'empty-type-parameters',
'empty-type-parameters-in-arrow-function',
'empty-type-parameters-in-constructor',
'empty-type-parameters-in-function-expression',
'empty-type-parameters-in-method',
'empty-type-parameters-in-method-signature',
/**
* Babel correctly errors on this
* TODO: enable error code TS1024: 'readonly' modifier can only appear on a property declaration or index signature.
Expand All @@ -546,7 +476,6 @@ tester.addFixturePatternConfig('typescript/types', {
* They produce TSTypeLiteral -> TemplateLiteral, and then force override the expression parser to parse types
* We instead just emit TSTemplateLiteralType.
*/
'template-literal-type-1',
'template-literal-type-2',
'template-literal-type-3',
'template-literal-type-4',
Expand Down
8 changes: 4 additions & 4 deletions packages/typescript-estree/tests/lib/persistentParse.test.ts
Expand Up @@ -116,7 +116,7 @@ function baseTests(

it('allows parsing of deeply nested new files', () => {
const PROJECT_DIR = setup(tsConfigIncludeAll, false);
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
const bazSlashBar = 'baz/bar' as const;

// parse once to: assert the config as correct, and to make sure the program is setup
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();
Expand All @@ -141,7 +141,7 @@ function baseTests(
fs.mkdirSync(path.join(PROJECT_DIR, 'src', 'bat'));
fs.mkdirSync(path.join(PROJECT_DIR, 'src', 'bat', 'baz'));

const bazSlashBar = path.join('bat', 'baz', 'bar') as 'bat/baz/bar';
const bazSlashBar = 'bat/baz/bar' as const;

// write a new file and attempt to parse it
writeFile(PROJECT_DIR, bazSlashBar);
Expand All @@ -151,7 +151,7 @@ function baseTests(

it('allows renaming of files', () => {
const PROJECT_DIR = setup(tsConfigIncludeAll, true);
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
const bazSlashBar = 'baz/bar' as const;

// parse once to: assert the config as correct, and to make sure the program is setup
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('persistent parse', () => {

it('handles tsconfigs with no includes/excludes (nested)', () => {
const PROJECT_DIR = setup({}, false);
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
const bazSlashBar = 'baz/bar' as const;

// parse once to: assert the config as correct, and to make sure the program is setup
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();
Expand Down

0 comments on commit 1932c8b

Please sign in to comment.