Skip to content

Commit a7a03ce

Browse files
authored
feat: Move shared types into their own package (#425)
1 parent 6eb97d4 commit a7a03ce

File tree

130 files changed

+1729
-1313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1729
-1313
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ fixtures
55
shared-fixtures
66
coverage
77

8-
packages/typescript-estree/src/estree
98
packages/eslint-plugin-tslint/tests

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"no-dupe-class-members": "off",
1313
"no-mixed-operators": "error",
1414
"no-console": "off",
15+
"no-dupe-class-members": "off",
1516
"no-undef": "off",
1617
"@typescript-eslint/indent": "off",
1718
"@typescript-eslint/no-explicit-any": "off",

packages/eslint-plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"dependencies": {
3939
"@typescript-eslint/parser": "1.7.0",
40-
"@typescript-eslint/typescript-estree": "1.7.0",
40+
"@typescript-eslint/experimental-utils": "1.7.0",
4141
"eslint-utils": "^1.3.1",
4242
"regexpp": "^2.0.1",
4343
"requireindex": "^1.2.0",

packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type RuleNode =

packages/eslint-plugin/src/rules/array-type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
AST_NODE_TYPES,
33
AST_TOKEN_TYPES,
44
TSESTree,
5-
} from '@typescript-eslint/typescript-estree';
5+
} from '@typescript-eslint/experimental-utils';
66
import * as util from '../util';
77

