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

feat(*): change TypeScript version range to >=3.2.1 <3.6.0 #597

Merged
merged 1 commit into from Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
}
}
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/semi.ts
Expand Up @@ -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;
}, {});

Expand Down
10 changes: 3 additions & 7 deletions packages/eslint-plugin/tests/configs/all.test.ts
@@ -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;
Expand Down
Expand Up @@ -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')),
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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();
Expand Down
10 changes: 2 additions & 8 deletions packages/experimental-utils/src/eslint-utils/RuleCreator.ts
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions packages/experimental-utils/src/eslint-utils/deepMerge.ts
@@ -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
Expand All @@ -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;
Expand All @@ -44,6 +41,6 @@ export function deepMerge<T extends ObjectLike = ObjectLike>(

return acc;
},
{} as T,
{} as ObjectLike,
);
}
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/parser.ts
Expand Up @@ -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,
Expand Down
Expand Up @@ -34,7 +34,7 @@ Object {
},
"isDeclarationFile": false,
"languageVariant": 1,
"languageVersion": 7,
"languageVersion": 8,
"libReferenceDirectives": Array [],
"lineMap": Array [
null,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -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"
Expand Down