Skip to content

Commit

Permalink
Merge branch 'master' into no-misused-promises
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Jul 16, 2019
2 parents 68cda9b + ceb2d32 commit 5bc9531
Show file tree
Hide file tree
Showing 39 changed files with 2,456 additions and 62 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)


### Bug Fixes

* **eslint-plugin:** handle `const;` ([#633](https://github.com/typescript-eslint/typescript-eslint/issues/633)) ([430d628](https://github.com/typescript-eslint/typescript-eslint/commit/430d628)), closes [#441](https://github.com/typescript-eslint/typescript-eslint/issues/441)
* **typescript-estree:** fix `async` identifier token typed as `Keyword` ([#681](https://github.com/typescript-eslint/typescript-eslint/issues/681)) ([6de19d3](https://github.com/typescript-eslint/typescript-eslint/commit/6de19d3))


### Features

* **eslint-plugin:** [ban-types] Support namespaced type ([#616](https://github.com/typescript-eslint/typescript-eslint/issues/616)) ([e325b72](https://github.com/typescript-eslint/typescript-eslint/commit/e325b72))
* **eslint-plugin:** [explicit-function-return-type] add handling for usage as arguments ([#680](https://github.com/typescript-eslint/typescript-eslint/issues/680)) ([e0aeb18](https://github.com/typescript-eslint/typescript-eslint/commit/e0aeb18))
* **eslint-plugin:** [no-explicit-any] Add an optional fixer ([#609](https://github.com/typescript-eslint/typescript-eslint/issues/609)) ([606fc70](https://github.com/typescript-eslint/typescript-eslint/commit/606fc70))
* **eslint-plugin:** Add rule no-reference-import ([#625](https://github.com/typescript-eslint/typescript-eslint/issues/625)) ([af70a59](https://github.com/typescript-eslint/typescript-eslint/commit/af70a59))
* **eslint-plugin:** add rule strict-boolean-expressions ([#579](https://github.com/typescript-eslint/typescript-eslint/issues/579)) ([34e7d1e](https://github.com/typescript-eslint/typescript-eslint/commit/34e7d1e))
* **eslint-plugin:** added new rule prefer-readonly ([#555](https://github.com/typescript-eslint/typescript-eslint/issues/555)) ([76b89a5](https://github.com/typescript-eslint/typescript-eslint/commit/76b89a5))





# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -139,7 +139,7 @@ Babel does now support parsing (but not type-checking) TypeScript source code. T

The key trade-off can be summarized as: `babel-eslint` supports additional syntax which TypeScript itself does not, but `typescript-eslint` supports creating rules based on type information, which is not available to babel because there is no type-checker.

Because they are therefore separate projects powered by different underlying tooling, they are currently not intended to be used together.
Because they are separate projects powered by different underlying tooling, they are currently not intended to be used together.

Some of the people involved in `typescript-eslint` are also involved in Babel and `babel-eslint`, and in this project we are working hard to align on the AST format for non-standard JavaScript syntax. This is an ongoing effort.

Expand Down
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Expand Up @@ -32,9 +32,13 @@ jobs:
displayName: 'Run linting'
- script: |
yarn docs:check
yarn check:docs
displayName: 'Validate documentation'
- script: |
yarn check:configs
displayName: 'Validate plugin configs'
- script: |
yarn test
displayName: 'Run unit tests'
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"version": "1.11.0",
"version": "1.12.0",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -20,7 +20,8 @@
"build": "lerna run build",
"clean": "lerna clean && lerna run clean",
"cz": "git-cz",
"docs:check": "lerna run docs:check",
"check:docs": "lerna run check:docs",
"check:configs": "lerna run check:configs",
"generate-contributors": "yarn ts-node ./tools/generate-contributors.ts && yarn all-contributors generate",
"format": "prettier --write \"./**/*.{ts,js,json,md}\"",
"format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"",
Expand Down
11 changes: 11 additions & 0 deletions packages/eslint-plugin-tslint/CHANGELOG.md
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)


### Features

* **eslint-plugin:** added new rule prefer-readonly ([#555](https://github.com/typescript-eslint/typescript-eslint/issues/555)) ([76b89a5](https://github.com/typescript-eslint/typescript-eslint/commit/76b89a5))





# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
Expand Down
7 changes: 3 additions & 4 deletions packages/eslint-plugin-tslint/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-tslint",
"version": "1.11.0",
"version": "1.12.0",
"main": "dist/index.js",
"typings": "src/index.ts",
"description": "TSLint wrapper plugin for ESLint",
Expand Down Expand Up @@ -31,16 +31,15 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/experimental-utils": "1.11.0",
"@typescript-eslint/experimental-utils": "1.12.0",
"lodash.memoize": "^4.1.2"
},
"peerDependencies": {
"eslint": "^5.0.0",
"tslint": "^5.0.0"
},
"devDependencies": {
"@types/json-schema": "^7.0.3",
"@types/lodash.memoize": "^4.1.4",
"@typescript-eslint/parser": "1.11.0"
"@typescript-eslint/parser": "1.12.0"
}
}
21 changes: 21 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Expand Up @@ -3,6 +3,27 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)


### Bug Fixes

* **eslint-plugin:** handle `const;` ([#633](https://github.com/typescript-eslint/typescript-eslint/issues/633)) ([430d628](https://github.com/typescript-eslint/typescript-eslint/commit/430d628)), closes [#441](https://github.com/typescript-eslint/typescript-eslint/issues/441)


### Features

* **eslint-plugin:** [ban-types] Support namespaced type ([#616](https://github.com/typescript-eslint/typescript-eslint/issues/616)) ([e325b72](https://github.com/typescript-eslint/typescript-eslint/commit/e325b72))
* **eslint-plugin:** [explicit-function-return-type] add handling for usage as arguments ([#680](https://github.com/typescript-eslint/typescript-eslint/issues/680)) ([e0aeb18](https://github.com/typescript-eslint/typescript-eslint/commit/e0aeb18))
* **eslint-plugin:** [no-explicit-any] Add an optional fixer ([#609](https://github.com/typescript-eslint/typescript-eslint/issues/609)) ([606fc70](https://github.com/typescript-eslint/typescript-eslint/commit/606fc70))
* **eslint-plugin:** Add rule no-reference-import ([#625](https://github.com/typescript-eslint/typescript-eslint/issues/625)) ([af70a59](https://github.com/typescript-eslint/typescript-eslint/commit/af70a59))
* **eslint-plugin:** add rule strict-boolean-expressions ([#579](https://github.com/typescript-eslint/typescript-eslint/issues/579)) ([34e7d1e](https://github.com/typescript-eslint/typescript-eslint/commit/34e7d1e))
* **eslint-plugin:** added new rule prefer-readonly ([#555](https://github.com/typescript-eslint/typescript-eslint/issues/555)) ([76b89a5](https://github.com/typescript-eslint/typescript-eslint/commit/76b89a5))





# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)


Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/README.md
Expand Up @@ -116,7 +116,6 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e

## Supported Rules

<!-- Please run `npm run docs` to update this section -->
<!-- begin rule list -->

**Key**: :heavy_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
Expand All @@ -131,7 +130,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | |
| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names | :heavy_check_mark: | | |
| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | |
| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | |
| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | :heavy_check_mark: | | |
| [`@typescript-eslint/func-call-spacing`](./docs/rules/func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | |
Expand Down
Expand Up @@ -138,6 +138,9 @@ let objectPropAs = {
let objectPropCast = <ObjectType>{
foo: () => 1,
};

declare functionWithArg(arg: () => number);
functionWithArg(() => 1);
```

### allowHigherOrderFunctions
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "1.11.0",
"version": "1.12.0",
"description": "TypeScript plugin for ESLint",
"keywords": [
"eslint",
Expand Down Expand Up @@ -30,24 +30,24 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"check:docs": "ts-node --files ./tools/validate-docs/index.ts",
"check:configs": "ts-node --files ./tools/validate-configs/index.ts",
"clean": "rimraf dist/",
"docs": "eslint-docs",
"docs:check": "ts-node --files ./tools/validate-docs/index.ts",
"format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore",
"generate:configs": "ts-node --files tools/generate-configs.ts",
"prebuild": "npm run clean",
"recommended:update": "ts-node tools/update-recommended.ts",
"test": "jest --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/experimental-utils": "1.11.0",
"@typescript-eslint/experimental-utils": "1.12.0",
"eslint-utils": "^1.3.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^2.0.1",
"tsutils": "^3.7.0"
},
"devDependencies": {
"@types/json-schema": "^7.0.3",
"@types/marked": "^0.6.5",
"chalk": "^2.4.2",
"marked": "^0.6.2"
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/configs/all.json
Expand Up @@ -64,6 +64,7 @@
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
Expand Down
Expand Up @@ -9,7 +9,7 @@ export default util.createRule({
description:
'Consistent with type definition either `interface` or `type`',
category: 'Stylistic Issues',
recommended: 'error',
recommended: false,
},
messages: {
interfaceOverType: 'Use an `interface` instead of a `type`',
Expand Down
Expand Up @@ -187,6 +187,21 @@ export default util.createRule<Options, MessageIds>({
);
}

/**
* Checks if a node belongs to:
* `foo(() => 1)`
*/
function isFunctionArgument(
parent: TSESTree.Node,
child: TSESTree.Node,
): boolean {
return (
parent.type === AST_NODE_TYPES.CallExpression &&
// make sure this isn't an IIFE
parent.callee !== child
);
}

/**
* Checks if a function declaration/expression has a return type.
*/
Expand Down Expand Up @@ -232,7 +247,8 @@ export default util.createRule<Options, MessageIds>({
isTypeCast(node.parent) ||
isVariableDeclaratorWithTypeAnnotation(node.parent) ||
isClassPropertyWithTypeAnnotation(node.parent) ||
isPropertyOfObjectWithType(node.parent)
isPropertyOfObjectWithType(node.parent) ||
isFunctionArgument(node.parent, node)
) {
return;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/prefer-readonly.ts
Expand Up @@ -2,7 +2,10 @@ import * as tsutils from 'tsutils';
import ts from 'typescript';
import * as util from '../util';
import { typeIsOrHasBaseType } from '../util';
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import {
TSESTree,
AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';

type MessageIds = 'preferReadonly';

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/prefer-regexp-exec.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/typescript-estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import { createRule, getParserServices, getTypeName } from '../util';
import { getStaticValue } from 'eslint-utils';

Expand Down
17 changes: 6 additions & 11 deletions packages/eslint-plugin/src/rules/triple-slash-reference.ts
@@ -1,10 +1,5 @@
import * as util from '../util';
import {
Literal,
Node,
TSExternalModuleReference,
} from '@typescript-eslint/typescript-estree/dist/ts-estree/ts-estree';
import { TSESTree } from '@typescript-eslint/typescript-estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';

type Options = [
{
Expand Down Expand Up @@ -55,14 +50,14 @@ export default util.createRule<Options, MessageIds>({
},
],
create(context, [{ lib, path, types }]) {
let programNode: Node;
let programNode: TSESTree.Node;
const sourceCode = context.getSourceCode();
const references: ({
comment: TSESTree.Comment;
importName: string;
})[] = [];

function hasMatchingReference(source: Literal) {
function hasMatchingReference(source: TSESTree.Literal) {
references.forEach(reference => {
if (reference.importName === source.value) {
context.report({
Expand All @@ -78,14 +73,14 @@ export default util.createRule<Options, MessageIds>({
return {
ImportDeclaration(node) {
if (programNode) {
const source = node.source as Literal;
const source = node.source as TSESTree.Literal;
hasMatchingReference(source);
}
},
TSImportEqualsDeclaration(node) {
if (programNode) {
const source = (node.moduleReference as TSExternalModuleReference)
.expression as Literal;
const source = (node.moduleReference as TSESTree.TSExternalModuleReference)
.expression as TSESTree.Literal;
hasMatchingReference(source);
}
},
Expand Down

0 comments on commit 5bc9531

Please sign in to comment.