From 552d174d7dd0ffbe856d7b99f27c17f1e43f8e7d Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Thu, 11 Apr 2019 18:22:31 +0200 Subject: [PATCH 1/6] feat: add TypeScript support --- README.md | 17 ++-- base.js | 3 +- package.json | 5 +- rules/base.js | 10 +-- rules/typescript.js | 61 +++++++++++++ sample-project/package.json | 6 +- sample-project/yarn.lock | 172 ++++++++++-------------------------- vue.js | 3 +- yarn.lock | 55 +++++++++++- 9 files changed, 185 insertions(+), 147 deletions(-) create mode 100644 rules/typescript.js diff --git a/README.md b/README.md index b2399eb7..ed824450 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Just **focus** on coding. - [Setup your project](#setup-your-project) - [Base requirements](#base-requirements) - - [Vanilla](#vanilla) + - [Vanilla or TypeScript](#vanilla-or-typescript) - [Jest](#jest) - [React](#react) - [Flow](#flow) @@ -41,13 +41,14 @@ Just **focus** on coding. ```sh yarn add \ -eslint babel-eslint prettier \ +eslint @typescript-eslint/parser prettier \ eslint-config-algolia eslint-config-prettier \ eslint-plugin-import eslint-plugin-prettier \ +@typescript-eslint/eslint-plugin typescript \ --dev ``` -### Vanilla +### Vanilla or TypeScript **.eslintrc.js** ```js @@ -61,7 +62,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint .", + "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "npm run lint -- --fix" } } @@ -88,7 +89,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint .", + "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "npm run lint -- --fix" } } @@ -113,7 +114,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint .", + "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "npm run lint -- --fix" } } @@ -152,7 +153,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint .", + "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "npm run lint -- --fix" } } @@ -202,7 +203,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint .", + "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "npm run lint -- --fix" } } diff --git a/base.js b/base.js index ee9abf99..bbdcfb82 100644 --- a/base.js +++ b/base.js @@ -5,7 +5,7 @@ module.exports = { es6: true, node: true, }, - parser: 'babel-eslint', // allows both flowtype and static class properties + parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2018, sourceType: 'module', @@ -17,6 +17,7 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:import/errors', + './rules/typescript.js', './rules/base.js', 'prettier', ], diff --git a/package.json b/package.json index c47cb9f6..bcf6c158 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,8 @@ }, "homepage": "https://github.com/algolia/eslint-config-algolia", "devDependencies": { + "@typescript-eslint/eslint-plugin": "1.6.0", + "@typescript-eslint/parser": "1.6.0", "conventional-changelog-cli": "2.0.12", "doctoc": "1.4.0", "eslint": "5.16.0", @@ -43,6 +45,7 @@ "eslint-plugin-import": "2.16.0", "eslint-plugin-jest": "21.27.2", "eslint-plugin-prettier": "2.7.0", - "json": "9.0.6" + "json": "9.0.6", + "typescript": "3.4.3" } } diff --git a/rules/base.js b/rules/base.js index 6f14098e..d955bde2 100644 --- a/rules/base.js +++ b/rules/base.js @@ -120,8 +120,8 @@ module.exports = { 'no-shadow-restricted-names': ['error'], 'no-undef': ['error'], 'no-undefined': ['off'], - 'no-unused-vars': ['error', { ignoreRestSiblings: true }], - 'no-use-before-define': ['error', { functions: false }], + 'no-unused-vars': ['off'], // Superset by @typescript-eslint/no-unused-vars + 'no-use-before-define': ['off'], // Superset by @typescript-eslint/no-use-before-define // Node.js and Common.js // http://eslint.org/docs/rules/#nodejs-and-commonjs @@ -141,7 +141,7 @@ module.exports = { 'array-bracket-spacing': ['error'], 'block-spacing': ['error'], 'brace-style': ['error', '1tbs', { allowSingleLine: true }], - camelcase: ['error'], + camelcase: ['off'], // Superset by @typescript-eslint/camelcase 'comma-dangle': ['error', 'always-multiline'], 'comma-spacing': ['error'], 'comma-style': ['error'], @@ -181,7 +181,7 @@ module.exports = { 'newline-after-var': ['off'], 'newline-before-return': ['off'], 'newline-per-chained-call': ['off'], - 'no-array-constructor': ['error'], + 'no-array-constructor': ['off'], // Superset by @typescript-eslint/no-array-constructor 'no-bitwise': ['error'], 'no-continue': ['error'], 'no-inline-comments': ['off'], @@ -240,7 +240,7 @@ module.exports = { 'no-restricted-imports': ['off'], 'no-this-before-super': ['error'], 'no-useless-computed-key': ['error'], - 'no-useless-constructor': ['error'], + 'no-useless-constructor': ['off'], // Superset by @typescript-eslint/no-useless-constructor 'no-useless-rename': ['error'], 'no-var': ['error'], 'object-shorthand': ['error'], diff --git a/rules/typescript.js b/rules/typescript.js new file mode 100644 index 00000000..dba97094 --- /dev/null +++ b/rules/typescript.js @@ -0,0 +1,61 @@ +// eslint-disable-next-line import/no-commonjs +module.exports = { + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/adjacent-overload-signatures': ['error'], + '@typescript-eslint/array-type': ['error', 'array-simple'], + '@typescript-eslint/ban-types': ['error'], + '@typescript-eslint/ban-ts-ignore': ['off'], + '@typescript-eslint/camelcase': ['error'], + '@typescript-eslint/class-name-casing': ['error'], + '@typescript-eslint/explicit-function-return-type': ['off'], + '@typescript-eslint/explicit-member-accessibility': ['error'], + '@typescript-eslint/generic-type-naming': ['off'], + '@typescript-eslint/indent': ['off'], + '@typescript-eslint/interface-name-prefix': ['error', 'never'], + '@typescript-eslint/member-delimiter-style': ['off'], + '@typescript-eslint/member-naming': ['off'], + '@typescript-eslint/member-ordering': [ + 'error', + { + default: ['static-field'], + }, + ], + '@typescript-eslint/no-angle-bracket-type-assertion': ['error'], + '@typescript-eslint/no-array-constructor': ['error'], + '@typescript-eslint/no-empty-interface': ['error'], + '@typescript-eslint/no-explicit-any': ['off'], + '@typescript-eslint/no-extraneous-class': ['off'], + '@typescript-eslint/no-for-in-array': ['off'], + '@typescript-eslint/no-inferrable-types': ['off'], + '@typescript-eslint/no-misused-new': ['error'], + '@typescript-eslint/no-namespace': ['error'], + '@typescript-eslint/no-non-null-assertion': ['off'], + '@typescript-eslint/no-object-literal-type-assertion': ['off'], + '@typescript-eslint/no-parameter-properties': ['off'], + '@typescript-eslint/no-require-imports': ['off'], + '@typescript-eslint/no-this-alias': ['off'], + '@typescript-eslint/no-triple-slash-reference': ['error'], + '@typescript-eslint/no-type-alias': ['off'], + '@typescript-eslint/no-unnecessary-qualifier': ['off'], + '@typescript-eslint/no-unnecessary-type-assertion': ['off'], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + ignoreRestSiblings: true, + }, + ], + '@typescript-eslint/no-use-before-define': ['error', { functions: false }], + '@typescript-eslint/no-useless-constructor': ['error'], + '@typescript-eslint/no-var-requires': ['error'], + '@typescript-eslint/prefer-for-of': ['off'], + '@typescript-eslint/prefer-function-type': ['error'], + '@typescript-eslint/prefer-interface': ['off'], + '@typescript-eslint/prefer-namespace-keyword': ['error'], + '@typescript-eslint/promise-function-async': ['off'], + '@typescript-eslint/restrict-plus-operands': ['off'], + '@typescript-eslint/type-annotation-spacing': ['error'], + '@typescript-eslint/unbound-method': ['off'], + '@typescript-eslint/unified-signatures': ['error'], + }, +}; diff --git a/sample-project/package.json b/sample-project/package.json index 31dc942e..2d93248b 100644 --- a/sample-project/package.json +++ b/sample-project/package.json @@ -17,7 +17,8 @@ "react-addons-shallow-compare": "15.6.2" }, "devDependencies": { - "babel-eslint": "10.0.1", + "@typescript-eslint/eslint-plugin": "1.6.0", + "@typescript-eslint/parser": "1.6.0", "eslint": "5.16.0", "eslint-config-algolia": "file:../", "eslint-config-prettier": "3.6.0", @@ -25,6 +26,7 @@ "eslint-plugin-jest": "21.27.2", "eslint-plugin-prettier": "2.7.0", "eslint-plugin-react": "7.7.0", - "prettier": "1.16.4" + "prettier": "1.16.4", + "typescript": "3.4.3" } } diff --git a/sample-project/yarn.lock b/sample-project/yarn.lock index 4580c288..cd24aa59 100644 --- a/sample-project/yarn.lock +++ b/sample-project/yarn.lock @@ -9,40 +9,6 @@ dependencies: "@babel/highlight" "^7.0.0" -"@babel/generator@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0.tgz#1efd58bffa951dc846449e58ce3a1d7f02d393aa" - integrity sha512-/BM2vupkpbZXq22l1ALO7MqXJZH2k8bKVv8Y+pABFnzWdztDB/ZLveP5At21vLz5c2YtSE6p7j2FZEsqafMz5Q== - dependencies: - "@babel/types" "^7.0.0" - jsesc "^2.5.1" - lodash "^4.17.10" - source-map "^0.5.0" - trim-right "^1.0.1" - -"@babel/helper-function-name@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" - integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== - dependencies: - "@babel/helper-get-function-arity" "^7.0.0" - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-get-function-arity@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" - integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== - dependencies: - "@babel/types" "^7.0.0" - -"@babel/helper-split-export-declaration@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813" - integrity sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag== - dependencies: - "@babel/types" "^7.0.0" - "@babel/highlight@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" @@ -52,43 +18,32 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.0.tgz#a7cd42cb3c12aec52e24375189a47b39759b783e" - integrity sha512-SmjnXCuPAlai75AFtzv+KCBcJ3sDDWbIn+WytKw1k+wAtEy6phqI2RqKh/zAnw53i1NR8su3Ep/UoqaKcimuLg== - -"@babel/template@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.0.tgz#58cc9572e1bfe24fe1537fdf99d839d53e517e22" - integrity sha512-yZ948B/pJrwWGY6VxG6XRFsVTee3IQ7bihq9zFpM00Vydu6z5Xwg0C3J644kxI9WOTzd+62xcIsQ+AT1MGhqhA== +"@typescript-eslint/eslint-plugin@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.6.0.tgz#a5ff3128c692393fb16efa403ec7c8a5593dab0f" + integrity sha512-U224c29E2lo861TQZs6GSmyC0OYeRNg6bE9UVIiFBxN2MlA0nq2dCrgIVyyRbC05UOcrgf2Wk/CF2gGOPQKUSQ== dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" + "@typescript-eslint/parser" "1.6.0" + "@typescript-eslint/typescript-estree" "1.6.0" + requireindex "^1.2.0" + tsutils "^3.7.0" -"@babel/traverse@^7.0.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.0.tgz#503ec6669387efd182c3888c4eec07bcc45d91b2" - integrity sha512-bwgln0FsMoxm3pLOgrrnGaXk18sSM9JNf1/nHC/FksmNGFbYnPWY4GYCfLxyP1KRmfsxqkRpfoa6xr6VuuSxdw== +"@typescript-eslint/parser@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.6.0.tgz#f01189c8b90848e3b8e45a6cdad27870529d1804" + integrity sha512-VB9xmSbfafI+/kI4gUK3PfrkGmrJQfh0N4EScT1gZXSZyUxpsBirPL99EWZg9MmPG0pzq/gMtgkk7/rAHj4aQw== dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.0.0" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" - debug "^3.1.0" - globals "^11.1.0" - lodash "^4.17.10" - -"@babel/types@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0.tgz#6e191793d3c854d19c6749989e3bc55f0e962118" - integrity sha512-5tPDap4bGKTLPtci2SUl/B7Gv8RnuJFuQoWx26RJobS0fFrz4reUA3JnwIM+HVHEmWE0C1mzKhDtTp8NsWY02Q== + "@typescript-eslint/typescript-estree" "1.6.0" + eslint-scope "^4.0.0" + eslint-visitor-keys "^1.0.0" + +"@typescript-eslint/typescript-estree@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.6.0.tgz#6cf43a07fee08b8eb52e4513b428c8cdc9751ef0" + integrity sha512-A4CanUwfaG4oXobD5y7EXbsOHjCwn8tj1RDd820etpPAjH+Icjc2K9e/DQM1Hac5zH2BSy+u6bjvvF2wwREvYA== dependencies: - esutils "^2.0.2" - lodash "^4.17.10" - to-fast-properties "^2.0.0" + lodash.unescape "4.0.1" + semver "5.5.0" acorn-jsx@^5.0.0: version "5.0.1" @@ -164,18 +119,6 @@ astral-regex@^1.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== -babel-eslint@10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed" - integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.0.0" - "@babel/traverse" "^7.0.0" - "@babel/types" "^7.0.0" - eslint-scope "3.7.1" - eslint-visitor-keys "^1.0.0" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -286,13 +229,6 @@ debug@^2.6.9: dependencies: ms "2.0.0" -debug@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.0.1.tgz#f9bb36d439b8d1f0dd52d8fb6b46e4ebb8c1cd5b" @@ -444,15 +380,7 @@ eslint-plugin-react@7.7.0: jsx-ast-utils "^2.0.1" prop-types "^15.6.0" -eslint-scope@3.7.1: - version "3.7.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" - integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug= - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-scope@^4.0.3: +eslint-scope@^4.0.0, eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== @@ -700,11 +628,6 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4" - integrity sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ== - globals@^11.7.0: version "11.7.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" @@ -896,11 +819,6 @@ js-yaml@^3.13.0: argparse "^1.0.7" esprima "^4.0.0" -jsesc@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe" - integrity sha1-5CGiqOINawgZ3yiQj3glJrlt0f4= - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -944,10 +862,10 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" -lodash@^4.17.10: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" - integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg== +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@^4.17.11: version "4.17.11" @@ -1244,6 +1162,11 @@ regexpp@^2.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== +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== + resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1303,7 +1226,7 @@ scheduler@^0.13.6: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -semver@^5.5.0: +semver@5.5.0, 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== @@ -1344,11 +1267,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -1453,21 +1371,18 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= - -tslib@^1.9.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.10.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.10.0.tgz#6f1c95c94606e098592b0dff06590cf9659227d6" + integrity sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q== + dependencies: + tslib "^1.8.1" + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -1475,6 +1390,11 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +typescript@3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f" + integrity sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ== + ua-parser-js@^0.7.9: version "0.7.12" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" diff --git a/vue.js b/vue.js index 779b7587..a8f79a97 100644 --- a/vue.js +++ b/vue.js @@ -11,7 +11,7 @@ module.exports = { node: true, }, parserOptions: { - parser: 'babel-eslint', // allows both flowtype and static class properties + parser: '@typescript-eslint/parser', ecmaVersion: 2018, sourceType: 'module', ecmaFeatures: { @@ -23,6 +23,7 @@ module.exports = { 'plugin:vue/strongly-recommended', 'eslint:recommended', 'plugin:import/errors', + './rules/typescript.js', './rules/base.js', 'prettier', './rules/vue.js', diff --git a/yarn.lock b/yarn.lock index 4968f96d..8b9bf18b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36,6 +36,33 @@ traverse "^0.6.6" unified "^6.1.6" +"@typescript-eslint/eslint-plugin@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.6.0.tgz#a5ff3128c692393fb16efa403ec7c8a5593dab0f" + integrity sha512-U224c29E2lo861TQZs6GSmyC0OYeRNg6bE9UVIiFBxN2MlA0nq2dCrgIVyyRbC05UOcrgf2Wk/CF2gGOPQKUSQ== + dependencies: + "@typescript-eslint/parser" "1.6.0" + "@typescript-eslint/typescript-estree" "1.6.0" + requireindex "^1.2.0" + tsutils "^3.7.0" + +"@typescript-eslint/parser@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.6.0.tgz#f01189c8b90848e3b8e45a6cdad27870529d1804" + integrity sha512-VB9xmSbfafI+/kI4gUK3PfrkGmrJQfh0N4EScT1gZXSZyUxpsBirPL99EWZg9MmPG0pzq/gMtgkk7/rAHj4aQw== + dependencies: + "@typescript-eslint/typescript-estree" "1.6.0" + eslint-scope "^4.0.0" + eslint-visitor-keys "^1.0.0" + +"@typescript-eslint/typescript-estree@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.6.0.tgz#6cf43a07fee08b8eb52e4513b428c8cdc9751ef0" + integrity sha512-A4CanUwfaG4oXobD5y7EXbsOHjCwn8tj1RDd820etpPAjH+Icjc2K9e/DQM1Hac5zH2BSy+u6bjvvF2wwREvYA== + dependencies: + lodash.unescape "4.0.1" + semver "5.5.0" + JSONStream@^1.0.4: version "1.3.1" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.1.tgz#707f761e01dae9e16f1bcf93703b78c70966579a" @@ -944,7 +971,7 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-scope@^4.0.3: +eslint-scope@^4.0.0, eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== @@ -1845,6 +1872,11 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" +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@^4.0.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -2378,6 +2410,11 @@ require-uncached@^1.0.3: caller-path "^0.1.0" resolve-from "^1.0.0" +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== + resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" @@ -2465,7 +2502,7 @@ safe-buffer@~5.0.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -semver@^5.5.0: +semver@5.5.0, 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== @@ -2772,11 +2809,18 @@ tryit@^1.0.1: resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" integrity sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics= -tslib@^1.9.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.10.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.10.0.tgz#6f1c95c94606e098592b0dff06590cf9659227d6" + integrity sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q== + dependencies: + tslib "^1.8.1" + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -2789,6 +2833,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typescript@3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f" + integrity sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ== + uglify-js@^3.1.4: version "3.4.9" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" From 67140e79fc84a59b210e40c3bbca76335d7e3d71 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Fri, 12 Apr 2019 18:21:37 +0200 Subject: [PATCH 2/6] Expose TypeScript configuration as standalone --- README.md | 73 ++++++++++++--- base.js | 3 +- package.json | 5 +- rules/base.js | 10 +-- rules/typescript.js | 7 ++ sample-project/package.json | 6 +- sample-project/yarn.lock | 172 ++++++++++++++++++++++++++---------- typescript.js | 17 ++++ vue.js | 3 +- yarn.lock | 55 +----------- 10 files changed, 226 insertions(+), 125 deletions(-) create mode 100644 typescript.js diff --git a/README.md b/README.md index ed824450..ce48d79c 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,19 @@ Just **focus** on coding. - [Setup your project](#setup-your-project) - [Base requirements](#base-requirements) - - [Vanilla or TypeScript](#vanilla-or-typescript) + - [Vanilla](#vanilla) - [Jest](#jest) - [React](#react) - [Flow](#flow) - [Flow with React](#flow-with-react) + - [TypeScript](#typescript) + - [TypeScript with React](#typescript-with-react) - [Vue](#vue) - [Node.js](#nodejs) - [Existing codebase setup](#existing-codebase-setup) - [Setup autofix in IDE](#setup-autofix-in-ide) - [Ignoring files](#ignoring-files) -- [Contibuting](#contibuting) +- [Contributing](#contributing) - [Test](#test) - [Release](#release) @@ -41,14 +43,13 @@ Just **focus** on coding. ```sh yarn add \ -eslint @typescript-eslint/parser prettier \ +eslint babel-eslint prettier \ eslint-config-algolia eslint-config-prettier \ eslint-plugin-import eslint-plugin-prettier \ -@typescript-eslint/eslint-plugin typescript \ --dev ``` -### Vanilla or TypeScript +### Vanilla **.eslintrc.js** ```js @@ -62,7 +63,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint --ext .js,.ts,.tsx .", + "lint": "eslint .", "lint:fix": "npm run lint -- --fix" } } @@ -89,7 +90,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint --ext .js,.ts,.tsx .", + "lint": "eslint .", "lint:fix": "npm run lint -- --fix" } } @@ -114,7 +115,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint --ext .js,.ts,.tsx .", + "lint": "eslint .", "lint:fix": "npm run lint -- --fix" } } @@ -148,6 +149,31 @@ module.exports = { }; ``` +**package.json** +```json +{ + "scripts": { + "test": "npm run lint", + "lint": "eslint .", + "lint:fix": "npm run lint -- --fix" + } +} +``` + +### TypeScript + +**terminal** +```sh +yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript --dev +``` + +**.eslintrc.js** +```js +module.exports = { + extends: 'algolia/typescript' +}; +``` + **package.json** ```json { @@ -159,6 +185,33 @@ module.exports = { } ``` +### TypeScript with React + +**terminal** +```sh +yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript eslint-plugin-react --dev +``` + +**.eslintrc.js** +```js +module.exports = { + extends: ['algolia/react', 'algolia/typescript'] +}; +``` +**Note**: Be sure to put the `algolia/typescript` configuration last so the parser is properly set for TypeScript files. + +**package.json** +```json +{ + "scripts": { + "test": "npm run lint", + "lint": "eslint --ext .js,.ts,.tsx .", + "lint:fix": "npm run lint -- --fix" + } +} +``` + + ### Vue **terminal** @@ -203,7 +256,7 @@ module.exports = { { "scripts": { "test": "npm run lint", - "lint": "eslint --ext .js,.ts,.tsx .", + "lint": "eslint .", "lint:fix": "npm run lint -- --fix" } } @@ -245,7 +298,7 @@ Also activate "Lint HTML files" when dealing with `.vue` components. See "Ignoring Files and Directories" on [ESLint website](http://eslint.org/docs/user-guide/configuring.html#ignoring-files-and-directories). -## Contibuting +## Contributing ### Test diff --git a/base.js b/base.js index bbdcfb82..8fcacf72 100644 --- a/base.js +++ b/base.js @@ -5,7 +5,7 @@ module.exports = { es6: true, node: true, }, - parser: '@typescript-eslint/parser', + parser: 'babel-eslint', parserOptions: { ecmaVersion: 2018, sourceType: 'module', @@ -17,7 +17,6 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:import/errors', - './rules/typescript.js', './rules/base.js', 'prettier', ], diff --git a/package.json b/package.json index bcf6c158..c47cb9f6 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,6 @@ }, "homepage": "https://github.com/algolia/eslint-config-algolia", "devDependencies": { - "@typescript-eslint/eslint-plugin": "1.6.0", - "@typescript-eslint/parser": "1.6.0", "conventional-changelog-cli": "2.0.12", "doctoc": "1.4.0", "eslint": "5.16.0", @@ -45,7 +43,6 @@ "eslint-plugin-import": "2.16.0", "eslint-plugin-jest": "21.27.2", "eslint-plugin-prettier": "2.7.0", - "json": "9.0.6", - "typescript": "3.4.3" + "json": "9.0.6" } } diff --git a/rules/base.js b/rules/base.js index d955bde2..6f14098e 100644 --- a/rules/base.js +++ b/rules/base.js @@ -120,8 +120,8 @@ module.exports = { 'no-shadow-restricted-names': ['error'], 'no-undef': ['error'], 'no-undefined': ['off'], - 'no-unused-vars': ['off'], // Superset by @typescript-eslint/no-unused-vars - 'no-use-before-define': ['off'], // Superset by @typescript-eslint/no-use-before-define + 'no-unused-vars': ['error', { ignoreRestSiblings: true }], + 'no-use-before-define': ['error', { functions: false }], // Node.js and Common.js // http://eslint.org/docs/rules/#nodejs-and-commonjs @@ -141,7 +141,7 @@ module.exports = { 'array-bracket-spacing': ['error'], 'block-spacing': ['error'], 'brace-style': ['error', '1tbs', { allowSingleLine: true }], - camelcase: ['off'], // Superset by @typescript-eslint/camelcase + camelcase: ['error'], 'comma-dangle': ['error', 'always-multiline'], 'comma-spacing': ['error'], 'comma-style': ['error'], @@ -181,7 +181,7 @@ module.exports = { 'newline-after-var': ['off'], 'newline-before-return': ['off'], 'newline-per-chained-call': ['off'], - 'no-array-constructor': ['off'], // Superset by @typescript-eslint/no-array-constructor + 'no-array-constructor': ['error'], 'no-bitwise': ['error'], 'no-continue': ['error'], 'no-inline-comments': ['off'], @@ -240,7 +240,7 @@ module.exports = { 'no-restricted-imports': ['off'], 'no-this-before-super': ['error'], 'no-useless-computed-key': ['error'], - 'no-useless-constructor': ['off'], // Superset by @typescript-eslint/no-useless-constructor + 'no-useless-constructor': ['error'], 'no-useless-rename': ['error'], 'no-var': ['error'], 'object-shorthand': ['error'], diff --git a/rules/typescript.js b/rules/typescript.js index dba97094..a7a9b0c0 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -57,5 +57,12 @@ module.exports = { '@typescript-eslint/type-annotation-spacing': ['error'], '@typescript-eslint/unbound-method': ['off'], '@typescript-eslint/unified-signatures': ['error'], + + // Disable rules superset by @typescript-eslint + 'no-unused-vars': ['off'], + 'no-use-before-define': ['off'], + camelcase: ['off'], + 'no-array-constructor': ['off'], + 'no-useless-constructor': ['off'], }, }; diff --git a/sample-project/package.json b/sample-project/package.json index 2d93248b..31dc942e 100644 --- a/sample-project/package.json +++ b/sample-project/package.json @@ -17,8 +17,7 @@ "react-addons-shallow-compare": "15.6.2" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "1.6.0", - "@typescript-eslint/parser": "1.6.0", + "babel-eslint": "10.0.1", "eslint": "5.16.0", "eslint-config-algolia": "file:../", "eslint-config-prettier": "3.6.0", @@ -26,7 +25,6 @@ "eslint-plugin-jest": "21.27.2", "eslint-plugin-prettier": "2.7.0", "eslint-plugin-react": "7.7.0", - "prettier": "1.16.4", - "typescript": "3.4.3" + "prettier": "1.16.4" } } diff --git a/sample-project/yarn.lock b/sample-project/yarn.lock index cd24aa59..4580c288 100644 --- a/sample-project/yarn.lock +++ b/sample-project/yarn.lock @@ -9,6 +9,40 @@ dependencies: "@babel/highlight" "^7.0.0" +"@babel/generator@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0.tgz#1efd58bffa951dc846449e58ce3a1d7f02d393aa" + integrity sha512-/BM2vupkpbZXq22l1ALO7MqXJZH2k8bKVv8Y+pABFnzWdztDB/ZLveP5At21vLz5c2YtSE6p7j2FZEsqafMz5Q== + dependencies: + "@babel/types" "^7.0.0" + jsesc "^2.5.1" + lodash "^4.17.10" + source-map "^0.5.0" + trim-right "^1.0.1" + +"@babel/helper-function-name@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" + integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== + dependencies: + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-get-function-arity@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" + integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-split-export-declaration@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813" + integrity sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag== + dependencies: + "@babel/types" "^7.0.0" + "@babel/highlight@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" @@ -18,32 +52,43 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@typescript-eslint/eslint-plugin@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.6.0.tgz#a5ff3128c692393fb16efa403ec7c8a5593dab0f" - integrity sha512-U224c29E2lo861TQZs6GSmyC0OYeRNg6bE9UVIiFBxN2MlA0nq2dCrgIVyyRbC05UOcrgf2Wk/CF2gGOPQKUSQ== - dependencies: - "@typescript-eslint/parser" "1.6.0" - "@typescript-eslint/typescript-estree" "1.6.0" - requireindex "^1.2.0" - tsutils "^3.7.0" +"@babel/parser@^7.0.0", "@babel/parser@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.0.tgz#a7cd42cb3c12aec52e24375189a47b39759b783e" + integrity sha512-SmjnXCuPAlai75AFtzv+KCBcJ3sDDWbIn+WytKw1k+wAtEy6phqI2RqKh/zAnw53i1NR8su3Ep/UoqaKcimuLg== -"@typescript-eslint/parser@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.6.0.tgz#f01189c8b90848e3b8e45a6cdad27870529d1804" - integrity sha512-VB9xmSbfafI+/kI4gUK3PfrkGmrJQfh0N4EScT1gZXSZyUxpsBirPL99EWZg9MmPG0pzq/gMtgkk7/rAHj4aQw== +"@babel/template@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.0.tgz#58cc9572e1bfe24fe1537fdf99d839d53e517e22" + integrity sha512-yZ948B/pJrwWGY6VxG6XRFsVTee3IQ7bihq9zFpM00Vydu6z5Xwg0C3J644kxI9WOTzd+62xcIsQ+AT1MGhqhA== dependencies: - "@typescript-eslint/typescript-estree" "1.6.0" - eslint-scope "^4.0.0" - eslint-visitor-keys "^1.0.0" + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" -"@typescript-eslint/typescript-estree@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.6.0.tgz#6cf43a07fee08b8eb52e4513b428c8cdc9751ef0" - integrity sha512-A4CanUwfaG4oXobD5y7EXbsOHjCwn8tj1RDd820etpPAjH+Icjc2K9e/DQM1Hac5zH2BSy+u6bjvvF2wwREvYA== +"@babel/traverse@^7.0.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.0.tgz#503ec6669387efd182c3888c4eec07bcc45d91b2" + integrity sha512-bwgln0FsMoxm3pLOgrrnGaXk18sSM9JNf1/nHC/FksmNGFbYnPWY4GYCfLxyP1KRmfsxqkRpfoa6xr6VuuSxdw== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.0.0" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.0.0" + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + debug "^3.1.0" + globals "^11.1.0" + lodash "^4.17.10" + +"@babel/types@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0.tgz#6e191793d3c854d19c6749989e3bc55f0e962118" + integrity sha512-5tPDap4bGKTLPtci2SUl/B7Gv8RnuJFuQoWx26RJobS0fFrz4reUA3JnwIM+HVHEmWE0C1mzKhDtTp8NsWY02Q== dependencies: - lodash.unescape "4.0.1" - semver "5.5.0" + esutils "^2.0.2" + lodash "^4.17.10" + to-fast-properties "^2.0.0" acorn-jsx@^5.0.0: version "5.0.1" @@ -119,6 +164,18 @@ astral-regex@^1.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== +babel-eslint@10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed" + integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.0.0" + "@babel/traverse" "^7.0.0" + "@babel/types" "^7.0.0" + eslint-scope "3.7.1" + eslint-visitor-keys "^1.0.0" + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -229,6 +286,13 @@ debug@^2.6.9: dependencies: ms "2.0.0" +debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.0.1.tgz#f9bb36d439b8d1f0dd52d8fb6b46e4ebb8c1cd5b" @@ -380,7 +444,15 @@ eslint-plugin-react@7.7.0: jsx-ast-utils "^2.0.1" prop-types "^15.6.0" -eslint-scope@^4.0.0, eslint-scope@^4.0.3: +eslint-scope@3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" + integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug= + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== @@ -628,6 +700,11 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +globals@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4" + integrity sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ== + globals@^11.7.0: version "11.7.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" @@ -819,6 +896,11 @@ js-yaml@^3.13.0: argparse "^1.0.7" esprima "^4.0.0" +jsesc@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe" + integrity sha1-5CGiqOINawgZ3yiQj3glJrlt0f4= + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -862,10 +944,10 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" -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@^4.17.10: + version "4.17.10" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" + integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg== lodash@^4.17.11: version "4.17.11" @@ -1162,11 +1244,6 @@ regexpp@^2.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== -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== - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1226,7 +1303,7 @@ scheduler@^0.13.6: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -semver@5.5.0, semver@^5.5.0: +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== @@ -1267,6 +1344,11 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +source-map@^0.5.0: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -1371,18 +1453,21 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -tslib@^1.8.1, tslib@^1.9.0: +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + +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.10.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.10.0.tgz#6f1c95c94606e098592b0dff06590cf9659227d6" - integrity sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q== - dependencies: - tslib "^1.8.1" - type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -1390,11 +1475,6 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" -typescript@3.4.3: - version "3.4.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f" - integrity sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ== - ua-parser-js@^0.7.9: version "0.7.12" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" diff --git a/typescript.js b/typescript.js new file mode 100644 index 00000000..38764d67 --- /dev/null +++ b/typescript.js @@ -0,0 +1,17 @@ +// eslint-disable-next-line import/no-commonjs +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + impliedStrict: true, + jsx: true, + }, + }, + extends: [ + './base.js', + './rules/typescript.js', + 'prettier/@typescript-eslint', + ], +}; diff --git a/vue.js b/vue.js index a8f79a97..75716a52 100644 --- a/vue.js +++ b/vue.js @@ -11,7 +11,7 @@ module.exports = { node: true, }, parserOptions: { - parser: '@typescript-eslint/parser', + parser: 'babel-eslint', ecmaVersion: 2018, sourceType: 'module', ecmaFeatures: { @@ -23,7 +23,6 @@ module.exports = { 'plugin:vue/strongly-recommended', 'eslint:recommended', 'plugin:import/errors', - './rules/typescript.js', './rules/base.js', 'prettier', './rules/vue.js', diff --git a/yarn.lock b/yarn.lock index 8b9bf18b..4968f96d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36,33 +36,6 @@ traverse "^0.6.6" unified "^6.1.6" -"@typescript-eslint/eslint-plugin@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.6.0.tgz#a5ff3128c692393fb16efa403ec7c8a5593dab0f" - integrity sha512-U224c29E2lo861TQZs6GSmyC0OYeRNg6bE9UVIiFBxN2MlA0nq2dCrgIVyyRbC05UOcrgf2Wk/CF2gGOPQKUSQ== - dependencies: - "@typescript-eslint/parser" "1.6.0" - "@typescript-eslint/typescript-estree" "1.6.0" - requireindex "^1.2.0" - tsutils "^3.7.0" - -"@typescript-eslint/parser@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.6.0.tgz#f01189c8b90848e3b8e45a6cdad27870529d1804" - integrity sha512-VB9xmSbfafI+/kI4gUK3PfrkGmrJQfh0N4EScT1gZXSZyUxpsBirPL99EWZg9MmPG0pzq/gMtgkk7/rAHj4aQw== - dependencies: - "@typescript-eslint/typescript-estree" "1.6.0" - eslint-scope "^4.0.0" - eslint-visitor-keys "^1.0.0" - -"@typescript-eslint/typescript-estree@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.6.0.tgz#6cf43a07fee08b8eb52e4513b428c8cdc9751ef0" - integrity sha512-A4CanUwfaG4oXobD5y7EXbsOHjCwn8tj1RDd820etpPAjH+Icjc2K9e/DQM1Hac5zH2BSy+u6bjvvF2wwREvYA== - dependencies: - lodash.unescape "4.0.1" - semver "5.5.0" - JSONStream@^1.0.4: version "1.3.1" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.1.tgz#707f761e01dae9e16f1bcf93703b78c70966579a" @@ -971,7 +944,7 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-scope@^4.0.0, eslint-scope@^4.0.3: +eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== @@ -1872,11 +1845,6 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" -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@^4.0.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -2410,11 +2378,6 @@ require-uncached@^1.0.3: caller-path "^0.1.0" resolve-from "^1.0.0" -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== - resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" @@ -2502,7 +2465,7 @@ safe-buffer@~5.0.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -semver@5.5.0, semver@^5.5.0: +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== @@ -2809,18 +2772,11 @@ tryit@^1.0.1: resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" integrity sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics= -tslib@^1.8.1, tslib@^1.9.0: +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.10.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.10.0.tgz#6f1c95c94606e098592b0dff06590cf9659227d6" - integrity sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q== - dependencies: - tslib "^1.8.1" - type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -2833,11 +2789,6 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@3.4.3: - version "3.4.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f" - integrity sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ== - uglify-js@^3.1.4: version "3.4.9" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" From 015b0065d8709367cebc3854e577ccaab420b071 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Fri, 12 Apr 2019 18:23:17 +0200 Subject: [PATCH 3/6] Re-add comments on parser --- base.js | 2 +- vue.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/base.js b/base.js index 8fcacf72..ee9abf99 100644 --- a/base.js +++ b/base.js @@ -5,7 +5,7 @@ module.exports = { es6: true, node: true, }, - parser: 'babel-eslint', + parser: 'babel-eslint', // allows both flowtype and static class properties parserOptions: { ecmaVersion: 2018, sourceType: 'module', diff --git a/vue.js b/vue.js index 75716a52..779b7587 100644 --- a/vue.js +++ b/vue.js @@ -11,7 +11,7 @@ module.exports = { node: true, }, parserOptions: { - parser: 'babel-eslint', + parser: 'babel-eslint', // allows both flowtype and static class properties ecmaVersion: 2018, sourceType: 'module', ecmaFeatures: { From d0400a50dd967f0d4e5b97a22c0518f634559e2f Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Mon, 15 Apr 2019 11:18:15 +0200 Subject: [PATCH 4/6] Disable @typescript-eslint/no-var-requires, conflict with import/no-commonjs --- rules/typescript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/typescript.js b/rules/typescript.js index a7a9b0c0..f32bd635 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -47,7 +47,7 @@ module.exports = { ], '@typescript-eslint/no-use-before-define': ['error', { functions: false }], '@typescript-eslint/no-useless-constructor': ['error'], - '@typescript-eslint/no-var-requires': ['error'], + '@typescript-eslint/no-var-requires': ['off'], '@typescript-eslint/prefer-for-of': ['off'], '@typescript-eslint/prefer-function-type': ['error'], '@typescript-eslint/prefer-interface': ['off'], From 3d0bdfe089dec47836533340a1dcc917976ed682 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Tue, 16 Apr 2019 10:45:01 +0200 Subject: [PATCH 5/6] Enable @typescript-eslint/explicit-function-return-type rule --- rules/typescript.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rules/typescript.js b/rules/typescript.js index f32bd635..47ab37f9 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -8,7 +8,13 @@ module.exports = { '@typescript-eslint/ban-ts-ignore': ['off'], '@typescript-eslint/camelcase': ['error'], '@typescript-eslint/class-name-casing': ['error'], - '@typescript-eslint/explicit-function-return-type': ['off'], + '@typescript-eslint/explicit-function-return-type': [ + 'error', + { + allowExpressions: true, + allowTypedFunctionExpressions: true, + }, + ], '@typescript-eslint/explicit-member-accessibility': ['error'], '@typescript-eslint/generic-type-naming': ['off'], '@typescript-eslint/indent': ['off'], From 457be869b3500de2478e6712021c17ab09783c38 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Tue, 16 Apr 2019 10:45:15 +0200 Subject: [PATCH 6/6] Enable @typescript-eslint/generic-type-naming rule --- rules/typescript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/typescript.js b/rules/typescript.js index 47ab37f9..61f6a891 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -16,7 +16,7 @@ module.exports = { }, ], '@typescript-eslint/explicit-member-accessibility': ['error'], - '@typescript-eslint/generic-type-naming': ['off'], + '@typescript-eslint/generic-type-naming': ['error', '^T[A-Z][a-zA-Z]+$'], '@typescript-eslint/indent': ['off'], '@typescript-eslint/interface-name-prefix': ['error', 'never'], '@typescript-eslint/member-delimiter-style': ['off'],