From ebf6c62fbcece1b4c4e5d798176c8e5046761666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Fri, 22 May 2020 15:30:57 +0200 Subject: [PATCH 01/24] feat!: Upgrade @typescript-eslint dependencies --- index.js | 15 +-------------- package.json | 4 ++-- yarn.lock | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/index.js b/index.js index 5d1a471..5652a1f 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ module.exports = { extends: [ "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:eslint-plugin-import/recommended", @@ -27,17 +26,7 @@ module.exports = { default: "array-simple", }, ], - "@typescript-eslint/ban-types": [ - "error", - { - types: { - Object: "Avoid using the `Object` type. Did you mean `object`?", - Boolean: "Avoid using the `Boolean` type. Did you mean `boolean`?", - Number: "Avoid using the `Number` type. Did you mean `number`?", - String: "Avoid using the `String` type. Did you mean `string`?", - }, - }, - ], + "@typescript-eslint/ban-types": "error", "@typescript-eslint/consistent-type-assertions": [ "error", { @@ -62,8 +51,6 @@ module.exports = { }, }, ], - "@typescript-eslint/generic-type-naming": ["error", "^T[A-Z][a-zA-Z]+$"], - "@typescript-eslint/interface-name-prefix": ["error", "always"], "@typescript-eslint/naming-convention": "error", "@typescript-eslint/no-empty-function": [ "error", diff --git a/package.json b/package.json index 6bf2def..ba1daad 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,11 @@ }, "scripts": {}, "dependencies": { - "@typescript-eslint/parser": "^2.34.0", + "@typescript-eslint/parser": "^3.0.0", "eslint-config-prettier": "^6.11.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": ">=2.34.0", + "@typescript-eslint/eslint-plugin": ">=3.0.0", "eslint": ">=7.0.0", "eslint-plugin-array-func": ">=3.1.5", "eslint-plugin-clean-code": ">=0.1.12", diff --git a/yarn.lock b/yarn.lock index f8a47be..5cfce1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,30 +12,30 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== -"@typescript-eslint/experimental-utils@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" - integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== +"@typescript-eslint/experimental-utils@3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.0.tgz#1ddf53eeb61ac8eaa9a77072722790ac4f641c03" + integrity sha512-BN0vmr9N79M9s2ctITtChRuP1+Dls0x/wlg0RXW1yQ7WJKPurg6X3Xirv61J2sjPif4F8SLsFMs5Nzte0WYoTQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.34.0" + "@typescript-eslint/typescript-estree" "3.0.0" eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@^2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" - integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== +"@typescript-eslint/parser@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.0.0.tgz#fe9fdf18a1155c02c04220c14506a320cb6c6944" + integrity sha512-8RRCA9KLxoFNO0mQlrLZA0reGPd/MsobxZS/yPFj+0/XgMdS8+mO8mF3BDj2ZYQj03rkayhSJtF1HAohQ3iylw== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.34.0" - "@typescript-eslint/typescript-estree" "2.34.0" + "@typescript-eslint/experimental-utils" "3.0.0" + "@typescript-eslint/typescript-estree" "3.0.0" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/typescript-estree@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" - integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== +"@typescript-eslint/typescript-estree@3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz#fa40e1b76ccff880130be054d9c398e96004bf42" + integrity sha512-nevQvHyNghsfLrrByzVIH4ZG3NROgJ8LZlfh3ddwPPH4CH7W4GAiSx5qu+xHuX5pWsq6q/eqMc1io840ZhAnUg== dependencies: debug "^4.1.1" eslint-visitor-keys "^1.1.0" From 30cded641cdf704de861992b42a9cf1b2dcb5f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Fri, 22 May 2020 15:39:29 +0200 Subject: [PATCH 02/24] Update naming-convention options --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5652a1f..4c82b11 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,19 @@ module.exports = { }, }, ], - "@typescript-eslint/naming-convention": "error", + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": ["PascalCase"], + "prefix": ["I"] + }, + { + "selector": "typeParameter", + "format": ["PascalCase"], + "prefix": ["T"] + }, + ], "@typescript-eslint/no-empty-function": [ "error", { From 2d5eb70609b26efab722fc843ae74a53f93868ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Fri, 22 May 2020 15:53:01 +0200 Subject: [PATCH 03/24] Lock peer dependencies --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index ba1daad..dbe5b0b 100644 --- a/package.json +++ b/package.json @@ -25,15 +25,15 @@ "eslint-config-prettier": "^6.11.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": ">=3.0.0", + "@typescript-eslint/eslint-plugin": "^3.0.0", "eslint": ">=7.0.0", - "eslint-plugin-array-func": ">=3.1.5", - "eslint-plugin-clean-code": ">=0.1.12", - "eslint-plugin-import": "=>2.20.2", - "eslint-plugin-jest": ">=23.9.0", - "eslint-plugin-no-loops": ">=0.3.0", - "eslint-plugin-prettier": ">=3.1.3", - "eslint-plugin-sonarjs": ">=0.5.0", + "eslint-plugin-array-func": "^3.1.6", + "eslint-plugin-clean-code": "^0.1.12", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-jest": "^23.13.1", + "eslint-plugin-no-loops": "^0.3.0", + "eslint-plugin-prettier": "^3.1.3", + "eslint-plugin-sonarjs": "^0.5.0", "prettier": ">=2.0.5", "typescript": ">=3.8" } From 52b1a6e7042625a1f85d82017a6700009a3d3dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Fri, 22 May 2020 15:54:52 +0200 Subject: [PATCH 04/24] Update README dependencies --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b10213d..0651c25 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Add `@deepcrawl/eslint-config` and its peer dependencies to your `package.json`: { "devDependencies": { "@deepcrawl/eslint-config": "^0.1.0", - "@typescript-eslint/eslint-plugin": "^2.34.0", + "@typescript-eslint/eslint-plugin": "^3.0.0", "eslint": "^7.0.0", - "eslint-plugin-array-func": "^3.1.5", + "eslint-plugin-array-func": "^3.1.6", "eslint-plugin-clean-code": "^0.1.12", "eslint-plugin-import": "^2.20.2", - "eslint-plugin-jest": "^23.9.0", + "eslint-plugin-jest": "^23.13.1", "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-sonarjs": "^0.5.0", From 8ef4cf66e3bdbd209e601dc5662fab6df7d99fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 08:10:28 +0200 Subject: [PATCH 05/24] Update with new defaults --- index.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4c82b11..9162f5b 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,60 @@ module.exports = { default: "array-simple", }, ], - "@typescript-eslint/ban-types": "error", + "@typescript-eslint/ban-types": [ + "error", + { + types: { + String: { + message: "Use string instead", + fixWith: "string", + }, + Boolean: { + message: "Use boolean instead", + fixWith: "boolean", + }, + Number: { + message: "Use number instead", + fixWith: "number", + }, + Symbol: { + message: "Use symbol instead", + fixWith: "symbol", + }, + + Function: { + message: [ + 'The `Function` type accepts any function-like value.', + 'It provides no type safety when calling the function, which can be a common source of bugs.', + 'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.', + 'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.', + ].join('\n'), + }, + + // object typing + Object: { + message: [ + 'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.', + '- If you want a type meaning "any object", you probably want `Record` instead.', + '- If you want a type meaning "any value", you probably want `unknown` instead.', + ].join('\n'), + }, + '{}': { + message: [ + '`{}` actually means "any non-nullish value".', + '- If you want a type meaning "any object", you probably want `Record` instead.', + '- If you want a type meaning "any value", you probably want `unknown` instead.', + ].join('\n'), + }, + object: { + message: [ + 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).', + 'Consider using `Record` instead, as it allows you to more easily inspect and use the keys.', + ].join('\n'), + }, + }, + }, + ], "@typescript-eslint/consistent-type-assertions": [ "error", { @@ -51,6 +104,7 @@ module.exports = { }, }, ], + "@typescript-eslint/member-delimiter-style": "error", "@typescript-eslint/naming-convention": [ "error", { @@ -77,7 +131,6 @@ module.exports = { ignoreRestArgs: true, }, ], - "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-inferrable-types": [ "error", { @@ -104,14 +157,14 @@ module.exports = { argsIgnorePattern: "^_", }, ], - "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-useless-constructor": "error", "@typescript-eslint/prefer-for-of": "error", "@typescript-eslint/prefer-function-type": "error", + "@typescript-eslint/prefer-includes": "error", "@typescript-eslint/prefer-nullish-coalescing": "error", "@typescript-eslint/prefer-optional-chain": "error", + "@typescript-eslint/prefer-string-starts-ends-with": "error", "@typescript-eslint/require-array-sort-compare": "error", - "@typescript-eslint/restrict-plus-operands": "error", "@typescript-eslint/return-await": "error", "@typescript-eslint/unified-signatures": "error", "array-func/avoid-reverse": "error", From 3de253598e6116ea0f94d4644f89853966dfc273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 08:17:43 +0200 Subject: [PATCH 06/24] Remove prettier redundant rules --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9162f5b..c078d54 100644 --- a/index.js +++ b/index.js @@ -104,7 +104,6 @@ module.exports = { }, }, ], - "@typescript-eslint/member-delimiter-style": "error", "@typescript-eslint/naming-convention": [ "error", { @@ -131,6 +130,7 @@ module.exports = { ignoreRestArgs: true, }, ], + "@typescript-eslint/no-extra-semi": "off", "@typescript-eslint/no-inferrable-types": [ "error", { From 5f4f3da24ca0935207a3c83d92a91743731e90be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 08:55:08 +0200 Subject: [PATCH 07/24] Disable broken rules --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c078d54..3176ad8 100644 --- a/index.js +++ b/index.js @@ -71,12 +71,6 @@ module.exports = { '- If you want a type meaning "any value", you probably want `unknown` instead.', ].join('\n'), }, - object: { - message: [ - 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).', - 'Consider using `Record` instead, as it allows you to more easily inspect and use the keys.', - ].join('\n'), - }, }, }, ], @@ -151,6 +145,10 @@ module.exports = { }, ], "@typescript-eslint/no-unnecessary-type-arguments": "error", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", "@typescript-eslint/no-unused-vars": [ "error", { From 011515b71f155b17e50a5dd705285d38d403fccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 09:07:38 +0200 Subject: [PATCH 08/24] Disable broken rule --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 3176ad8..231ba95 100644 --- a/index.js +++ b/index.js @@ -163,6 +163,7 @@ module.exports = { "@typescript-eslint/prefer-optional-chain": "error", "@typescript-eslint/prefer-string-starts-ends-with": "error", "@typescript-eslint/require-array-sort-compare": "error", + "@typescript-eslint/restrict-template-expressions": "off", "@typescript-eslint/return-await": "error", "@typescript-eslint/unified-signatures": "error", "array-func/avoid-reverse": "error", From deb9f63b364c29f6a200442dc16005161cf2b507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 09:14:00 +0200 Subject: [PATCH 09/24] Fix ban-types options --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 231ba95..9718ceb 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ module.exports = { "@typescript-eslint/ban-types": [ "error", { + extendDefaults: false, types: { String: { message: "Use string instead", From 5ddec5812f8b66bade6d9f0e8b60c65fd4afc076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 09:32:10 +0200 Subject: [PATCH 10/24] Disable redundant rule --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 9718ceb..6026277 100644 --- a/index.js +++ b/index.js @@ -99,6 +99,7 @@ module.exports = { }, }, ], + "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/naming-convention": [ "error", { From cfc19388a47e271b4cf8b738432be02b3e6b1c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 09:47:27 +0200 Subject: [PATCH 11/24] Update ban-types --- index.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/index.js b/index.js index 6026277..d0463ec 100644 --- a/index.js +++ b/index.js @@ -48,15 +48,6 @@ module.exports = { fixWith: "symbol", }, - Function: { - message: [ - 'The `Function` type accepts any function-like value.', - 'It provides no type safety when calling the function, which can be a common source of bugs.', - 'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.', - 'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.', - ].join('\n'), - }, - // object typing Object: { message: [ From 80985f032c1f60bf49085ed929e917e6e7c23745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 10:38:40 +0200 Subject: [PATCH 12/24] Fix naming convention --- index.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d0463ec..44eebfa 100644 --- a/index.js +++ b/index.js @@ -94,14 +94,30 @@ module.exports = { "@typescript-eslint/naming-convention": [ "error", { - "selector": "interface", - "format": ["PascalCase"], - "prefix": ["I"] + selector: "default", + format: ["camelCase"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", }, { - "selector": "typeParameter", - "format": ["PascalCase"], - "prefix": ["T"] + selector: "variable", + format: ["camelCase", "UPPER_CASE"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + { + selector: "typeLike", + format: ["PascalCase"], + }, + { + selector: "interface", + format: ["PascalCase"], + prefix: ["I"] + }, + { + selector: "typeParameter", + format: ["PascalCase"], + prefix: ["T"] }, ], "@typescript-eslint/no-empty-function": [ From ef5991bb10d33acc73688e418c2ba787c20defa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 10:47:32 +0200 Subject: [PATCH 13/24] Update naming convention --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 44eebfa..77056d8 100644 --- a/index.js +++ b/index.js @@ -105,6 +105,12 @@ module.exports = { leadingUnderscore: "allow", trailingUnderscore: "allow", }, + { + selector: "property", + format: ["camelCase", "UPPER_CASE"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, { selector: "typeLike", format: ["PascalCase"], From f3c1617a917f9c5f29afd2e08ee023d48b91a864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 10:51:34 +0200 Subject: [PATCH 14/24] Fix naming convention --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 77056d8..5b6d9c3 100644 --- a/index.js +++ b/index.js @@ -110,6 +110,10 @@ module.exports = { format: ["camelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", + "filter": { + "regex": "[- ]", + "match": false, + }, }, { selector: "typeLike", From 630daa2adb29cf110aa55d354dd046c1ea1b8748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:00:36 +0200 Subject: [PATCH 15/24] Update naming convention --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5b6d9c3..9e9a639 100644 --- a/index.js +++ b/index.js @@ -110,11 +110,15 @@ module.exports = { format: ["camelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", - "filter": { - "regex": "[- ]", - "match": false, + filter: { + regex: "[- ]", + match: false, }, }, + { + selector: "enumMember", + format: ["PascalCase"], + }, { selector: "typeLike", format: ["PascalCase"], From ad5623f3450def8e9e43331dd41a8487e5ea4e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:06:17 +0200 Subject: [PATCH 16/24] Update naming --- index.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/index.js b/index.js index 9e9a639..78f2e03 100644 --- a/index.js +++ b/index.js @@ -93,12 +93,6 @@ module.exports = { "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/naming-convention": [ "error", - { - selector: "default", - format: ["camelCase"], - leadingUnderscore: "allow", - trailingUnderscore: "allow", - }, { selector: "variable", format: ["camelCase", "UPPER_CASE"], From 8efc81e1568c86fcd619ef81674c2ad2a6f5990c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:14:18 +0200 Subject: [PATCH 17/24] Update naming --- index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 78f2e03..229447c 100644 --- a/index.js +++ b/index.js @@ -93,6 +93,10 @@ module.exports = { "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/naming-convention": [ "error", + { + selector: "default", + format: ["camelCase"], + }, { selector: "variable", format: ["camelCase", "UPPER_CASE"], @@ -101,12 +105,16 @@ module.exports = { }, { selector: "property", - format: ["camelCase", "UPPER_CASE"], + format: ["camelCase", "PascalCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", + }, + { + selector: "property", + format: null, filter: { - regex: "[- ]", - match: false, + regex: "[- :]", + match: true, }, }, { From 5417db57bbd245a4e4a4f2a340e5a6f4de8cc1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:14:52 +0200 Subject: [PATCH 18/24] Fix --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 229447c..aa676ad 100644 --- a/index.js +++ b/index.js @@ -96,6 +96,8 @@ module.exports = { { selector: "default", format: ["camelCase"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", }, { selector: "variable", From b9dfb7562acf512b4fb7058170595979b73791db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:34:12 +0200 Subject: [PATCH 19/24] Fix --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index aa676ad..522fb5b 100644 --- a/index.js +++ b/index.js @@ -121,7 +121,7 @@ module.exports = { }, { selector: "enumMember", - format: ["PascalCase"], + format: ["camelCase", "PascalCase"], }, { selector: "typeLike", From db4c56f811ba23f668320bb55e99b9ae79038bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 11:40:17 +0200 Subject: [PATCH 20/24] Fix --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 522fb5b..f6f27a4 100644 --- a/index.js +++ b/index.js @@ -101,7 +101,7 @@ module.exports = { }, { selector: "variable", - format: ["camelCase", "UPPER_CASE"], + format: ["camelCase", "PascalCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", }, From 7ffa3452503aadd4793dd2bdfe148e00f29e3d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 12:46:40 +0200 Subject: [PATCH 21/24] Add function --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index f6f27a4..de9fe15 100644 --- a/index.js +++ b/index.js @@ -105,6 +105,10 @@ module.exports = { leadingUnderscore: "allow", trailingUnderscore: "allow", }, + { + selector: "function", + format: ["camelCase", "PascalCase"], + }, { selector: "property", format: ["camelCase", "PascalCase", "UPPER_CASE"], From 2bb3a19b7a372ba49076086199e79c19e837c57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 13:38:54 +0200 Subject: [PATCH 22/24] feat!: Remove eslint-plugin-prettier --- README.md | 4 +--- index.js | 20 +------------------- package.json | 2 -- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0651c25..73b9474 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@ Add `@deepcrawl/eslint-config` and its peer dependencies to your `package.json`: "eslint-plugin-import": "^2.20.2", "eslint-plugin-jest": "^23.13.1", "eslint-plugin-no-loops": "^0.3.0", - "eslint-plugin-prettier": "^3.1.3", - "eslint-plugin-sonarjs": "^0.5.0", - "prettier": "^2.0.5" + "eslint-plugin-sonarjs": "^0.5.0" } } ``` diff --git a/index.js b/index.js index de9fe15..a66631b 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ module.exports = { "plugin:eslint-plugin-import/recommended", "plugin:eslint-plugin-import/typescript", "plugin:eslint-plugin-jest/recommended", - "plugin:prettier/recommended", + "eslint-config-prettier", "prettier/@typescript-eslint", ], parser: "@typescript-eslint/parser", @@ -17,7 +17,6 @@ module.exports = { "eslint-plugin-no-loops", "eslint-plugin-jest", "eslint-plugin-sonarjs", - "prettier", ], rules: { "@typescript-eslint/array-type": [ @@ -155,7 +154,6 @@ module.exports = { ignoreRestArgs: true, }, ], - "@typescript-eslint/no-extra-semi": "off", "@typescript-eslint/no-inferrable-types": [ "error", { @@ -221,22 +219,6 @@ module.exports = { ], "jest/expect-expect": "error", "no-loops/no-loops": "error", - "prettier/prettier": [ - "error", - { - arrowParens: "avoid", - bracketSpacing: true, - printWidth: 120, - semi: true, - singleQuote: false, - tabWidth: 2, - trailingComma: "all", - useTabs: false, - }, - { - usePrettierrc: false, - }, - ], "sonarjs/cognitive-complexity": ["error", 8], "sonarjs/max-switch-cases": "error", "sonarjs/no-all-duplicated-branches": "error", diff --git a/package.json b/package.json index dbe5b0b..21b18af 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,7 @@ "eslint-plugin-import": "^2.20.2", "eslint-plugin-jest": "^23.13.1", "eslint-plugin-no-loops": "^0.3.0", - "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-sonarjs": "^0.5.0", - "prettier": ">=2.0.5", "typescript": ">=3.8" } } From 4a58f9a22d9b807f7d563dbec909f806ffda0080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 13:44:51 +0200 Subject: [PATCH 23/24] Update README --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 73b9474..961993e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Update your `.eslintrc` configuration: ## Recommendations +### TypeScript + Have these options enabled in your `tsconfig.json` file: ```json @@ -46,3 +48,22 @@ Have these options enabled in your `tsconfig.json` file: ``` or enable `@typescript-eslint/typedef` rule. + +### Prettier + +Apart from ESLint, it is recommended to use the following Prettier configuration: + +```json +{ + "arrowParens": "avoid", + "bracketSpacing": true, + "endOfLine": "lf", + "printWidth": 120, + "quoteProps": "as-needed", + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false +} +``` From 06f7ea0ba1bed8108b65b9cf263150dc092d6e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Kie=C5=82tyka?= Date: Mon, 25 May 2020 13:48:21 +0200 Subject: [PATCH 24/24] README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 961993e..26cff6e 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,5 @@ Apart from ESLint, it is recommended to use the following Prettier configuration "useTabs": false } ``` + +with `lint-staged` pre-commit hook done via `husky`.