diff --git a/.eslintrc.js b/.eslintrc.js index 4a3ba1dcff90..d7ed999831eb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,6 +15,19 @@ module.exports = { 'prettier/flowtype', ], overrides: [ + { + files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint/eslint-plugin'], + rules: { + '@typescript-eslint/no-unused-vars': [ + 'error', + {argsIgnorePattern: '^_'}, + ], + 'import/order': 'error', + 'no-unused-vars': 'off', + }, + }, // to make it more suitable for running on code examples in docs/ folder { files: ['*.md'], @@ -122,6 +135,7 @@ module.exports = { '^types/(.*)': './types/$1', }, }, + 'eslint-import-resolver-typescript': true, }, }, }; diff --git a/e2e/__tests__/__snapshots__/coverageRemapping.test.js.snap b/e2e/__tests__/__snapshots__/coverageRemapping.test.js.snap index 3faf7a0a5362..ee84a8e4d887 100644 --- a/e2e/__tests__/__snapshots__/coverageRemapping.test.js.snap +++ b/e2e/__tests__/__snapshots__/coverageRemapping.test.js.snap @@ -27,32 +27,32 @@ Object { "loc": Object { "end": Object { "column": 35, - "line": 4, + "line": 6, }, "start": Object { "column": 34, - "line": 4, + "line": 6, }, }, "locations": Array [ Object { "end": Object { "column": 35, - "line": 4, + "line": 6, }, "start": Object { "column": 34, - "line": 4, + "line": 6, }, }, Object { "end": Object { "column": 39, - "line": 4, + "line": 6, }, "start": Object { "column": 38, - "line": 4, + "line": 6, }, }, ], @@ -62,32 +62,32 @@ Object { "loc": Object { "end": Object { "column": 35, - "line": 5, + "line": 7, }, "start": Object { "column": 34, - "line": 5, + "line": 7, }, }, "locations": Array [ Object { "end": Object { "column": 35, - "line": 5, + "line": 7, }, "start": Object { "column": 34, - "line": 5, + "line": 7, }, }, Object { "end": Object { "column": 39, - "line": 5, + "line": 7, }, "start": Object { "column": 38, - "line": 5, + "line": 7, }, }, ], @@ -97,42 +97,42 @@ Object { "loc": Object { "end": Object { "column": 31, - "line": 6, + "line": 8, }, "start": Object { "column": 27, - "line": 6, + "line": 8, }, }, "locations": Array [ Object { "end": Object { "column": 31, - "line": 6, + "line": 8, }, "start": Object { "column": 27, - "line": 6, + "line": 8, }, }, Object { "end": Object { "column": 39, - "line": 6, + "line": 8, }, "start": Object { "column": 35, - "line": 6, + "line": 8, }, }, Object { "end": Object { "column": 48, - "line": 6, + "line": 8, }, "start": Object { "column": 43, - "line": 6, + "line": 8, }, }, ], @@ -142,32 +142,32 @@ Object { "loc": Object { "end": Object { "column": 40, - "line": 7, + "line": 9, }, "start": Object { "column": 30, - "line": 7, + "line": 9, }, }, "locations": Array [ Object { "end": Object { "column": 40, - "line": 7, + "line": 9, }, "start": Object { "column": 30, - "line": 7, + "line": 9, }, }, Object { "end": Object { "column": 53, - "line": 7, + "line": 9, }, "start": Object { "column": 43, - "line": 7, + "line": 9, }, }, ], @@ -184,21 +184,21 @@ Object { "decl": Object { "end": Object { "column": 29, - "line": 3, + "line": 5, }, "start": Object { "column": 9, - "line": 3, + "line": 5, }, }, "loc": Object { "end": Object { "column": 1, - "line": 10, + "line": 12, }, "start": Object { "column": 49, - "line": 3, + "line": 5, }, }, "name": "difference", @@ -207,21 +207,21 @@ Object { "decl": Object { "end": Object { "column": 36, - "line": 7, + "line": 9, }, "start": Object { "column": 30, - "line": 7, + "line": 9, }, }, "loc": Object { "end": Object { "column": 40, - "line": 7, + "line": 9, }, "start": Object { "column": 30, - "line": 7, + "line": 9, }, }, "name": "(anonymous_1)", @@ -230,21 +230,21 @@ Object { "decl": Object { "end": Object { "column": 49, - "line": 7, + "line": 9, }, "start": Object { "column": 43, - "line": 7, + "line": 9, }, }, "loc": Object { "end": Object { "column": 53, - "line": 7, + "line": 9, }, "start": Object { "column": 43, - "line": 7, + "line": 9, }, }, "name": "(anonymous_2)", @@ -265,81 +265,81 @@ Object { "0": Object { "end": Object { "column": 2, - "line": 10, + "line": 12, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "1": Object { "end": Object { "column": 39, - "line": 4, + "line": 6, }, "start": Object { "column": 27, - "line": 4, + "line": 6, }, }, "2": Object { "end": Object { "column": 39, - "line": 5, + "line": 7, }, "start": Object { "column": 27, - "line": 5, + "line": 7, }, }, "3": Object { "end": Object { "column": 48, - "line": 6, + "line": 8, }, "start": Object { "column": 27, - "line": 6, + "line": 8, }, }, "4": Object { "end": Object { "column": 53, - "line": 7, + "line": 9, }, "start": Object { "column": 23, - "line": 7, + "line": 9, }, }, "5": Object { "end": Object { "column": 43, - "line": 7, + "line": 9, }, "start": Object { "column": 36, - "line": 7, + "line": 9, }, }, "6": Object { "end": Object { "column": 54, - "line": 7, + "line": 9, }, "start": Object { "column": 49, - "line": 7, + "line": 9, }, }, "7": Object { "end": Object { "column": 15, - "line": 9, + "line": 11, }, "start": Object { "column": 2, - "line": 9, + "line": 11, }, }, }, diff --git a/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts b/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts index 820294d1973e..ef772b495891 100644 --- a/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts +++ b/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts @@ -7,8 +7,6 @@ * @emails oncall+jsinfra */ -/* eslint-disable import/no-unresolved */ - import {Color} from '../types'; import {color} from '../entry'; diff --git a/e2e/babel-plugin-jest-hoist/entry.ts b/e2e/babel-plugin-jest-hoist/entry.ts index 00ed0fce24fa..bafd2d4f8606 100644 --- a/e2e/babel-plugin-jest-hoist/entry.ts +++ b/e2e/babel-plugin-jest-hoist/entry.ts @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -// eslint-disable-next-line import/no-unresolved import {Color} from './types'; export const color: Color = 'red'; diff --git a/e2e/coverage-remapping/covered.ts b/e2e/coverage-remapping/covered.ts index a11ac4f3cfb8..84b8f7ab9c2e 100644 --- a/e2e/coverage-remapping/covered.ts +++ b/e2e/coverage-remapping/covered.ts @@ -1,5 +1,7 @@ // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +/* eslint-disable @typescript-eslint/no-unused-vars */ + export = function difference(a: number, b: number): number { const branch1: boolean = true ? 1 : 0; const branch2: boolean = true ? 1 : 0; diff --git a/package.json b/package.json index 8d684d5e9566..1f0df8564ba8 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", + "@typescript-eslint/eslint-plugin": "^1.2.0", + "@typescript-eslint/parser": "^1.2.0", "ansi-regex": "^4.0.0", "ansi-styles": "^3.2.0", "babel-eslint": "^9.0.0", @@ -22,6 +24,7 @@ "debug": "^4.0.1", "eslint": "^5.6.0", "eslint-config-prettier": "^3.1.0", + "eslint-import-resolver-typescript": "^1.1.1", "eslint-plugin-babel": "^5.1.0", "eslint-plugin-flowtype": "^2.35.0", "eslint-plugin-import": "^2.6.0", @@ -75,7 +78,7 @@ "clean-e2e": "find ./e2e -not \\( -path ./e2e/presets/js -prune \\) -not \\( -path ./e2e/presets/json -prune \\) -mindepth 2 -type d \\( -name node_modules -prune \\) -exec rm -r '{}' +", "jest": "node ./packages/jest-cli/bin/jest.js", "jest-coverage": "yarn jest --coverage", - "lint": "eslint . --cache --report-unused-disable-directives --ext js,md", + "lint": "eslint . --cache --report-unused-disable-directives --ext js,jsx,ts,tsx,md", "lint-es5-build": "eslint --no-eslintrc --no-ignore --env=browser packages/*/build-es5", "lint:md": "yarn --silent lint:md:ci --fix", "lint:md:ci": "prettylint '**/*.{md,yml,yaml}' --ignore-path .gitignore", diff --git a/yarn.lock b/yarn.lock index 2bf618f358a8..ffc57a710145 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1650,6 +1650,11 @@ "@types/tough-cookie" "*" parse5 "^4.0.0" +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= + "@types/leven@^2.1.1": version "2.1.1" resolved "https://registry.yarnpkg.com/@types/leven/-/leven-2.1.1.tgz#7cdc02ec636f80dc0bb0a53d8ee7eff2d8e8e1d8" @@ -1791,6 +1796,32 @@ resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.2.tgz#7569157b2601d49d4442023c0d22f81d23f62d1e" integrity sha512-NUyxaQW48vjeDHybmhy7CFx/6of1+PoaEGPMI+0PzBVr5s3BTELT7gV4lNaxUsKllNS1YAjkeTEhBtzIDWs2WQ== +"@typescript-eslint/eslint-plugin@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.2.0.tgz#a73021a0d5bd1116a88689186844ce4421d52ab0" + integrity sha512-em3q8Gg3euesNohOwaz+SqrQM2Jn1ZWELMM+vgKi4dEk5fC+eVoi05yfubgAi2qPE5ifG4F0SOXM1XTamB0Aig== + dependencies: + "@typescript-eslint/parser" "1.2.0" + requireindex "^1.2.0" + tsutils "^3.7.0" + +"@typescript-eslint/parser@1.2.0", "@typescript-eslint/parser@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.2.0.tgz#256de163b7cb0d79d0388266a5bfb5585bccb1ff" + integrity sha512-IXXiXgs6ocKTmtbzJjGyUvRHZFLuk2mYXyk+ayEql1woh1+rYS/Uct8b4jGtfHG8ZRUBZ12zjzsrDKFYC2pbrQ== + dependencies: + "@typescript-eslint/typescript-estree" "1.2.0" + eslint-scope "^4.0.0" + eslint-visitor-keys "^1.0.0" + +"@typescript-eslint/typescript-estree@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.2.0.tgz#d9043a407d5e0f07db2b4a80d86852f7826c34f0" + integrity sha512-YGh4egbiCfUObvi6fnQNzJAMmScMGCjG5cRHaapW7GpwujWYQymLlids88imnhcTbOx8Mlz1OXFIuxyPBXK6Ig== + dependencies: + lodash.unescape "4.0.1" + semver "5.5.0" + "@webassemblyjs/ast@1.7.11": version "1.7.11" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.11.tgz#b988582cafbb2b095e8b556526f30c90d057cace" @@ -4280,7 +4311,7 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= -deepmerge@^2.1.1: +deepmerge@^2.0.1, deepmerge@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170" integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA== @@ -4953,6 +4984,15 @@ eslint-import-resolver-node@^0.3.1: debug "^2.6.9" resolve "^1.5.0" +eslint-import-resolver-typescript@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-1.1.1.tgz#e6d42172b95144ef16610fe104ef38340edea591" + integrity sha512-jqSfumQ+H5y3FUJ6NjRkbOQSUOlbBucGTN3ELymOtcDBbPjVdm/luvJuCfCaIXGh8sEF26ma1qVdtDgl9ndhUg== + dependencies: + debug "^4.0.1" + resolve "^1.4.0" + tsconfig-paths "^3.6.0" + eslint-module-utils@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746" @@ -8199,6 +8239,11 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= +lodash.unescape@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" + integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= + lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -11244,6 +11289,11 @@ require-main-filename@^1.0.1: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= +requireindex@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef" + integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww== + requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -11519,6 +11569,11 @@ semver-truncate@^1.1.2: resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== +semver@5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== + semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -12597,11 +12652,29 @@ truncate-html@^1.0.1: "@types/cheerio" "^0.22.8" cheerio "0.22.0" -tslib@^1.8.0, tslib@^1.9.0: +tsconfig-paths@^3.6.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.7.0.tgz#02ae978db447b22e09dafcd4198be95c4885ceb2" + integrity sha512-7iE+Q/2E1lgvxD+c0Ot+GFFmgmfIjt/zCayyruXkXQ84BLT85gHXy0WSoQSiuFX9+d+keE/jiON7notV74ZY+A== + dependencies: + "@types/json5" "^0.0.29" + deepmerge "^2.0.1" + json5 "^1.0.1" + minimist "^1.2.0" + strip-bom "^3.0.0" + +tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== +tsutils@^3.7.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.8.0.tgz#7a3dbadc88e465596440622b65c04edc8e187ae5" + integrity sha512-XQdPhgcoTbCD8baXC38PQ0vpTZ8T3YrE+vR66YIj/xvDt1//8iAhafpIT/4DmvzzC1QFapEImERu48Pa01dIUA== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"