From 51229f9336885ad38cf4f2b849dd681a711e6014 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Wed, 3 Jun 2020 20:52:31 +1000 Subject: [PATCH] feat: Update to @typescript-eslint v3.1.0 (#99) BREAKING CHANGE: Dropped support for Node 8 BREAKING CHANGE: Dropped support for TypeScript 3.2 --- README.md | 5 +-- lib/shared.js | 49 ++++++++++++++++++++++-- package-lock.json | 94 +++++++++++++++++++++-------------------------- package.json | 6 +-- 4 files changed, 92 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 0e89909..aa8c8ff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ npm install eslint-config-airbnb-typescript \ eslint-plugin-jsx-a11y@^6.2.3 \ eslint-plugin-react@^7.19.0 \ eslint-plugin-react-hooks@^2.5.0 \ - @typescript-eslint/eslint-plugin@^2.24.0 \ + @typescript-eslint/eslint-plugin@^3.1.0 \ --save-dev ``` @@ -42,7 +42,7 @@ Install dependencies. ESLint plugins [must also be installed](https://github.com ```bash npm install eslint-config-airbnb-typescript \ eslint-plugin-import@^2.20.1 \ - @typescript-eslint/eslint-plugin@^2.24.0 \ + @typescript-eslint/eslint-plugin@^3.1.0 \ --save-dev ``` @@ -74,7 +74,6 @@ It's recommended to alter your ESLint config for additional functionality. Here' "extends": [ "airbnb-typescript", "airbnb/hooks", - "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking" ], diff --git a/lib/shared.js b/lib/shared.js index f0a00d6..9e3a7a2 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -28,16 +28,47 @@ module.exports = { 'brace-style': 'off', '@typescript-eslint/brace-style': baseStyleRules['brace-style'], - // Replace Airbnb 'camelcase' rule with '@typescript-eslint' version - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md + // Replace Airbnb 'camelcase' rule with '@typescript-eslint/naming-convention' + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md camelcase: 'off', - '@typescript-eslint/camelcase': baseStyleRules.camelcase, - + '@typescript-eslint/naming-convention': [ + 'error', + // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this. + { + selector: 'default', + format: ['camelCase'], + }, + // Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums. + { + selector: 'typeLike', + format: ['PascalCase'], + }, + // Allow UPPER_CASE for variables to cater for 23.10 + { + selector: 'variable', + format: ['camelCase', 'UPPER_CASE'], + }, + // Allow any naming convention for properties, because (1) Airbnb does not specify any naming conventions for properties (2) The `camelcase` rule specifically disables checking properties: https://github.com/airbnb/javascript/blob/06b3ab11d9a443ff46f052dd00375e271e5146e6/packages/eslint-config-airbnb-base/rules/style.js#L24 + { + selector: 'property', + format: null, + }, + // Allow any naming convention for enum members, because Airbnb has no recommendation + { + selector: 'enumMember', + format: null, + }, + ], // Replace Airbnb 'comma-spacing' rule with '@typescript-eslint' version // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-spacing.md 'comma-spacing': 'off', '@typescript-eslint/comma-spacing': baseStyleRules['comma-spacing'], + // Replace Airbnb 'dot-notation' rule with '@typescript-eslint' version + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md + 'dot-notation': 'off', + '@typescript-eslint/dot-notation': baseBestPracticesRules['dot-notation'], + // Replace Airbnb 'func-call-spacing' rule with '@typescript-eslint' version // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md 'func-call-spacing': 'off', @@ -48,6 +79,16 @@ module.exports = { indent: 'off', '@typescript-eslint/indent': baseStyleRules.indent, + // Replace Airbnb 'keyword-spacing' rule with '@typescript-eslint' version + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md + 'keyword-spacing': 'off', + '@typescript-eslint/keyword-spacing': baseStyleRules['keyword-spacing'], + + // Replace Airbnb 'lines-between-class-members' rule with '@typescript-eslint' version + // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md + 'lines-between-class-members': 'off', + '@typescript-eslint/lines-between-class-members': baseStyleRules['lines-between-class-members'], + // Replace Airbnb 'no-array-constructor' rule with '@typescript-eslint' version // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md 'no-array-constructor': 'off', diff --git a/package-lock.json b/package-lock.json index 4d2085d..b5249b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,88 +103,77 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.27.0.tgz", - "integrity": "sha512-/my+vVHRN7zYgcp0n4z5A6HAK7bvKGBiswaM5zIlOQczsxj/aiD7RcgD+dvVFuwFaGh5+kM7XA6Q6PN0bvb1tw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.1.0.tgz", + "integrity": "sha512-D52KwdgkjYc+fmTZKW7CZpH5ZBJREJKZXRrveMiRCmlzZ+Rw9wRVJ1JAmHQ9b/+Ehy1ZeaylofDB9wwXUt83wg==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.27.0", + "@typescript-eslint/experimental-utils": "3.1.0", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { - "@typescript-eslint/experimental-utils": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.27.0.tgz", - "integrity": "sha512-vOsYzjwJlY6E0NJRXPTeCGqjv5OHgRU1kzxHKWJVPjDYGbPgLudBXjIlc+OD1hDBZ4l1DLbOc5VjofKahsu9Jw==", - "dev": true, - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.27.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - } - }, - "@typescript-eslint/typescript-estree": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.27.0.tgz", - "integrity": "sha512-t2miCCJIb/FU8yArjAvxllxbTiyNqaXJag7UOpB5DVoM3+xnjeOngtqlJkLRnMtzaRcJhe3CIR9RmL40omubhg==", - "dev": true, - "requires": { - "debug": "^4.1.1", - "eslint-visitor-keys": "^1.1.0", - "glob": "^7.1.6", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^6.3.0", - "tsutils": "^3.17.1" - } - }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + } + } + }, + "@typescript-eslint/experimental-utils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.1.0.tgz", + "integrity": "sha512-Zf8JVC2K1svqPIk1CB/ehCiWPaERJBBokbMfNTNRczCbQSlQXaXtO/7OfYz9wZaecNvdSvVADt6/XQuIxhC79w==", + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "3.1.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + }, + "dependencies": { "eslint-utils": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", - "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" } } } }, - "@typescript-eslint/experimental-utils": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz", - "integrity": "sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw==", - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.24.0", - "eslint-scope": "^5.0.0" - } - }, "@typescript-eslint/parser": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.24.0.tgz", - "integrity": "sha512-H2Y7uacwSSg8IbVxdYExSI3T7uM1DzmOn2COGtCahCC3g8YtM1xYAPi2MAHyfPs61VKxP/J/UiSctcRgw4G8aw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.1.0.tgz", + "integrity": "sha512-NcDSJK8qTA2tPfyGiPes9HtVKLbksmuYjlgGAUs7Ld2K0swdWibnCq9IJx9kJN8JJdgUJSorFiGaPHBgH81F/Q==", "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.24.0", - "@typescript-eslint/typescript-estree": "2.24.0", + "@typescript-eslint/experimental-utils": "3.1.0", + "@typescript-eslint/typescript-estree": "3.1.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz", - "integrity": "sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.1.0.tgz", + "integrity": "sha512-+4nfYauqeQvK55PgFrmBWFVYb6IskLyOosYEmhH3mSVhfBp9AIJnjExdgDmKWoOBHRcPM8Ihfm2BFpZf0euUZQ==", "requires": { "debug": "^4.1.1", "eslint-visitor-keys": "^1.1.0", "glob": "^7.1.6", "is-glob": "^4.0.1", "lodash": "^4.17.15", - "semver": "^6.3.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" + }, + "dependencies": { + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" + } } }, "acorn": { @@ -2698,7 +2687,8 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true }, "semver-compare": { "version": "1.0.0", diff --git a/package.json b/package.json index cfb0de8..75441c4 100644 --- a/package.json +++ b/package.json @@ -23,15 +23,15 @@ "validate": "npm run lint" }, "dependencies": { - "@typescript-eslint/parser": "^2.24.0", + "@typescript-eslint/parser": "^3.1.0", "eslint-config-airbnb": "^18.1.0", "eslint-config-airbnb-base": "^14.1.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^2.24.0" + "@typescript-eslint/eslint-plugin": "^3.1.0" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "2.27.0", + "@typescript-eslint/eslint-plugin": "^3.1.0", "doctoc": "1.4.0", "eslint": "6.8.0", "eslint-config-prettier": "6.11.0",