Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript-estree): wrap import = declaration in an export node #5885

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7a25528
fix(typescript-estree): wrap import = declaration in an export node
JoshuaKGoldberg Oct 25, 2022
0414e4d
fix(utils): removed `TRuleListener` generic from the `createRule` (#5…
Andarist Oct 25, 2022
04488c2
feat: create TSTypeQuery node when TSImportType has isTypeOf (#3076)
armano2 Oct 26, 2022
ee2fbfa
Merge branch 'main' into v6
JoshuaKGoldberg Oct 26, 2022
c446386
feat(scope-manager): ignore ECMA version (#5889)
JoshuaKGoldberg Oct 26, 2022
cf2956f
feat: remove semantically invalid properties from TSEnumDeclaration, …
juank1809 Oct 26, 2022
b90e7c3
fix(eslint-plugin): remove valid-typeof disable in eslint-recommended…
JoshuaKGoldberg Oct 26, 2022
fff0e29
feat(utils): remove (ts-)eslint-scope types (#5256)
JoshuaKGoldberg Oct 26, 2022
a027cec
Updated snapshots again
JoshuaKGoldberg Oct 26, 2022
3d85274
Merge branch 'main' into v6
JoshuaKGoldberg Oct 26, 2022
51d97ae
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Oct 26, 2022
16a5cfb
Merge branch 'main' into import-equals-wrap-node
JoshuaKGoldberg Nov 18, 2022
74839f9
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Nov 28, 2022
8dd2a42
Remove silly comment
JoshuaKGoldberg Nov 28, 2022
58c4d34
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Dec 11, 2022
b36507f
Just a bit of cleanup
JoshuaKGoldberg Dec 11, 2022
dd858f6
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Dec 16, 2022
28863a4
Remove from ignoreSourceType
JoshuaKGoldberg Dec 16, 2022
b331c98
Remove more fixtures-to-test changes
JoshuaKGoldberg Dec 16, 2022
a128343
Revert "Remove more fixtures-to-test changes"
JoshuaKGoldberg Dec 16, 2022
c60da02
Explained ignoring in comment
JoshuaKGoldberg Dec 16, 2022
d2d052d
remove the wat
JoshuaKGoldberg Dec 16, 2022
c7ea8eb
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Dec 16, 2022
a738b91
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Dec 16, 2022
79a5f81
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldberg Feb 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts
Expand Up @@ -2,7 +2,6 @@ import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSEnumMember } from '../../element/TSEnumMember/spec';
import type { Identifier } from '../../expression/Identifier/spec';
import type { Modifier } from '../../unions/Modifier';

export interface TSEnumDeclaration extends BaseNode {
type: AST_NODE_TYPES.TSEnumDeclaration;
Expand Down Expand Up @@ -30,6 +29,4 @@ export interface TSEnumDeclaration extends BaseNode {
* The enum members.
*/
members: TSEnumMember[];
// TODO(#4759) - breaking change remove this
modifiers?: Modifier[];
}
Expand Up @@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
moduleReference: TSQualifiedName {
type: "TSQualifiedName",
left: TSQualifiedName {
Expand Down
Expand Up @@ -2,5 +2,88 @@

exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many AST Alignment - AST 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
- TSESTree
+ Babel

Program {
type: 'Program',
body: Array [
TSImportEqualsDeclaration {
type: 'TSImportEqualsDeclaration',
id: Identifier {
type: 'Identifier',
name: 'F',

range: [7, 8],
loc: {
start: { column: 7, line: 1 },
end: { column: 8, line: 1 },
},
},
importKind: 'value',
+ isExport: false,
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
moduleReference: TSQualifiedName {
type: 'TSQualifiedName',
left: TSQualifiedName {
type: 'TSQualifiedName',
left: Identifier {
type: 'Identifier',
name: 'A',

range: [11, 12],
loc: {
start: { column: 11, line: 1 },
end: { column: 12, line: 1 },
},
},
right: Identifier {
type: 'Identifier',
name: 'B',

range: [13, 14],
loc: {
start: { column: 13, line: 1 },
end: { column: 14, line: 1 },
},
},

range: [11, 14],
loc: {
start: { column: 11, line: 1 },
end: { column: 14, line: 1 },
},
},
right: Identifier {
type: 'Identifier',
name: 'C',

range: [15, 16],
loc: {
start: { column: 15, line: 1 },
end: { column: 16, line: 1 },
},
},

range: [11, 16],
loc: {
start: { column: 11, line: 1 },
end: { column: 16, line: 1 },
},
},

range: [0, 17],
loc: {
start: { column: 0, line: 1 },
end: { column: 17, line: 1 },
},
},
],
sourceType: 'script',

range: [0, 18],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}"
`;
Expand Up @@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
moduleReference: Identifier {
type: "Identifier",
name: "A",
Expand Down
Expand Up @@ -2,5 +2,50 @@

exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one AST Alignment - AST 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
- TSESTree
+ Babel

Program {
type: 'Program',
body: Array [
TSImportEqualsDeclaration {
type: 'TSImportEqualsDeclaration',
id: Identifier {
type: 'Identifier',
name: 'F',

range: [7, 8],
loc: {
start: { column: 7, line: 1 },
end: { column: 8, line: 1 },
},
},
importKind: 'value',
+ isExport: false,
moduleReference: Identifier {
type: 'Identifier',
name: 'A',

range: [11, 12],
loc: {
start: { column: 11, line: 1 },
end: { column: 12, line: 1 },
},
},

range: [0, 13],
loc: {
start: { column: 0, line: 1 },
end: { column: 13, line: 1 },
},
},
],
sourceType: 'script',

range: [0, 14],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}"
`;
Expand Up @@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
moduleReference: TSExternalModuleReference {
type: "TSExternalModuleReference",
expression: Literal {
Expand Down
Expand Up @@ -21,7 +21,7 @@ exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-
},
},
importKind: 'value',
isExport: false,
+ isExport: false,
moduleReference: TSExternalModuleReference {
type: 'TSExternalModuleReference',
expression: Literal {
Expand Down
Expand Up @@ -22,12 +22,4 @@ export interface TSImportEqualsDeclaration extends BaseNode {
moduleReference: EntityName | TSExternalModuleReference;
// TODO(#1852) - breaking change remove this as it is invalid
importKind: ImportKind;
/**
* Whether this is immediately exported
* ```
* export import F = A;
* ```
*/
// TODO(#4130) - this should be represented in the AST
isExport: boolean;
}
Expand Up @@ -7,8 +7,6 @@ import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDe

export interface TSInterfaceDeclaration extends BaseNode {
type: AST_NODE_TYPES.TSInterfaceDeclaration;
// TODO(#4759) - breaking change remove this
abstract?: boolean;
/**
* The body of the interface
*/
Expand All @@ -26,8 +24,6 @@ export interface TSInterfaceDeclaration extends BaseNode {
* The name of this interface
*/
id: Identifier;
// TODO(#4759) - breaking change remove this
implements?: TSInterfaceHeritage[];
/**
* The generic type parameters declared for the interface.
* This is `undefined` if there are no generic type parameters declared.
Expand Down
3 changes: 0 additions & 3 deletions packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts
Expand Up @@ -3,7 +3,6 @@ import type { BaseNode } from '../../base/BaseNode';
import type { Identifier } from '../../expression/Identifier/spec';
import type { TSModuleBlock } from '../../special/TSModuleBlock/spec';
import type { Literal } from '../../unions/Literal';
import type { Modifier } from '../../unions/Modifier';

export interface TSModuleDeclaration extends BaseNode {
type: AST_NODE_TYPES.TSModuleDeclaration;
Expand Down Expand Up @@ -49,6 +48,4 @@ export interface TSModuleDeclaration extends BaseNode {
*/
// TODO(#5020) - make this `false` if it is not `declare`d
declare?: boolean;
// TODO(#4759) - breaking change remove this
modifiers?: Modifier[];
}
1 change: 0 additions & 1 deletion packages/ast-spec/src/index.ts
Expand Up @@ -26,7 +26,6 @@ export * from './unions/JSXTagNameExpression';
export * from './unions/LeftHandSideExpression';
export * from './unions/Literal';
export * from './unions/LiteralExpression';
export * from './unions/Modifier';
export * from './unions/Node';
export * from './unions/ObjectLiteralElement';
export * from './unions/Parameter';
Expand Down
3 changes: 1 addition & 2 deletions packages/ast-spec/src/type/TSImportType/spec.ts
Expand Up @@ -6,8 +6,7 @@ import type { TypeNode } from '../../unions/TypeNode';

export interface TSImportType extends BaseNode {
type: AST_NODE_TYPES.TSImportType;
isTypeOf: boolean;
parameter: TypeNode;
argument: TypeNode;
qualifier: EntityName | null;
typeParameters: TSTypeParameterInstantiation | null;
}
3 changes: 2 additions & 1 deletion packages/ast-spec/src/type/TSTypeQuery/spec.ts
Expand Up @@ -2,9 +2,10 @@ import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSTypeParameterInstantiation } from '../../special/spec';
import type { EntityName } from '../../unions/EntityName';
import type { TSImportType } from '../TSImportType/spec';

export interface TSTypeQuery extends BaseNode {
type: AST_NODE_TYPES.TSTypeQuery;
exprName: EntityName;
exprName: EntityName | TSImportType;
typeParameters?: TSTypeParameterInstantiation;
}
2 changes: 2 additions & 0 deletions packages/ast-spec/src/unions/ExportDeclaration.ts
Expand Up @@ -8,6 +8,7 @@ import type {
} from '../declaration/FunctionDeclaration/spec';
import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec';
import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec';
import type { TSImportEqualsDeclaration } from '../declaration/TSImportEqualsDeclaration/spec';
import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec';
import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec';
import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec';
Expand Down Expand Up @@ -37,6 +38,7 @@ export type NamedExportDeclarations =
| FunctionDeclarationWithOptionalName
| TSDeclareFunction
| TSEnumDeclaration
| TSImportEqualsDeclaration
| TSInterfaceDeclaration
| TSModuleDeclaration
| TSTypeAliasDeclaration
Expand Down
16 changes: 0 additions & 16 deletions packages/ast-spec/src/unions/Modifier.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/ast-spec/tests/fixtures-with-differences-ast.shot
Expand Up @@ -17,6 +17,8 @@ Set {
"declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts",
"declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts",
"declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/src/configs/eslint-recommended.ts
Expand Up @@ -28,7 +28,6 @@ export = {
'prefer-const': 'error', // ts provides better types with const
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
'valid-typeof': 'off', // ts(2367)
},
},
],
Expand Down
1 change: 0 additions & 1 deletion packages/parser/src/parser.ts
Expand Up @@ -105,7 +105,6 @@ function parseForESLint(
jsx: validateBoolean(options.ecmaFeatures.jsx),
});
const analyzeOptions: AnalyzeOptions = {
ecmaVersion: options.ecmaVersion === 'latest' ? 1e8 : options.ecmaVersion,
globalReturn: options.ecmaFeatures.globalReturn,
jsxPragma: options.jsxPragma,
jsxFragmentName: options.jsxFragmentName,
Expand Down
8 changes: 0 additions & 8 deletions packages/parser/tests/lib/parser.ts
Expand Up @@ -19,11 +19,6 @@ describe('parser', () => {
expect(() => parseForESLint(code, null)).not.toThrow();
});

it("parseForESLint() should work if options.ecmaVersion is `'latest'`", () => {
const code = 'const valid = true;';
expect(() => parseForESLint(code, { ecmaVersion: 'latest' })).not.toThrow();
});

it('parseAndGenerateServices() should be called with options', () => {
const code = 'const valid = true;';
const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices');
Expand All @@ -33,7 +28,6 @@ describe('parser', () => {
range: false,
tokens: false,
sourceType: 'module' as const,
ecmaVersion: 2018,
ecmaFeatures: {
globalReturn: false,
jsx: false,
Expand Down Expand Up @@ -84,7 +78,6 @@ describe('parser', () => {
range: false,
tokens: false,
sourceType: 'module' as const,
ecmaVersion: 2018,
ecmaFeatures: {
globalReturn: false,
jsx: false,
Expand All @@ -104,7 +97,6 @@ describe('parser', () => {
parseForESLint(code, config);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenLastCalledWith(expect.anything(), {
ecmaVersion: 2018,
globalReturn: false,
lib: ['dom.iterable'],
jsxPragma: 'Foo',
Expand Down
12 changes: 2 additions & 10 deletions packages/scope-manager/README.md
Expand Up @@ -36,13 +36,6 @@ interface AnalyzeOptions {
*/
childVisitorKeys?: Record<string, string[]> | null;

/**
* Which ECMAScript version is considered.
* Defaults to `2018`.
* `'latest'` is converted to 1e8 at parser.
*/
ecmaVersion?: EcmaVersion | 1e8;

/**
* Whether the whole script is executed under node.js environment.
* When enabled, the scope manager adds a function scope immediately following the global scope.
Expand All @@ -51,7 +44,7 @@ interface AnalyzeOptions {
globalReturn?: boolean;

/**
* Implied strict mode (if ecmaVersion >= 5).
* Implied strict mode.
* Defaults to `false`.
*/
impliedStrict?: boolean;
Expand All @@ -76,7 +69,7 @@ interface AnalyzeOptions {
* This automatically defines a type variable for any types provided by the configured TS libs.
* For more information, see https://www.typescriptlang.org/tsconfig#lib
*
* Defaults to the lib for the provided `ecmaVersion`.
* Defaults to ['esnext'].
*/
lib?: Lib[];

Expand Down Expand Up @@ -105,7 +98,6 @@ const ast = parse(code, {
range: true,
});
const scope = analyze(ast, {
ecmaVersion: 2020,
sourceType: 'module',
});
```
Expand Down