Navigation Menu

Skip to content

Commit

Permalink
feat: Move shared types into their own package (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed May 10, 2019
1 parent 6eb97d4 commit a7a03ce
Show file tree
Hide file tree
Showing 130 changed files with 1,729 additions and 1,313 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -5,5 +5,4 @@ fixtures
shared-fixtures
coverage

packages/typescript-estree/src/estree
packages/eslint-plugin-tslint/tests
1 change: 1 addition & 0 deletions .eslintrc.json
Expand Up @@ -12,6 +12,7 @@
"no-dupe-class-members": "off",
"no-mixed-operators": "error",
"no-console": "off",
"no-dupe-class-members": "off",
"no-undef": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@typescript-eslint/parser": "1.7.0",
"@typescript-eslint/typescript-estree": "1.7.0",
"@typescript-eslint/experimental-utils": "1.7.0",
"eslint-utils": "^1.3.1",
"regexpp": "^2.0.1",
"requireindex": "^1.2.0",
Expand Down
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type RuleNode =
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/array-type.ts
Expand Up @@ -2,7 +2,7 @@ import {
AST_NODE_TYPES,
AST_TOKEN_TYPES,
TSESTree,
} from '@typescript-eslint/typescript-estree';
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin/src/rules/await-thenable.ts
@@ -1,5 +1,5 @@
import * as tsutils from 'tsutils';
import * as ts from 'typescript';
import ts from 'typescript';

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

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

return {
AwaitExpression(node) {
const originalNode = parserServices.esTreeNodeToTSNodeMap.get(
node,
) as ts.AwaitExpression;
const originalNode = parserServices.esTreeNodeToTSNodeMap.get<
ts.AwaitExpression
>(node);
const type = checker.getTypeAtLocation(originalNode.expression);

if (
Expand Down
9 changes: 6 additions & 3 deletions packages/eslint-plugin/src/rules/ban-types.ts
@@ -1,5 +1,8 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import { ReportFixFunction } from 'ts-eslint';
import {
TSESLint,
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

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

let fix: ReportFixFunction | null = null;
let fix: TSESLint.ReportFixFunction | null = null;

if (typeof bannedCfgValue === 'string') {
customMessage += ` ${bannedCfgValue}`;
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/camelcase.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/camelcase';
import * as util from '../util';

Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/class-name-casing.ts
@@ -1,5 +1,8 @@
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';

export default util.createRule({
name: 'class-name-casing',
Expand Down
@@ -1,11 +1,13 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
{
allowExpressions?: boolean;
allowTypedFunctionExpressions?: boolean;
allowUntypedSetters?: boolean;
}
];
type MessageIds = 'missingReturnType';
Expand Down Expand Up @@ -42,7 +44,6 @@ export default util.createRule<Options, MessageIds>({
{
allowExpressions: false,
allowTypedFunctionExpressions: false,
allowUntypedSetters: true,
},
],
create(context, [options]) {
Expand Down
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type AccessibilityLevel =
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/func-call-spacing.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/typescript-estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import { isOpeningParenToken } from 'eslint-utils';
import * as util from '../util';

Expand Down
@@ -1,8 +1,8 @@
// The following code is adapted from the the code in eslint.
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE

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

export type TokenOrComment = TSESTree.Token | TSESTree.Comment;
export interface TreeValue {
Expand Down
@@ -1,9 +1,9 @@
// The following code is adapted from the the code in eslint.
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE

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

/**
* A class to store information on desired offsets of tokens from each other
Expand Down
@@ -1,18 +1,17 @@
// The following code is adapted from the the code in eslint.
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE

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

/**
* A helper class to get token-based info related to indentation
*/
export class TokenInfo {
private sourceCode: SourceCode;
private sourceCode: TSESLint.SourceCode;
public firstTokensByLineNumber: Map<number, TSESTree.Token>;

constructor(sourceCode: SourceCode) {
constructor(sourceCode: TSESLint.SourceCode) {
this.sourceCode = sourceCode;
this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce(
(map, token) => {
Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts
Expand Up @@ -6,7 +6,8 @@ import {
AST_NODE_TYPES,
TSESTree,
AST_TOKEN_TYPES,
} from '@typescript-eslint/typescript-estree';
TSESLint,
} from '@typescript-eslint/experimental-utils';
import { createGlobalLinebreakMatcher } from 'eslint/lib/util/ast-utils';
import {
isOpeningParenToken,
Expand All @@ -20,7 +21,6 @@ import {
isColonToken,
isCommentToken,
} from 'eslint-utils';
import { RuleListener, RuleFunction } from 'ts-eslint';
import { TokenOrComment } from './BinarySearchTree';
import { OffsetStorage } from './OffsetStorage';
import { TokenInfo } from './TokenInfo';
Expand Down Expand Up @@ -848,7 +848,7 @@ export default createRule<Options, MessageIds>({

const ignoredNodeFirstTokens = new Set();

const baseOffsetListeners: RuleListener = {
const baseOffsetListeners: TSESLint.RuleListener = {
'ArrayExpression, ArrayPattern'(
node: TSESTree.ArrayExpression | TSESTree.ArrayPattern,
) {
Expand Down Expand Up @@ -1547,7 +1547,7 @@ export default createRule<Options, MessageIds>({
};

const listenerCallQueue: {
listener: RuleFunction<TSESTree.Node>;
listener: TSESLint.RuleFunction<TSESTree.Node>;
node: TSESTree.Node;
}[] = [];

Expand All @@ -1558,7 +1558,7 @@ export default createRule<Options, MessageIds>({
* 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
*/
const offsetListeners = Object.keys(baseOffsetListeners).reduce<
RuleListener
TSESLint.RuleListener
>(
/*
* Offset listener calls are deferred until traversal is finished, and are called as
Expand All @@ -1577,7 +1577,7 @@ export default createRule<Options, MessageIds>({
* ignored nodes are known.
*/
(acc, key) => {
const listener = baseOffsetListeners[key] as RuleFunction<
const listener = baseOffsetListeners[key] as TSESLint.RuleFunction<
TSESTree.Node
>;
acc[key] = node => listenerCallQueue.push({ listener, node });
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/indent.ts
Expand Up @@ -4,7 +4,10 @@
* This is done intentionally based on the internal implementation of the base indent rule.
*/

import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/indent';
import * as util from '../util';

Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/member-delimiter-style.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Delimiter = 'comma' | 'none' | 'semi';
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/member-naming.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/typescript-estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import * as util from '../util';

interface Config<T = string> {
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/member-ordering.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type MessageIds = 'incorrectOrder';
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-array-constructor.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

export default util.createRule({
Expand Down
9 changes: 6 additions & 3 deletions packages/eslint-plugin/src/rules/no-extra-parens.ts
@@ -1,5 +1,8 @@
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
import { RuleListener } from 'ts-eslint';
import {
AST_NODE_TYPES,
TSESTree,
TSESLint,
} from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/no-extra-parens';
import * as util from '../util';

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

const overrides: RuleListener = {
const overrides: TSESLint.RuleListener = {
// ArrayExpression
ArrowFunctionExpression(node) {
if (node.body.type !== AST_NODE_TYPES.TSAsExpression) {
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-extraneous-class.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-inferrable-types.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-magic-numbers.ts
Expand Up @@ -3,7 +3,10 @@
* @author Scott O'Hara
*/

import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/no-magic-numbers';
import * as util from '../util';
import { JSONSchema4 } from 'json-schema';
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-misused-new.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

export default util.createRule({
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-namespace.ts
@@ -1,4 +1,7 @@
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
Expand Down
@@ -1,4 +1,7 @@
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-parameter-properties.ts
@@ -1,4 +1,7 @@
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Modifier =
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-require-imports.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/typescript-estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import * as util from '../util';

export default util.createRule({
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-this-alias.ts
@@ -1,4 +1,7 @@
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree';
import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import * as util from '../util';

type Options = [
Expand Down

0 comments on commit a7a03ce

Please sign in to comment.