diff --git a/.codecov.yml b/.codecov.yml
index 119f1a50499c..750d876773d3 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -7,3 +7,7 @@ coverage:
default:
target: auto
threshold: 2%
+comment:
+ layout: diff, flags, files
+ require_changes: true
+
diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md
index d78e999d908e..313c1880a1ab 100644
--- a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md
+++ b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md
@@ -6,18 +6,6 @@ labels: 'package: @typescript-eslint/eslint-plugin-tslint, triage'
assignees: ''
---
-**What version of Node.js and npm are you using?**
-
-- Node:
-- npm:
-
-**What version of the following packages are you using?**
-
-- @typescript-eslint/eslint-plugin-tslint:
-- @typescript-eslint/parser:
-- TypeScript:
-- ESLint:
-
**What code were you trying to parse?**
```ts
@@ -27,3 +15,14 @@ assignees: ''
**What did you expect to happen?**
**What actually happened?**
+
+**Versions**
+
+| package | version |
+| ----------------------------------------- | ------- |
+| `@typescript-eslint/eslint-plugin-tslint` | `X.Y.Z` |
+| `@typescript-eslint/parser` | `X.Y.Z` |
+| `TypeScript` | `X.Y.Z` |
+| `ESLint` | `X.Y.Z` |
+| `node` | `X.Y.Z` |
+| `npm` | `X.Y.Z` |
diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md
index b7566c0069ca..ddae219da635 100644
--- a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md
+++ b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md
@@ -42,4 +42,7 @@ Please try to avoid code that isn't directly related to the bug, as it makes it
| ---------------------------------- | ------- |
| `@typescript-eslint/eslint-plugin` | `X.Y.Z` |
| `@typescript-eslint/parser` | `X.Y.Z` |
-| `typescript` | `X.Y.Z` |
+| `TypeScript` | `X.Y.Z` |
+| `ESLint` | `X.Y.Z` |
+| `node` | `X.Y.Z` |
+| `npm` | `X.Y.Z` |
diff --git a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md
index 601087f77e82..f0cfe5a1e158 100644
--- a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md
+++ b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md
@@ -6,17 +6,6 @@ labels: 'package: parser, triage'
assignees: ''
---
-**What version of Node.js and npm are you using?**
-
-- Node:
-- npm:
-
-**What version of the following packages are you using?**
-
-- @typescript-eslint/parser:
-- TypeScript:
-- ESLint:
-
**What code were you trying to parse?**
```ts
@@ -26,3 +15,13 @@ assignees: ''
**What did you expect to happen?**
**What actually happened?**
+
+**Versions**
+
+| package | version |
+| --------------------------- | ------- |
+| `@typescript-eslint/parser` | `X.Y.Z` |
+| `TypeScript` | `X.Y.Z` |
+| `ESLint` | `X.Y.Z` |
+| `node` | `X.Y.Z` |
+| `npm` | `X.Y.Z` |
diff --git a/.github/ISSUE_TEMPLATE/typescript-estree.md b/.github/ISSUE_TEMPLATE/typescript-estree.md
index f6b12ebafe9e..fc8cca3d9a39 100644
--- a/.github/ISSUE_TEMPLATE/typescript-estree.md
+++ b/.github/ISSUE_TEMPLATE/typescript-estree.md
@@ -6,10 +6,6 @@ labels: 'package: typescript-estree, triage'
assignees: ''
---
-**What version of TypeScript are you using?**
-
-**What version of `@typescript-eslint/typescript-estree` are you using?**
-
**What code were you trying to parse?**
```ts
@@ -19,3 +15,12 @@ assignees: ''
**What did you expect to happen?**
**What actually happened?**
+
+**Versions**
+
+| package | version |
+| -------------------------------------- | ------- |
+| `@typescript-eslint/typescript-estree` | `X.Y.Z` |
+| `TypeScript` | `X.Y.Z` |
+| `node` | `X.Y.Z` |
+| `npm` | `X.Y.Z` |
diff --git a/.travis.yml b/.travis.yml
index 10d7a2a909e6..c18b22b64cb0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,28 +11,28 @@ notifications:
node_js:
- '11'
- '10'
- - '9'
- '8'
- '6'
install:
- - yarn --ignore-engines
+ # This also runs a build as part of the postinstall
+ # bootstrap
+ - yarn --ignore-engines --frozen-lockfile
script:
- - commitlint-travis
- - yarn check-format
# TODO: Fix this check
# - yarn workspace eslint-plugin docs:check
- - yarn build
- yarn test
- - yarn integration-tests
- yarn global add codecov
after_success:
- codecov
branches:
only:
- master
-deploy:
- on:
- branch: master
- provider: script
- script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes
- skip_cleanup: true
+
+jobs:
+ include:
+ - stage: Code and Commit Formatting and Integration Tests
+ node_js: "11"
+ script:
+ - commitlint-travis
+ - yarn check-format
+ - yarn integration-tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0706cb69e05..c87104215644 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+### Bug Fixes
+
+- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51))
+- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c))
+- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc))
+
+### Features
+
+- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c))
+- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736))
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/typescript-eslint
diff --git a/README.md b/README.md
index 47493a417b0e..2d6dda93ecb3 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/lerna.json b/lerna.json
index d51f69375e6d..c416cf72769b 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "version": "0.2.1",
+ "version": "1.0.0",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md
index 241c8cd24624..a95c7b88cb36 100644
--- a/packages/eslint-plugin-tslint/CHANGELOG.md
+++ b/packages/eslint-plugin-tslint/CHANGELOG.md
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md
index 09cc6e4c0b71..7a1cdf297aa4 100644
--- a/packages/eslint-plugin-tslint/README.md
+++ b/packages/eslint-plugin-tslint/README.md
@@ -1,41 +1,49 @@
-# ESLint Plugin TSLint
+ESLint Plugin TSLint
-[](https://travis-ci.org/@typescript-eslint/eslint-plugin-tslint)
-[](https://github.com/@typescript-eslint/eslint-plugin-tslint/blob/master/LICENSE)
-[](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint)
-[](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint)
-[](http://commitizen.github.io/cz-cli/)
+ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint.
-ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint.
+
+
+
+
+
+
+
-## INSTALL
+## Installation
-```
-npm i -D @typescript-eslint/eslint-plugin-tslint
+```sh
+npm i @typescript-eslint/eslint-plugin-tslint --save-dev
```
-## USAGE
+## Usage
Configure in your eslint config file:
-```
-"plugins": [
- "tslint"
-],
-"rules": {
- "tslint/config": ["warn", {
- lintFile: '/* path to tslint.json of your project */',
- rules: { /* tslint rules (will be used if `lintFile` is not specified) */ },
- rulesDirectory: [ /* array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) */ ]
+```js
+{
+ "plugins": [
+ "@typescript-eslint/tslint"
+ ],
+ "rules": {
+ "@typescript-eslint/tslint/config": ["warn", {
+ "lintFile": '', // path to tslint.json of your project
+ "rules": {
+ // tslint rules (will be used if `lintFile` is not specified)
+ },
+ "rulesDirectory": [
+ // array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified)
+ ]
}],
+ }
}
```
-## RULES
+## Rules
-Plugin contains only single rule `tslint/config`.
+Plugin contains only single rule `@typescript-eslint/tslint/config`.
-## EXAMPLES
+## Examples
- [unlight/node-package-starter/.eslintrc.js](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js)
diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json
index e6f13409db21..9c0668115ecc 100644
--- a/packages/eslint-plugin-tslint/package.json
+++ b/packages/eslint-plugin-tslint/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-tslint",
- "version": "0.2.1",
+ "version": "1.0.0",
"main": "dist/index.js",
"typings": "src/index.ts",
"description": "TSLint wrapper plugin for ESLint",
@@ -33,6 +33,6 @@
"devDependencies": {
"@types/eslint": "^4.16.3",
"@types/lodash.memoize": "^4.1.4",
- "@typescript-eslint/parser": "0.2.1"
+ "@typescript-eslint/parser": "1.0.0"
}
}
diff --git a/packages/eslint-plugin-tslint/tests/index.spec.ts b/packages/eslint-plugin-tslint/tests/index.spec.ts
index 1b78c3943f85..8232a16ec21c 100644
--- a/packages/eslint-plugin-tslint/tests/index.spec.ts
+++ b/packages/eslint-plugin-tslint/tests/index.spec.ts
@@ -2,18 +2,19 @@ import { rules } from '../src/index';
import { RuleTester } from 'eslint';
import { readFileSync } from 'fs';
-const ruleTester = new RuleTester();
-
-const parserOptions: any = {
- ecmaVersion: 6,
- sourceType: 'module',
- ecmaFeatures: {},
- /**
- * Project is needed to generate the parserServices
- * within @typescript-eslint/parser
- */
- project: './tests/tsconfig.json'
-};
+const ruleTester = new RuleTester({
+ parserOptions: {
+ ecmaVersion: 6,
+ sourceType: 'module',
+ ecmaFeatures: {},
+ /**
+ * Project is needed to generate the parserServices
+ * within @typescript-eslint/parser
+ */
+ project: './tests/tsconfig.json'
+ },
+ parser: '@typescript-eslint/parser'
+});
/**
* Inline rules should be supported
@@ -40,8 +41,6 @@ ruleTester.run('tslint/config', rules.config, {
valid: [
{
code: 'var foo = true;',
- parser: '@typescript-eslint/parser',
- parserOptions,
options: [tslintRulesConfig]
},
{
@@ -50,9 +49,7 @@ ruleTester.run('tslint/config', rules.config, {
/\n/g,
' '
),
- parser: '@typescript-eslint/parser',
parserOptions: {
- ...parserOptions,
project: `${__dirname}/test-project/tsconfig.json`
},
options: [
@@ -63,8 +60,6 @@ ruleTester.run('tslint/config', rules.config, {
},
{
code: 'throw "should be ok because rule is not loaded";',
- parser: '@typescript-eslint/parser',
- parserOptions,
options: [tslintRulesConfig]
}
],
@@ -72,8 +67,6 @@ ruleTester.run('tslint/config', rules.config, {
invalid: [
{
options: [{ lintFile: './tests/test-project/tslint.json' }],
- parser: '@typescript-eslint/parser',
- parserOptions,
code: 'throw "err" // no-string-throw',
errors: [
{
@@ -84,8 +77,6 @@ ruleTester.run('tslint/config', rules.config, {
},
{
code: 'var foo = true // semicolon',
- parser: '@typescript-eslint/parser',
- parserOptions,
options: [tslintRulesConfig],
output: 'var foo = true // semicolon',
errors: [
@@ -98,8 +89,6 @@ ruleTester.run('tslint/config', rules.config, {
},
{
code: 'var foo = true // fail',
- parser: '@typescript-eslint/parser',
- parserOptions,
options: [tslintRulesDirectoryConfig],
output: 'var foo = true // fail',
errors: [
@@ -116,9 +105,7 @@ ruleTester.run('tslint/config', rules.config, {
/\n/g,
' '
),
- parser: '@typescript-eslint/parser',
parserOptions: {
- ...parserOptions,
project: `${__dirname}/test-project/tsconfig.json`
},
options: [
diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md
index d0f9e7a9b350..188e6b07bec3 100644
--- a/packages/eslint-plugin/CHANGELOG.md
+++ b/packages/eslint-plugin/CHANGELOG.md
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+### Bug Fixes
+
+- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51))
+- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c))
+- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc))
+
+### Features
+
+- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c))
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/eslint-plugin
diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md
index 82e116951b03..b9366b302b31 100644
--- a/packages/eslint-plugin/README.md
+++ b/packages/eslint-plugin/README.md
@@ -1,62 +1,53 @@
-# @typescript-eslint/eslint-plugin
+ESLint Plugin TypeScript
-[](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
-[](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
-[](https://travis-ci.com/@typescript-eslint/eslint-plugin)
+
+
+
+
+
+
+
## Installation
-You'll first need to install [ESLint](http://eslint.org):
+Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin:
-```shellsession
-$ npm i eslint --save-dev
+```sh
+npm i @typescript-eslint/eslint-plugin --save-dev
```
-Next, install `typescript` if you haven’t already:
-
-```shellsession
-$ npm i typescript@~3.1.1 --save-dev
-```
-
-Last, install `@typescript-eslint/eslint-plugin`:
-
-```shellsession
-$ npm install @typescript-eslint/eslint-plugin --save-dev
-```
+It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`.
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally.
## Usage
-Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file:
+Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file:
```json
{
- "parser": "@typescript-eslint/eslint-plugin/parser",
- "plugins": ["typescript"]
+ "parser": "@typescript-eslint/parser",
+ "plugins": ["@typescript-eslint"]
}
```
-Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`.
-This helps us guarantee 100% compatibility between the plugin and the parser.
-
Then configure the rules you want to use under the rules section.
```json
{
- "parser": "@typescript-eslint/eslint-plugin/parser",
- "plugins": ["typescript"],
+ "parser": "@typescript-eslint/parser",
+ "plugins": ["@typescript-eslint"],
"rules": {
- "typescript/rule-name": "error"
+ "@typescript-eslint/rule-name": "error"
}
}
```
-You can also enable all the recommended rules at once. Add `plugin:typescript/recommended` in extends:
+You can also enable all the recommended rules at once. Add `plugin:@typescript-eslint/recommended` in extends:
```json
{
- "extends": ["plugin:typescript/recommended"]
+ "extends": ["plugin:@typescript-eslint/recommended"]
}
```
@@ -70,38 +61,38 @@ You can also enable all the recommended rules at once. Add `plugin:typescript/re
| Name | Description | :heavy_check_mark: | :wrench: |
| ---- | ----------- | ------------------ | -------- |
-| [`typescript/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | |
-| [`typescript/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | |
-| [`typescript/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | |
-| [`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | |
-| [`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | |
-| [`typescript/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | |
-| [`typescript/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | |
-| [`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: |
-| [`typescript/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | |
-| [`typescript/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | |
-| [`typescript/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: |
-| [`typescript/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | |
-| [`typescript/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | |
-| [`typescript/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | |
-| [`typescript/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | |
-| [`typescript/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | |
-| [`typescript/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | |
-| [`typescript/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`typescript/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :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 (`class-name` from TSLint) | :heavy_check_mark: | |
+| [`@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 (`member-access` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | |
+| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | |
+| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | |
+| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | |
+| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | |
+| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | |
+| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | |
+| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | |
+| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
+| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md
index 64eaa018df9f..5ab5e6e96e76 100644
--- a/packages/eslint-plugin/docs/rules/ban-types.md
+++ b/packages/eslint-plugin/docs/rules/ban-types.md
@@ -32,7 +32,7 @@ class Foo extends Bar implements Baz {
```CJSON
{
- "typescript/ban-types": ["error", {
+ "@typescript-eslint/ban-types": ["error", {
"types": {
// report usages of the type using the default error message
"Foo": null,
@@ -54,7 +54,7 @@ class Foo extends Bar implements Baz {
```json
{
- "typescript/ban-types": [
+ "@typescript-eslint/ban-types": [
"error",
{
"types": {
diff --git a/packages/eslint-plugin/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md
index ab624c2f9931..203a3885ed43 100644
--- a/packages/eslint-plugin/docs/rules/camelcase.md
+++ b/packages/eslint-plugin/docs/rules/camelcase.md
@@ -24,7 +24,7 @@ variable that will be imported into the local module scope.
{
// note you must disable the base rule as it can report incorrect errors
"camelcase": "off",
- "typescript/camelcase": ["error", { "properties": "always" }]
+ "@typescript-eslint/camelcase": ["error", { "properties": "always" }]
}
```
@@ -41,7 +41,7 @@ This rule has an object option:
Examples of **incorrect** code for this rule with the default `{ "properties": "always" }` option:
```js
-/*eslint typescript/camelcase: "error"*/
+/*eslint @typescript-eslint/camelcase: "error"*/
import { no_camelcased } from 'external-module';
@@ -81,7 +81,7 @@ var { foo: bar_baz = 1 } = quz;
Examples of **correct** code for this rule with the default `{ "properties": "always" }` option:
```js
-/*eslint typescript/camelcase: "error"*/
+/*eslint @typescript-eslint/camelcase: "error"*/
import { no_camelcased as camelCased } from 'external-module';
@@ -122,7 +122,7 @@ var { foo: isCamelCased = 1 } = quz;
Examples of **correct** code for this rule with the `{ "properties": "never" }` option:
```js
-/*eslint typescript/camelcase: ["error", {properties: "never"}]*/
+/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/
var obj = {
my_pref: 1
@@ -134,7 +134,7 @@ var obj = {
Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option:
```js
-/*eslint typescript/camelcase: "error"*/
+/*eslint @typescript-eslint/camelcase: "error"*/
var { category_id } = query;
@@ -152,7 +152,7 @@ var { category_id: categoryId, ...other_props } = query;
Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option:
```js
-/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/
+/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/
var { category_id: category_alias } = query;
@@ -162,7 +162,7 @@ var { category_id, ...other_props } = query;
Examples of **correct** code for this rule with the `{ "ignoreDestructuring": true }` option:
```js
-/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/
+/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/
var { category_id } = query;
@@ -176,7 +176,7 @@ var { category_id: category_id } = query;
Examples of **correct** code for this rule with the `allow` option:
```js
-/*eslint typescript/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/
+/*eslint @typescript-eslint/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/
function UNSAFE_componentWillMount() {
// ...
@@ -184,7 +184,7 @@ function UNSAFE_componentWillMount() {
```
```js
-/*eslint typescript/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
+/*eslint @typescript-eslint/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
function UNSAFE_componentWillMount() {
// ...
diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md
index 1ef6595a8ad8..5678ba291da2 100644
--- a/packages/eslint-plugin/docs/rules/indent.md
+++ b/packages/eslint-plugin/docs/rules/indent.md
@@ -30,7 +30,7 @@ For example, for 2-space indentation:
{
// note you must disable the base rule as it can report incorrect errors
"indent": "off",
- "typescript/indent": ["error", 2]
+ "@typescript-eslint/indent": ["error", 2]
}
```
@@ -40,7 +40,7 @@ Or for tabbed indentation:
{
// note you must disable the base rule as it can report incorrect errors
"indent": "off",
- "typescript/indent": ["error", "tab"]
+ "@typescript-eslint/indent": ["error", "tab"]
}
```
@@ -48,7 +48,7 @@ Examples of **incorrect** code for this rule with the default options:
```js
-/*eslint typescript/indent: "error"*/
+/*eslint @typescript-eslint/indent: "error"*/
if (a) {
b=c;
@@ -62,7 +62,7 @@ Examples of **correct** code for this rule with the default options:
```js
-/*eslint typescript/indent: "error"*/
+/*eslint @typescript-eslint/indent: "error"*/
if (a) {
b=c;
@@ -116,7 +116,7 @@ Examples of **incorrect** code for this rule with the `"tab"` option:
```js
-/*eslint typescript/indent: ["error", "tab"]*/
+/*eslint @typescript-eslint/indent: ["error", "tab"]*/
if (a) {
b=c;
@@ -130,7 +130,7 @@ Examples of **correct** code for this rule with the `"tab"` option:
```js
-/*eslint typescript/indent: ["error", "tab"]*/
+/*eslint @typescript-eslint/indent: ["error", "tab"]*/
if (a) {
/*tab*/b=c;
@@ -146,7 +146,7 @@ Examples of **incorrect** code for this rule with the `2, { "SwitchCase": 1 }` o
```js
-/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
@@ -160,7 +160,7 @@ Examples of **correct** code for this rule with the `2, { "SwitchCase": 1 }` opt
```js
-/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
@@ -176,7 +176,7 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator"
```js
-/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/
var a,
@@ -194,7 +194,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator":
```js
-/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/
var a,
@@ -212,7 +212,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator":
```js
-/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 2 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 2 }]*/
/*eslint-env es6*/
var a,
@@ -230,7 +230,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator":
```js
-/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
/*eslint-env es6*/
var a,
@@ -250,7 +250,7 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo
```js
-/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/
(function() {
@@ -270,7 +270,7 @@ Examples of **correct** code for this rule with the options `2, {"outerIIFEBody"
```js
-/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/
(function() {
@@ -292,7 +292,7 @@ Examples of **incorrect** code for this rule with the `2, { "MemberExpression":
```js
-/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/
foo
.bar
@@ -303,7 +303,7 @@ Examples of **correct** code for this rule with the `2, { "MemberExpression": 1
```js
-/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/
foo
.bar
@@ -316,7 +316,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration
```js
-/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
function foo(bar,
baz,
@@ -329,7 +329,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration":
```js
-/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
function foo(bar,
baz,
@@ -342,7 +342,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration
```js
-/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
function foo(bar, baz,
qux, boop) {
@@ -354,7 +354,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration":
```js
-/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
function foo(bar, baz,
qux, boop) {
@@ -368,7 +368,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression"
```js
-/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
var foo = function(bar,
baz,
@@ -381,7 +381,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression":
```js
-/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
var foo = function(bar,
baz,
@@ -394,7 +394,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression"
```js
-/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
var foo = function(bar, baz,
qux, boop) {
@@ -406,7 +406,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression":
```js
-/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
var foo = function(bar, baz,
qux, boop) {
@@ -420,7 +420,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {"
```js
-/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
foo(bar,
baz,
@@ -432,7 +432,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar
```js
-/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
foo(bar,
baz,
@@ -444,7 +444,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {"
```js
-/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
foo(bar, baz,
baz, boop, beep);
@@ -454,7 +454,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar
```js
-/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
foo(bar, baz,
baz, boop, beep);
@@ -466,7 +466,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1
```js
-/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/
var foo = [
bar,
@@ -479,7 +479,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": 1 }
```js
-/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/
var foo = [
bar,
@@ -492,7 +492,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": "
```js
-/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/
var foo = [bar,
baz,
@@ -504,7 +504,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": "fi
```js
-/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/
var foo = [bar,
baz,
@@ -518,7 +518,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression":
```js
-/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/
var foo = {
bar: 1,
@@ -531,7 +531,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": 1
```js
-/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/
var foo = {
bar: 1,
@@ -544,7 +544,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression":
```js
-/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/
var foo = { bar: 1,
baz: 2 };
@@ -554,7 +554,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": "f
```js
-/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/
+/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/
var foo = { bar: 1,
baz: 2 };
@@ -566,7 +566,7 @@ Examples of **correct** code for this rule with the `4, { "ImportDeclaration": 1
```js
-/*eslint typescript/indent: ["error", 4, { ImportDeclaration: 1 }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: 1 }]*/
import { foo,
bar,
@@ -584,7 +584,7 @@ Examples of **incorrect** code for this rule with the `4, { ImportDeclaration: "
```js
-/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/
import { foo,
bar,
@@ -596,7 +596,7 @@ Examples of **correct** code for this rule with the `4, { ImportDeclaration: "fi
```js
-/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/
import { foo,
bar,
@@ -610,7 +610,7 @@ Examples of **incorrect** code for this rule with the default `4, { "flatTernary
```js
-/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/
var a =
foo ? bar :
@@ -622,7 +622,7 @@ Examples of **correct** code for this rule with the default `4, { "flatTernaryEx
```js
-/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/
var a =
foo ? bar :
@@ -634,7 +634,7 @@ Examples of **incorrect** code for this rule with the `4, { "flatTernaryExpressi
```js
-/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/
var a =
foo ? bar :
@@ -646,7 +646,7 @@ Examples of **correct** code for this rule with the `4, { "flatTernaryExpression
```js
-/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/
var a =
foo ? bar :
@@ -662,7 +662,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Cond
```js
-/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/
var a = foo
? bar
@@ -679,7 +679,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Call
```js
-/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/
+/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/
(function() {
@@ -695,7 +695,7 @@ Examples of additional **correct** code for this rule with the `4, { "ignoreComm
```js
-/*eslint typescript/indent: ["error", 4, { "ignoreComments": true }] */
+/*eslint @typescript-eslint/indent: ["error", 4, { "ignoreComments": true }] */
if (foo) {
doSomething();
diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md
index ea588fd5ec29..df1aec7ad605 100644
--- a/packages/eslint-plugin/docs/rules/no-misused-new.md
+++ b/packages/eslint-plugin/docs/rules/no-misused-new.md
@@ -32,7 +32,7 @@ interface I {
```json
{
- "typescript/no-misused-new": "error"
+ "@typescript-eslint/no-misused-new": "error"
}
```
diff --git a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md
index c833fe9fbbbd..fe25f8f64107 100644
--- a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md
+++ b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md
@@ -22,7 +22,7 @@ const z = { ... } as unknown;
```json
{
- "typescript/no-object-literal-type-assertion": "error"
+ "@typescript-eslint/no-object-literal-type-assertion": "error"
}
```
diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md
index ea747805e0ee..b40c165b3db7 100644
--- a/packages/eslint-plugin/docs/rules/no-this-alias.md
+++ b/packages/eslint-plugin/docs/rules/no-this-alias.md
@@ -41,7 +41,7 @@ You can pass an object option:
```json5
{
- 'typescript/no-this-alias': [
+ '@typescript-eslint/no-this-alias': [
'error',
{
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md
index 58dcc78f1ee0..63f148f7a3f4 100644
--- a/packages/eslint-plugin/docs/rules/no-unused-vars.md
+++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md
@@ -110,11 +110,15 @@ By default this rule is enabled with `all` option for variables and `after-used`
```CJSON
{
- "rules": {
- // note you must disable the base rule as it can report incorrect errors
- "no-unused-vars": "off",
- "typescript/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
- }
+ "rules": {
+ // note you must disable the base rule as it can report incorrect errors
+ "no-unused-vars": "off",
+ "@typescript-eslint/no-unused-vars": ["error", {
+ "vars": "all",
+ "args": "after-used",
+ "ignoreRestSiblings": false
+ }]
+ }
}
```
diff --git a/packages/eslint-plugin/lib/configs/recommended.json b/packages/eslint-plugin/lib/configs/recommended.json
index 77b6e55d31c9..cd21778bfff1 100644
--- a/packages/eslint-plugin/lib/configs/recommended.json
+++ b/packages/eslint-plugin/lib/configs/recommended.json
@@ -1,5 +1,5 @@
{
- "parser": "@typescript-eslint/eslint-plugin/parser",
+ "parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
diff --git a/packages/eslint-plugin/lib/rules/indent.js b/packages/eslint-plugin/lib/rules/indent.js
index a8024145a1c4..84144219faff 100644
--- a/packages/eslint-plugin/lib/rules/indent.js
+++ b/packages/eslint-plugin/lib/rules/indent.js
@@ -101,7 +101,8 @@ module.exports = Object.assign({}, baseRule, {
url: util.metaDocsUrl('indent')
},
fixable: 'whitespace',
- schema: baseRule.meta.schema
+ schema: baseRule.meta.schema,
+ messages: baseRule.meta.messages
},
create(context) {
diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js
index eef6ddb2310f..d7f32f15a5c1 100644
--- a/packages/eslint-plugin/lib/rules/no-unused-vars.js
+++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js
@@ -21,7 +21,8 @@ module.exports = Object.assign({}, baseRule, {
url: util.metaDocsUrl('no-unused-vars'),
recommended: 'warn'
},
- schema: baseRule.meta.schema
+ schema: baseRule.meta.schema,
+ messages: baseRule.meta.messages
},
create(context) {
@@ -62,6 +63,9 @@ module.exports = Object.assign({}, baseRule, {
},
'TSEnumMember Identifier'(node) {
context.markVariableAsUsed(node.name);
+ },
+ '*[declare=true] Identifier'(node) {
+ context.markVariableAsUsed(node.name);
}
});
}
diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js
index 66c6312ea14d..1df02bfb9e8e 100644
--- a/packages/eslint-plugin/lib/util.js
+++ b/packages/eslint-plugin/lib/util.js
@@ -117,11 +117,8 @@ exports.getParserServices = context => {
!context.parserServices.program ||
!context.parserServices.esTreeNodeToTSNodeMap
) {
- // TODO - the message will require revisiting once the @typescript-eslint/parser work finalises
- // their work around exposing the parser. They may require that there be a project config field in
- // the eslint config, in which case we should check and/or report that here appropriately.
throw new Error(
- 'This rule requires you to use `@typescript-eslint/eslint-plugin/parser`.'
+ 'This rule requires you to use `@typescript-eslint/parser`.'
);
}
return context.parserServices;
diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json
index a8f81d0eab0b..34d125380e4c 100644
--- a/packages/eslint-plugin/package.json
+++ b/packages/eslint-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
- "version": "0.2.1",
+ "version": "1.0.0",
"description": "TypeScript plugin for ESLint",
"keywords": [
"eslint",
@@ -24,7 +24,7 @@
"recommended:update": "node tools/update-recommended.js"
},
"dependencies": {
- "@typescript-eslint/parser": "0.2.1",
+ "@typescript-eslint/parser": "1.0.0",
"requireindex": "^1.2.0"
},
"devDependencies": {
diff --git a/packages/eslint-plugin/parser.js b/packages/eslint-plugin/parser.js
deleted file mode 100644
index 44041c4bf2c8..000000000000
--- a/packages/eslint-plugin/parser.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * @fileoverview Internal parser
- * @author Patricio Trevino
- */
-
-'use strict';
-
-// export the @typescript-eslint/parser.
-// this forces the parser to be a direct dependency of the plugin.
-module.exports = require('@typescript-eslint/parser');
diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js
index 8e7a5a8a7892..25410bbf2701 100644
--- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js
+++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js
@@ -525,6 +525,22 @@ import * as fastify from 'fastify'
import { Server, IncomingMessage, ServerResponse } from 'http'
const server: fastify.FastifyInstance = fastify({})
server.get('/ping')
+ `,
+ // https://github.com/typescript-eslint/typescript-eslint/issues/61
+ `declare function foo();`,
+ // https://github.com/typescript-eslint/typescript-eslint/issues/61
+ `
+declare namespace Foo {
+ function bar(line: string, index: number | null, tabSize: number): number;
+ var baz: string;
+}
+ `,
+ // https://github.com/typescript-eslint/typescript-eslint/issues/61
+ `
+declare var Foo: {
+ new (value?: any): Object,
+ foo(): string
+}
`
],
diff --git a/packages/eslint-plugin/tools/update-recommended.js b/packages/eslint-plugin/tools/update-recommended.js
index 73b9571eddbe..ce402c3933be 100644
--- a/packages/eslint-plugin/tools/update-recommended.js
+++ b/packages/eslint-plugin/tools/update-recommended.js
@@ -49,7 +49,7 @@ function generate() {
const filePath = path.resolve(__dirname, '../lib/configs/recommended.json');
const recommendedConfig = {
- parser: '@typescript-eslint/eslint-plugin/parser',
+ parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module'
},
diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md
index eec382e512e0..1e519885b94a 100644
--- a/packages/parser/CHANGELOG.md
+++ b/packages/parser/CHANGELOG.md
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+### Features
+
+- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736))
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/parser
diff --git a/packages/parser/README.md b/packages/parser/README.md
index 253ed00e4686..77359a790f34 100644
--- a/packages/parser/README.md
+++ b/packages/parser/README.md
@@ -1,11 +1,19 @@
-# TypeScript ESLint Parser
+TypeScript ESLint Parser
-An ESLint custom parser which leverages [TypeScript ESTree](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree) to allow for ESLint to lint TypeScript source code.
+An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
+
+
+
+
+
+
+
+
## Installation:
```sh
-npm install --save-dev @typescript-eslint/parser
+npm install @typescript-eslint/parser --save-dev
```
## Usage
@@ -26,13 +34,13 @@ The core rules built into ESLint, such as `indent` have no knowledge of such con
Instead, you also need to make use of one more plugins which will add or extend rules with TypeScript-specific features.
-By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/nzakas/@typescript-eslint/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/JamesHenry/@typescript-eslint/eslint-plugin-tslint).
+By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint).
## Configuration
The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) in your ESLint configuration file.
-- **`jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html).
+- **`ecmaFeatures.jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html).
- It's `false` on `*.ts` files regardless of this option.
- It's `true` on `*.tsx` files regardless of this option.
@@ -46,7 +54,9 @@ The following additional configuration options are available by specifying them
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
- "jsx": true,
+ "ecmaFeatures": {
+ "jsx": true
+ },
"useJSXTextNode": true
}
}
@@ -54,50 +64,13 @@ The following additional configuration options are available by specifying them
## Supported TypeScript Version
-We will always endeavor to support the latest stable version of TypeScript.
-
-The version of TypeScript currently supported by this parser is `~3.2.1`. 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.
-
-If you use a non-supported version of TypeScript, the parser will log a warning to the console.
+Please see https://github.com/typescript-eslint/typescript-eslint for the supported TypeScript version.
**Please ensure that you are using a supported version before submitting any issues/bug reports.**
## Reporting Issues
-Please check the current list of open and known issues and ensure the issue has not been reported before. When creating a new issue provide as much information about your environment as possible. This includes:
-
-- ESLint Version
-- TypeScript version
-- The `@typescript-eslint/parser` version
-- ESLint config or rules and plugins currently enabled
-
-## Integration Tests
-
-We have a very flexible way of running integration tests which connects all of the moving parts of the usage of this parser in the ESLint ecosystem.
-
-We run each test within its own docker container, and so each one has complete autonomy over what dependencies/plugins are installed and what versions are used. This also has the benefit of not bloating the `package.json` and `node_modules` of the parser project itself.
-
-> If you are going to submit an issue related to the usage of this parser with ESLint, please consider creating a failing integration test which clearly demonstrates the behavior. It's honestly super quick!
-
-You just need to duplicate one of the existing test sub-directories found in `tests/integration/`, tweak the dependencies and ESLint config to match what you need, and add a new entry to the docker-compose.yml file which matches the format of the existing ones.
-
-Then run:
-
-```sh
-npm run integration-tests
-```
-
-If you ever need to change what gets installed when the docker images are built by docker-compose, you will first need to kill the existing containers by running:
-
-```sh
-npm run kill-integration-test-containers
-```
-
-## Build Commands
-
-- `npm test` - run all linting and tests
-- `npm run lint` - run all linting
-- `npm run integration-tests` - run only integration tests
+Please use the @typescript-eslint/parser issue template when creating your issue and fill out the information requested as best you can. This will really help us when looking into your issue.
## License
diff --git a/packages/parser/package.json b/packages/parser/package.json
index b4271605c7b9..be34576e324c 100644
--- a/packages/parser/package.json
+++ b/packages/parser/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
- "version": "0.2.1",
+ "version": "1.0.0",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"main": "dist/parser.js",
"files": [
@@ -36,7 +36,7 @@
"typescript": "*"
},
"dependencies": {
- "@typescript-eslint/typescript-estree": "0.2.1",
+ "@typescript-eslint/typescript-estree": "1.0.0",
"eslint-scope": "^4.0.0",
"eslint-visitor-keys": "^1.0.0"
},
@@ -44,6 +44,6 @@
"@types/eslint": "^4.16.5",
"@types/eslint-visitor-keys": "^1.0.0",
"@types/estree": "^0.0.39",
- "@typescript-eslint/shared-fixtures": "0.2.1"
+ "@typescript-eslint/shared-fixtures": "1.0.0"
}
}
diff --git a/packages/parser/src/parser-options.ts b/packages/parser/src/parser-options.ts
index 6bb6b160bca7..95d6e54c182c 100644
--- a/packages/parser/src/parser-options.ts
+++ b/packages/parser/src/parser-options.ts
@@ -1,17 +1,20 @@
export interface ParserOptions {
- useJSXTextNode?: boolean;
- loc?: true;
- range?: true;
- tokens?: true;
- filePath?: string;
+ loc?: boolean;
+ comment?: boolean;
+ range?: boolean;
+ tokens?: boolean;
sourceType?: 'script' | 'module';
ecmaVersion?: number;
ecmaFeatures?: {
globalReturn?: boolean;
+ jsx?: boolean;
};
- /**
- * @deprecated We should finalize the work from
- * https://github.com/eslint/typescript-eslint-parser#595
- */
- jsx?: boolean;
+ // ts-estree specific
+ filePath?: string;
+ project?: string | string[];
+ useJSXTextNode?: boolean;
+ errorOnUnknownASTType?: boolean;
+ errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
+ tsconfigRootDir?: string;
+ extraFileExtensions?: string[];
}
diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts
index 49aabf26074a..2dd32b383625 100644
--- a/packages/parser/src/parser.ts
+++ b/packages/parser/src/parser.ts
@@ -1,5 +1,9 @@
import traverser from 'eslint/lib/util/traverser';
-import * as typescriptESTree from '@typescript-eslint/typescript-estree';
+import {
+ AST_NODE_TYPES,
+ parseAndGenerateServices,
+ ParserOptions as ParserOptionsTsESTree
+} from '@typescript-eslint/typescript-estree';
import { analyzeScope } from './analyze-scope';
import { ParserOptions } from './parser-options';
import { visitorKeys } from './visitor-keys';
@@ -20,52 +24,67 @@ interface ParseForESLintResult {
scopeManager: ReturnType;
}
+function validateBoolean(
+ value: boolean | undefined,
+ fallback: boolean = false
+): boolean {
+ if (typeof value !== 'boolean') {
+ return fallback;
+ }
+ return value;
+}
+
+//------------------------------------------------------------------------------
+// Public
+//------------------------------------------------------------------------------
+
export const version = packageJSON.version;
+export const Syntax = Object.freeze(AST_NODE_TYPES);
+
export function parse(code: string, options?: ParserOptions) {
return parseForESLint(code, options).ast;
}
-export const Syntax = Object.freeze(typescriptESTree.AST_NODE_TYPES);
-
-export function parseForESLint(
+export function parseForESLint(
code: string,
- options?: T | null
+ options?: ParserOptions | null
): ParseForESLintResult {
- if (typeof options !== 'object' || options === null) {
- options = { useJSXTextNode: true } as T;
- } else if (typeof options.useJSXTextNode !== 'boolean') {
- options = Object.assign({}, options, { useJSXTextNode: true });
- }
- if (typeof options.filePath === 'string') {
- const tsx = options.filePath.endsWith('.tsx');
- if (tsx || options.filePath.endsWith('.ts')) {
- options = Object.assign({}, options, { jsx: tsx });
- }
+ if (!options || typeof options !== 'object') {
+ options = {};
}
-
// https://eslint.org/docs/user-guide/configuring#specifying-parser-options
// if sourceType is not provided by default eslint expect that it will be set to "script"
- options.sourceType = options.sourceType || 'script';
if (options.sourceType !== 'module' && options.sourceType !== 'script') {
options.sourceType = 'script';
}
+ if (typeof options.ecmaFeatures !== 'object') {
+ options.ecmaFeatures = {};
+ }
+
+ const parserOptions: ParserOptionsTsESTree = {};
+ Object.assign(parserOptions, options, {
+ useJSXTextNode: validateBoolean(options.useJSXTextNode, true),
+ jsx: validateBoolean(options.ecmaFeatures.jsx)
+ });
+
+ if (typeof options.filePath === 'string') {
+ const tsx = options.filePath.endsWith('.tsx');
+ if (tsx || options.filePath.endsWith('.ts')) {
+ parserOptions.jsx = tsx;
+ }
+ }
- const { ast, services } = typescriptESTree.parseAndGenerateServices(
- code,
- options
- );
+ const { ast, services } = parseAndGenerateServices(code, parserOptions);
ast.sourceType = options.sourceType;
traverser.traverse(ast, {
- enter: (node: any) => {
+ enter(node: any) {
switch (node.type) {
// Function#body cannot be null in ESTree spec.
case 'FunctionExpression':
if (!node.body) {
- node.type = `TSEmptyBody${
- node.type
- }` as typescriptESTree.AST_NODE_TYPES;
+ node.type = `TSEmptyBody${node.type}` as AST_NODE_TYPES;
}
break;
// no default
diff --git a/packages/parser/tests/lib/comments.ts b/packages/parser/tests/lib/comments.ts
index bdf3356f3a4b..f2bb2260d651 100644
--- a/packages/parser/tests/lib/comments.ts
+++ b/packages/parser/tests/lib/comments.ts
@@ -15,8 +15,10 @@ describe('Comments', () => {
testFiles.forEach(filename => {
const code = fs.readFileSync(filename, 'utf8');
const config: ParserOptions = {
- jsx: true,
- sourceType: 'module'
+ sourceType: 'module',
+ ecmaFeatures: {
+ jsx: true
+ }
};
it(
testUtils.formatSnapshotName(filename, FIXTURES_DIR),
diff --git a/packages/parser/tests/lib/jsx.ts b/packages/parser/tests/lib/jsx.ts
index 55bb4e5f742f..05adef987f6f 100644
--- a/packages/parser/tests/lib/jsx.ts
+++ b/packages/parser/tests/lib/jsx.ts
@@ -28,7 +28,9 @@ describe('JSX', () => {
const code = fs.readFileSync(filename, 'utf8');
const config = {
useJSXTextNode,
- jsx: true
+ ecmaFeatures: {
+ jsx: true
+ }
};
it(
testUtils.formatSnapshotName(filename, fixturesDir),
diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts
index f5b1f7a9ac4a..bfc23bac5abb 100644
--- a/packages/parser/tests/lib/parser.ts
+++ b/packages/parser/tests/lib/parser.ts
@@ -1,5 +1,6 @@
import * as typescriptESTree from '@typescript-eslint/typescript-estree';
import { parse, parseForESLint, Syntax } from '../../src/parser';
+import * as scope from '../../src/analyze-scope';
describe('parser', () => {
it('parse() should return just the AST from parseForESLint()', () => {
@@ -15,11 +16,64 @@ describe('parser', () => {
it('parseForESLint() should set the sourceType to script, if an invalid one is provided', () => {
const code = 'const valid = true;';
const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices');
+ const spyScope = jest.spyOn(scope, 'analyzeScope');
parseForESLint(code, { sourceType: 'foo' as any });
expect(spy).toHaveBeenCalledWith(code, {
+ ecmaFeatures: {},
+ jsx: false,
sourceType: 'script',
useJSXTextNode: true
});
+ expect(spyScope).toHaveBeenCalledWith(jasmine.any(Object), {
+ ecmaFeatures: {},
+ sourceType: 'script'
+ });
+ });
+
+ it('parseAndGenerateServices() should be called with options', () => {
+ const code = 'const valid = true;';
+ const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices');
+ parseForESLint(code, {
+ loc: false,
+ comment: false,
+ range: false,
+ tokens: false,
+ sourceType: 'module',
+ ecmaVersion: 10,
+ ecmaFeatures: {
+ globalReturn: false,
+ jsx: false
+ },
+ // ts-estree specific
+ filePath: 'test/foo',
+ project: 'tsconfig.json',
+ useJSXTextNode: false,
+ errorOnUnknownASTType: false,
+ errorOnTypeScriptSyntacticAndSemanticIssues: false,
+ tsconfigRootDir: '../../',
+ extraFileExtensions: ['foo']
+ });
+ expect(spy).toHaveBeenCalledWith(code, {
+ jsx: false,
+ loc: false,
+ comment: false,
+ range: false,
+ tokens: false,
+ sourceType: 'module',
+ ecmaVersion: 10,
+ ecmaFeatures: {
+ globalReturn: false,
+ jsx: false
+ },
+ // ts-estree specific
+ filePath: 'test/foo',
+ project: 'tsconfig.json',
+ useJSXTextNode: false,
+ errorOnUnknownASTType: false,
+ errorOnTypeScriptSyntacticAndSemanticIssues: false,
+ tsconfigRootDir: '../../',
+ extraFileExtensions: ['foo']
+ });
});
it('Syntax should contain a frozen object of typescriptESTree.AST_NODE_TYPES', () => {
diff --git a/packages/parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts
index 0872edf307b0..a18278e80458 100644
--- a/packages/parser/tests/lib/tsx.ts
+++ b/packages/parser/tests/lib/tsx.ts
@@ -17,7 +17,9 @@ describe('TSX', () => {
const code = fs.readFileSync(filename, 'utf8');
const config = {
useJSXTextNode: true,
- jsx: true
+ ecmaFeatures: {
+ jsx: true
+ }
};
it(
testUtils.formatSnapshotName(filename, FIXTURES_DIR, '.tsx'),
@@ -53,7 +55,9 @@ describe('TSX', () => {
const config = {
parser: '@typescript-eslint/parser',
parserOptions: {
- jsx: true
+ ecmaFeatures: {
+ jsx: true
+ }
}
};
const messages = linter.verify(code, config);
@@ -85,7 +89,9 @@ describe('TSX', () => {
const config = {
parser: '@typescript-eslint/parser',
parserOptions: {
- jsx: true
+ ecmaFeatures: {
+ jsx: true
+ }
}
};
const messages = linter.verify(code, config, { filename: 'test.ts' });
@@ -117,7 +123,9 @@ describe('TSX', () => {
const config = {
parser: '@typescript-eslint/parser',
parserOptions: {
- jsx: false
+ ecmaFeatures: {
+ jsx: false
+ }
}
};
const messages = linter.verify(code, config, { filename: 'test.tsx' });
diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md
index aebf69abe3ec..2b7402f262e4 100644
--- a/packages/shared-fixtures/CHANGELOG.md
+++ b/packages/shared-fixtures/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+**Note:** Version bump only for package @typescript-eslint/shared-fixtures
+
+
+
+
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/shared-fixtures
diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json
index fe6193c18596..4478df0606e9 100644
--- a/packages/shared-fixtures/package.json
+++ b/packages/shared-fixtures/package.json
@@ -1,5 +1,5 @@
{
"name": "@typescript-eslint/shared-fixtures",
- "version": "0.2.1",
+ "version": "1.0.0",
"private": true
}
diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md
index 2ee862165041..39323d365fd7 100644
--- a/packages/typescript-estree/CHANGELOG.md
+++ b/packages/typescript-estree/CHANGELOG.md
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20)
+
+### Features
+
+- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736))
+
## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20)
**Note:** Version bump only for package @typescript-eslint/typescript-estree
diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md
index 110521f37616..910002f4fae0 100644
--- a/packages/typescript-estree/README.md
+++ b/packages/typescript-estree/README.md
@@ -3,12 +3,11 @@
A parser that converts TypeScript source code into an ESTree-compatible form
-
-
-
-
-
-
+
+
+
+
+
@@ -24,8 +23,8 @@ In fact, it is already used within these hyper-popular open-source projects to p
## Installation
-```
-npm install --save @typescript-eslint/typescript-estree
+```sh
+npm install @typescript-eslint/typescript-estree --save-dev
```
## API
@@ -34,46 +33,46 @@ npm install --save @typescript-eslint/typescript-estree
Parses the given string of code with the options provided and returns an ESTree-compatible AST. The options object has the following properties:
-```javascript
+```js
{
- // attach range information to each node
- range: false,
-
- // attach line/column location information to each node
- loc: false,
-
- // create a top-level tokens array containing all tokens
- tokens: false,
-
- // create a top-level comments array containing all comments
- comment: false,
-
- // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html
- jsx: false,
-
- /*
- * The JSX AST changed the node type for string literals
- * inside a JSX Element from `Literal` to `JSXText`.
- * When value is `true`, these nodes will be parsed as type `JSXText`.
- * When value is `false`, these nodes will be parsed as type `Literal`.
- */
- useJSXTextNode: false,
-
- // Cause the parser to error if it encounters an unknown AST node type (useful for testing)
- errorOnUnknownASTType: false,
-
- /*
- * Allows overriding of function used for logging.
- * When value is `false`, no logging will occur.
- * When value is not provided, `console.log()` will be used.
- */
- loggerFn: undefined
+ // attach range information to each node
+ range: false,
+
+ // attach line/column location information to each node
+ loc: false,
+
+ // create a top-level tokens array containing all tokens
+ tokens: false,
+
+ // create a top-level comments array containing all comments
+ comment: false,
+
+ // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html
+ jsx: false,
+
+ /*
+ * The JSX AST changed the node type for string literals
+ * inside a JSX Element from `Literal` to `JSXText`.
+ * When value is `true`, these nodes will be parsed as type `JSXText`.
+ * When value is `false`, these nodes will be parsed as type `Literal`.
+ */
+ useJSXTextNode: false,
+
+ // Cause the parser to error if it encounters an unknown AST node type (useful for testing)
+ errorOnUnknownASTType: false,
+
+ /*
+ * Allows overriding of function used for logging.
+ * When value is `false`, no logging will occur.
+ * When value is not provided, `console.log()` will be used.
+ */
+ loggerFn: undefined
}
```
Example usage:
-```javascript
+```js
const parser = require('@typescript-eslint/typescript-estree');
const code = `const hello: string = 'world';`;
const ast = parser.parse(code, {
@@ -88,7 +87,7 @@ Exposes the current version of typescript-estree as specified in package.json.
Example usage:
-```javascript
+```js
const parser = require('@typescript-eslint/typescript-estree');
const version = parser.version;
```
@@ -99,7 +98,7 @@ Exposes an object that contains the AST node types produced by the parser.
Example usage:
-```javascript
+```js
const parser = require('@typescript-eslint/typescript-estree');
const astNodeTypes = parser.AST_NODE_TYPES;
```
diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json
index 770cf0a1da51..10d0639be1f4 100644
--- a/packages/typescript-estree/package.json
+++ b/packages/typescript-estree/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/typescript-estree",
- "version": "0.2.1",
+ "version": "1.0.0",
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
"main": "dist/parser.js",
"files": [
@@ -41,7 +41,7 @@
"typescript": "*"
},
"devDependencies": {
- "@typescript-eslint/shared-fixtures": "0.2.1",
+ "@typescript-eslint/shared-fixtures": "1.0.0",
"typescript": "~3.2.1"
}
}
diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts
index 1a39cfd2f31f..2f6347e0a7a2 100644
--- a/packages/typescript-estree/src/parser.ts
+++ b/packages/typescript-estree/src/parser.ts
@@ -350,10 +350,7 @@ function generateAST(
// Public
//------------------------------------------------------------------------------
-export { AST_NODE_TYPES } from './ast-node-types';
-export { version };
-
-const version = packageJSON.version;
+export const version: string = packageJSON.version;
export function parse(
code: string,
@@ -378,3 +375,6 @@ export function parseAndGenerateServices(code: string, options: ParserOptions) {
}
};
}
+
+export { AST_NODE_TYPES } from './ast-node-types';
+export { ParserOptions };
diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
index 22bddf6b7baf..178b86573537 100644
--- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
+++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
@@ -352,9 +352,8 @@ tester.addFixturePatternConfig('typescript/basics', {
*/
'interface-with-extends-member-expression',
/**
- * Babel bug for parsing exported abstract interface
- * https://github.com/babel/babel/issues/9304
- * PR: https://github.com/babel/babel/pull/9336
+ * PR for parsing exported abstract interface has been merged into Babel: https://github.com/babel/babel/pull/9336
+ * TODO: remove me in next babel > 7.2.3
*/
'abstract-interface',
/**