Skip to content
Permalink
Browse files

feat(*): support TypeScript versions >=3.2.1 <3.6.0 (#597)

  • Loading branch information...
piecyk authored and bradzacher committed Jun 7, 2019
1 parent c03b6ed commit 5d2b9626d86ca0ef14c2a45c233f096f356bccbd
@@ -203,7 +203,7 @@ The `canary` (latest master) version is:

We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.

**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.5.0`.**
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.6.0`.**

This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.

@@ -78,6 +78,6 @@
"ts-jest": "^24.0.0",
"ts-node": "^8.0.1",
"tslint": "^5.11.0",
"typescript": ">=3.2.1 <3.5.0"
"typescript": ">=3.2.1 <3.6.0"
}
}
@@ -1588,7 +1588,7 @@ export default createRule<Options, MessageIds>({
);

// For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
const ignoredNodes = new Set();
const ignoredNodes = new Set<TSESTree.Node>();

/**
* Ignores a node
@@ -52,7 +52,7 @@ export default util.createRule<Options, MessageIds>({
AST_NODE_TYPES.TSImportEqualsDeclaration,
AST_NODE_TYPES.TSTypeAliasDeclaration,
].reduce<TSESLint.RuleListener>((acc, node) => {
acc[node] = checkForSemicolon;
acc[node as string] = checkForSemicolon;
return acc;
}, {});

@@ -1,21 +1,17 @@
import rules from '../../src/rules';
import allConfig from '../../src/configs/all.json';
import { TSESLint } from '@typescript-eslint/experimental-utils';

interface IndexRules {
[name: string]: TSESLint.RuleModule<string, any, any>;
}
interface JsonRules {
[name: string]: string;
}

describe('all.json config', () => {
const RULE_NAME_PREFIX = '@typescript-eslint/';

const typedRules: IndexRules = rules;
const notDeprecatedRuleNames = Object.keys(typedRules).reduce<string[]>(
const rulesNames = Object.keys(rules) as (keyof typeof rules)[];
const notDeprecatedRuleNames = rulesNames.reduce<string[]>(
(collection, name) => {
if (!typedRules[name].meta.deprecated) {
if (!rules[name].meta.deprecated) {
collection.push(`${RULE_NAME_PREFIX}${name}`);
}
return collection;
@@ -3,8 +3,8 @@ import fs from 'fs';
import path from 'path';
import { logRule } from './log';

function checkForRuleDocs(
rules: Record<string, TSESLint.RuleModule<any, any>>,
function checkForRuleDocs<TMessageIds extends string>(
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
): boolean {
const ruleDocs = new Set(
fs.readdirSync(path.resolve(__dirname, '../../docs/rules')),
@@ -5,8 +5,8 @@ import marked from 'marked';
import path from 'path';
import { logRule } from './log';

function validateTableRules(
rules: Record<string, TSESLint.RuleModule<any, any>>,
function validateTableRules<TMessageIds extends string>(
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
rulesTable: marked.Tokens.Table,
): boolean {
let hasErrors = false;
@@ -3,8 +3,8 @@ import chalk from 'chalk';
import marked from 'marked';
import { logError } from './log';

function validateTableStructure(
rules: Record<string, TSESLint.RuleModule<any, any>>,
function validateTableStructure<TMessageIds extends string>(
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
rulesTable: marked.Tokens.Table,
): boolean {
const ruleNames = Object.keys(rules).sort();
@@ -7,17 +7,11 @@ import {
} from '../ts-eslint/Rule';
import { applyDefault } from './applyDefault';

// Utility type to remove a list of properties from an object
type RemoveProps<
TObj extends Record<string, any>,
TKeys extends keyof TObj
> = Pick<TObj, Exclude<keyof TObj, TKeys>>;

// we'll automatically add the url + tslint description for people.
type CreateRuleMetaDocs = RemoveProps<RuleMetaDataDocs, 'url'>;
type CreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;
type CreateRuleMeta<TMessageIds extends string> = {
docs: CreateRuleMetaDocs;
} & RemoveProps<RuleMetaData<TMessageIds>, 'docs'>;
} & Omit<RuleMetaData<TMessageIds>, 'docs'>;

export function RuleCreator(urlCreator: (ruleName: string) => string) {
// This function will get much easier to call when this is merged https://github.com/Microsoft/TypeScript/pull/26349
@@ -1,4 +1,4 @@
export type ObjectLike<T = any> = Record<string, T>;
type ObjectLike<T = any> = Record<string, T>;

/**
* Check if the variable contains an object stricly rejecting arrays
@@ -16,14 +16,11 @@ export function isObjectNotArray<T extends object>(obj: T | any[]): obj is T {
* @param second The second object
* @returns a new object
*/
export function deepMerge<T extends ObjectLike = ObjectLike>(
first: ObjectLike = {},
second: ObjectLike = {},
): T {
export function deepMerge(first: ObjectLike = {}, second: ObjectLike = {}) {
// get the unique set of keys across both objects
const keys = new Set(Object.keys(first).concat(Object.keys(second)));

return Array.from(keys).reduce<T>(
return Array.from(keys).reduce(
(acc, key) => {
const firstHasKey = key in first;
const secondHasKey = key in second;
@@ -44,6 +41,6 @@ export function deepMerge<T extends ObjectLike = ObjectLike>(

return acc;
},
{} as T,
{} as ObjectLike,
);
}
@@ -15,7 +15,7 @@ import {
* This needs to be kept in sync with the top-level README.md in the
* typescript-eslint monorepo
*/
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.5.0';
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.6.0';
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
const isRunningSupportedTypeScriptVersion = semver.satisfies(
ACTIVE_TYPESCRIPT_VERSION,
@@ -34,7 +34,7 @@ Object {
},
"isDeclarationFile": false,
"languageVariant": 1,
"languageVersion": 7,
"languageVersion": 8,
"libReferenceDirectives": Array [],
"lineMap": Array [
null,
@@ -7155,10 +7155,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

"typescript@>=3.2.1 <3.5.0":
version "3.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==
"typescript@>=3.2.1 <3.6.0":
version "3.5.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202"
integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==

uglify-js@^3.1.4:
version "3.5.10"

0 comments on commit 5d2b962

Please sign in to comment.
You can’t perform that action at this time.