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", diff --git a/index.js b/index.js index 5d1a471..de9fe15 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", @@ -30,11 +29,40 @@ module.exports = { "@typescript-eslint/ban-types": [ "error", { + extendDefaults: false, 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`?", + 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", + }, + + // 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'), + }, }, }, ], @@ -62,9 +90,58 @@ 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/explicit-module-boundary-types": "off", + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "default", + format: ["camelCase"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + { + selector: "variable", + format: ["camelCase", "PascalCase", "UPPER_CASE"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + { + selector: "function", + format: ["camelCase", "PascalCase"], + }, + { + selector: "property", + format: ["camelCase", "PascalCase", "UPPER_CASE"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + { + selector: "property", + format: null, + filter: { + regex: "[- :]", + match: true, + }, + }, + { + selector: "enumMember", + format: ["camelCase", "PascalCase"], + }, + { + selector: "typeLike", + format: ["PascalCase"], + }, + { + selector: "interface", + format: ["PascalCase"], + prefix: ["I"] + }, + { + selector: "typeParameter", + format: ["PascalCase"], + prefix: ["T"] + }, + ], "@typescript-eslint/no-empty-function": [ "error", { @@ -78,7 +155,7 @@ module.exports = { ignoreRestArgs: true, }, ], - "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-extra-semi": "off", "@typescript-eslint/no-inferrable-types": [ "error", { @@ -99,20 +176,25 @@ 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", { 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/restrict-template-expressions": "off", "@typescript-eslint/return-await": "error", "@typescript-eslint/unified-signatures": "error", "array-func/avoid-reverse": "error", diff --git a/package.json b/package.json index 6bf2def..dbe5b0b 100644 --- a/package.json +++ b/package.json @@ -21,19 +21,19 @@ }, "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", - "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" } 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"