88
/**

packages/eslint-plugin/src/rules/await-thenable.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as tsutils from 'tsutils';
2-
import * as ts from 'typescript';
2+
import ts from 'typescript';
33

44
import * as util from '../util';
55

@@ -26,9 +26,9 @@ export default util.createRule({
2626

2727
return {
2828
AwaitExpression(node) {
29-
const originalNode = parserServices.esTreeNodeToTSNodeMap.get(
30-
node,
31-
) as ts.AwaitExpression;
29+
const originalNode = parserServices.esTreeNodeToTSNodeMap.get<
30+
ts.AwaitExpression
31+
>(node);
3232
const type = checker.getTypeAtLocation(originalNode.expression);
3333

3434
if (

packages/eslint-plugin/src/rules/ban-types.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
2-
import { ReportFixFunction } from 'ts-eslint';
1+
import {
2+
TSESLint,
3+
TSESTree,
4+
AST_NODE_TYPES,
5+
} from '@typescript-eslint/experimental-utils';
36
import * as util from '../util';
47

58
type Options = [
@@ -94,7 +97,7 @@ export default util.createRule<Options, MessageIds>({
9497
let customMessage = '';
9598
const bannedCfgValue = bannedTypes[node.name];
9699

97-
let fix: ReportFixFunction | null = null;
100+
let fix: TSESLint.ReportFixFunction | null = null;
98101

99102
if (typeof bannedCfgValue === 'string') {
100103
customMessage += ` ${bannedCfgValue}`;

packages/eslint-plugin/src/rules/camelcase.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import baseRule from 'eslint/lib/rules/camelcase';
36
import * as util from '../util';
47

packages/eslint-plugin/src/rules/class-name-casing.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
15
import * as util from '../util';
2-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
36

47
export default util.createRule({
58
name: 'class-name-casing',

packages/eslint-plugin/src/rules/explicit-function-return-type.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [
58
{
69
allowExpressions?: boolean;
710
allowTypedFunctionExpressions?: boolean;
8-
allowUntypedSetters?: boolean;
911
}
1012
];
1113
type MessageIds = 'missingReturnType';
@@ -42,7 +44,6 @@ export default util.createRule<Options, MessageIds>({
4244
{
4345
allowExpressions: false,
4446
allowTypedFunctionExpressions: false,
45-
allowUntypedSetters: true,
4647
},
4748
],
4849
create(context, [options]) {

packages/eslint-plugin/src/rules/explicit-member-accessibility.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
AST_NODE_TYPES,
3+
TSESTree,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type AccessibilityLevel =

packages/eslint-plugin/src/rules/func-call-spacing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TSESTree } from '@typescript-eslint/typescript-estree';
1+
import { TSESTree } from '@typescript-eslint/experimental-utils';
22
import { isOpeningParenToken } from 'eslint-utils';
33
import * as util from '../util';
44

packages/eslint-plugin/src/rules/indent-new-do-not-use/BinarySearchTree.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// The following code is adapted from the the code in eslint.
22
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
33

4-
import { TSESTree } from '@typescript-eslint/typescript-estree';
5-
import createTree = require('functional-red-black-tree');
4+
import { TSESTree } from '@typescript-eslint/experimental-utils';
5+
import createTree from 'functional-red-black-tree';
66

77
export type TokenOrComment = TSESTree.Token | TSESTree.Comment;
88
export interface TreeValue {

packages/eslint-plugin/src/rules/indent-new-do-not-use/OffsetStorage.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// The following code is adapted from the the code in eslint.
22
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
33

4-
import { TokenInfo } from './TokenInfo';
4+
import { TSESTree } from '@typescript-eslint/experimental-utils';
55
import { BinarySearchTree, TokenOrComment } from './BinarySearchTree';
6-
import { TSESTree } from '@typescript-eslint/typescript-estree';
6+
import { TokenInfo } from './TokenInfo';
77

88
/**
99
* A class to store information on desired offsets of tokens from each other

packages/eslint-plugin/src/rules/indent-new-do-not-use/TokenInfo.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// The following code is adapted from the the code in eslint.
22
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
33

4-
import { TSESTree } from '@typescript-eslint/typescript-estree';
5-
import { SourceCode } from 'ts-eslint';
4+
import { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';
65
import { TokenOrComment } from './BinarySearchTree';
76

87
/**
98
* A helper class to get token-based info related to indentation
109
*/
1110
export class TokenInfo {
12-
private sourceCode: SourceCode;
11+
private sourceCode: TSESLint.SourceCode;
1312
public firstTokensByLineNumber: Map<number, TSESTree.Token>;
1413

15-
constructor(sourceCode: SourceCode) {
14+
constructor(sourceCode: TSESLint.SourceCode) {
1615
this.sourceCode = sourceCode;
1716
this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce(
1817
(map, token) => {

packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
AST_NODE_TYPES,
77
TSESTree,
88
AST_TOKEN_TYPES,
9-
} from '@typescript-eslint/typescript-estree';
9+
TSESLint,
10+
} from '@typescript-eslint/experimental-utils';
1011
import { createGlobalLinebreakMatcher } from 'eslint/lib/util/ast-utils';
1112
import {
1213
isOpeningParenToken,
@@ -20,7 +21,6 @@ import {
2021
isColonToken,
2122
isCommentToken,
2223
} from 'eslint-utils';
23-
import { RuleListener, RuleFunction } from 'ts-eslint';
2424
import { TokenOrComment } from './BinarySearchTree';
2525
import { OffsetStorage } from './OffsetStorage';
2626
import { TokenInfo } from './TokenInfo';
@@ -848,7 +848,7 @@ export default createRule<Options, MessageIds>({
848848

849849
const ignoredNodeFirstTokens = new Set();
850850

851-
const baseOffsetListeners: RuleListener = {
851+
const baseOffsetListeners: TSESLint.RuleListener = {
852852
'ArrayExpression, ArrayPattern'(
853853
node: TSESTree.ArrayExpression | TSESTree.ArrayPattern,
854854
) {
@@ -1547,7 +1547,7 @@ export default createRule<Options, MessageIds>({
15471547
};
15481548

15491549
const listenerCallQueue: {
1550-
listener: RuleFunction<TSESTree.Node>;
1550+
listener: TSESLint.RuleFunction<TSESTree.Node>;
15511551
node: TSESTree.Node;
15521552
}[] = [];
15531553

@@ -1558,7 +1558,7 @@ export default createRule<Options, MessageIds>({
15581558
* 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
15591559
*/
15601560
const offsetListeners = Object.keys(baseOffsetListeners).reduce<
1561-
RuleListener
1561+
TSESLint.RuleListener
15621562
>(
15631563
/*
15641564
* Offset listener calls are deferred until traversal is finished, and are called as
@@ -1577,7 +1577,7 @@ export default createRule<Options, MessageIds>({
15771577
* ignored nodes are known.
15781578
*/
15791579
(acc, key) => {
1580-
const listener = baseOffsetListeners[key] as RuleFunction<
1580+
const listener = baseOffsetListeners[key] as TSESLint.RuleFunction<
15811581
TSESTree.Node
15821582
>;
15831583
acc[key] = node => listenerCallQueue.push({ listener, node });

packages/eslint-plugin/src/rules/indent.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* This is done intentionally based on the internal implementation of the base indent rule.
55
*/
66

7-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
7+
import {
8+
TSESTree,
9+
AST_NODE_TYPES,
10+
} from '@typescript-eslint/experimental-utils';
811
import baseRule from 'eslint/lib/rules/indent';
912
import * as util from '../util';
1013

packages/eslint-plugin/src/rules/member-delimiter-style.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Delimiter = 'comma' | 'none' | 'semi';

packages/eslint-plugin/src/rules/member-naming.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TSESTree } from '@typescript-eslint/typescript-estree';
1+
import { TSESTree } from '@typescript-eslint/experimental-utils';
22
import * as util from '../util';
33

44
interface Config<T = string> {

packages/eslint-plugin/src/rules/member-ordering.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type MessageIds = 'incorrectOrder';

packages/eslint-plugin/src/rules/no-array-constructor.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
export default util.createRule({

packages/eslint-plugin/src/rules/no-extra-parens.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
2-
import { RuleListener } from 'ts-eslint';
1+
import {
2+
AST_NODE_TYPES,
3+
TSESTree,
4+
TSESLint,
5+
} from '@typescript-eslint/experimental-utils';
36
import baseRule from 'eslint/lib/rules/no-extra-parens';
47
import * as util from '../util';
58

@@ -85,7 +88,7 @@ export default util.createRule<Options, MessageIds>({
8588
return rule(node);
8689
}
8790

88-
const overrides: RuleListener = {
91+
const overrides: TSESLint.RuleListener = {
8992
// ArrayExpression
9093
ArrowFunctionExpression(node) {
9194
if (node.body.type !== AST_NODE_TYPES.TSAsExpression) {

packages/eslint-plugin/src/rules/no-extraneous-class.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [

packages/eslint-plugin/src/rules/no-inferrable-types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [

packages/eslint-plugin/src/rules/no-magic-numbers.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* @author Scott O'Hara
44
*/
55

6-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
6+
import {
7+
TSESTree,
8+
AST_NODE_TYPES,
9+
} from '@typescript-eslint/experimental-utils';
710
import baseRule from 'eslint/lib/rules/no-magic-numbers';
811
import * as util from '../util';
912
import { JSONSchema4 } from 'json-schema';

packages/eslint-plugin/src/rules/no-misused-new.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
export default util.createRule({

packages/eslint-plugin/src/rules/no-namespace.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
1+
import {
2+
AST_NODE_TYPES,
3+
TSESTree,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [

packages/eslint-plugin/src/rules/no-object-literal-type-assertion.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
1+
import {
2+
AST_NODE_TYPES,
3+
TSESTree,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [

packages/eslint-plugin/src/rules/no-parameter-properties.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
1+
import {
2+
TSESTree,
3+
AST_NODE_TYPES,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Modifier =

packages/eslint-plugin/src/rules/no-require-imports.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TSESTree } from '@typescript-eslint/typescript-estree';
1+
import { TSESTree } from '@typescript-eslint/experimental-utils';
22
import * as util from '../util';
33

44
export default util.createRule({

packages/eslint-plugin/src/rules/no-this-alias.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
1+
import {
2+
AST_NODE_TYPES,
3+
TSESTree,
4+
} from '@typescript-eslint/experimental-utils';
25
import * as util from '../util';
36

47
type Options = [

0 commit comments

Comments
 (0)