From 2254984eeceed657f50be6031087c7332481280c Mon Sep 17 00:00:00 2001 From: Samuel Hobl Date: Tue, 23 Feb 2021 11:46:40 +0100 Subject: [PATCH] chore(deps): update eslint related packages During this process i encountered an issue about conflicts between eslint core rules and typescript-eslint rules. For this to work the extension rules from typescript-eslint must be turned off in eslint core (TIL). https://github.com/typescript-eslint/typescript-eslint/issues/2540 --- .eslintrc.js | 7 +- package.json | 4 +- packages/interpolate/src/interpolate.ts | 5 +- packages/quark/src/Slots.tsx | 3 +- packages/quark/src/test/index.test.tsx | 2 +- packages/quark/src/utils.ts | 2 +- packages/utils/src/types.ts | 4 +- playground/package.json | 1 + yarn.lock | 86 ++++++++++++++++++++++--- 9 files changed, 96 insertions(+), 18 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 08e7550..6751b75 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,9 +22,12 @@ module.exports = { // Custom preferences 'import/prefer-default-export': 'off', - 'no-use-before-define': ['error', { functions: false }], - 'no-underscore-dangle': ['error', { allow: ['_css'] }], + + // adjustments for ts extension rules + 'no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': ['error', { functions: false }], + + 'no-underscore-dangle': ['error', { allow: ['_css'] }], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/naming-convention': 'off', diff --git a/package.json b/package.json index 4c8c58c..86cf4d7 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "@commitlint/config-conventional": "^11.0.0", "@types/jest": "^25.2.3", "@types/react-test-renderer": "^17.0.0", - "@typescript-eslint/eslint-plugin": "^3.4.0", - "@typescript-eslint/parser": "^3.4.0", + "@typescript-eslint/eslint-plugin": "^4.15.2", + "@typescript-eslint/parser": "^4.15.2", "eslint": "^7.0.0", "eslint-config-airbnb-typescript": "^8.0.2", "eslint-config-prettier": "^6.11.0", diff --git a/packages/interpolate/src/interpolate.ts b/packages/interpolate/src/interpolate.ts index 3e4d6d9..4956016 100644 --- a/packages/interpolate/src/interpolate.ts +++ b/packages/interpolate/src/interpolate.ts @@ -4,7 +4,8 @@ import { ThemeOrAny } from '@gumption-ui/interpolate/theme'; import { get, isFunction, - FirstParameters, + FirstParameter, + ParameterTypes, LiteralUnion, ValueOf, ResponsiveStyleValue, @@ -13,7 +14,7 @@ import { Shorthands, Aliases, Matchers, CSSProperties } from './types'; export type Theme = Partial; -type ScopedCSSRules = FirstParameters; +type ScopedCSSRules = FirstParameter; type ScopedCSSProperties = Omit; type ResolveShorthand = ValueOf< diff --git a/packages/quark/src/Slots.tsx b/packages/quark/src/Slots.tsx index d5d3427..7cf84d1 100644 --- a/packages/quark/src/Slots.tsx +++ b/packages/quark/src/Slots.tsx @@ -47,7 +47,8 @@ export function SlotProvider({ slots: Slots; children: React.ReactNode; }) { - const parentSlots = React.useContext(SlotContext) || {}; + // parentSlots is always the memoized `value`, therefore won't trigger unnecessary re-renders. + const parentSlots = React.useContext(SlotContext) || {}; // eslint-disable-line react-hooks/exhaustive-deps const value = React.useMemo(() => { return Object.keys(parentSlots) .concat(Object.keys(slots)) diff --git a/packages/quark/src/test/index.test.tsx b/packages/quark/src/test/index.test.tsx index 92c3a37..4fa4611 100644 --- a/packages/quark/src/test/index.test.tsx +++ b/packages/quark/src/test/index.test.tsx @@ -23,7 +23,7 @@ const theme = { const customRender = (element: React.ReactElement, options?: RenderOptions) => render(element, { - wrapper: ({ children }: { children?: React.ReactNode }) => ( + wrapper: ({ children }) => ( {children} ), ...options, diff --git a/packages/quark/src/utils.ts b/packages/quark/src/utils.ts index 0b8e56b..80e78d2 100644 --- a/packages/quark/src/utils.ts +++ b/packages/quark/src/utils.ts @@ -87,7 +87,7 @@ export const domElements = [ export type DOMElements = UnionStringArray; export function runIfFn( - valueOrFn: T | ((...args: U[]) => T), + valueOrFn: T | ((..._args: U[]) => T), ...args: U[] ): T { return isFunction(valueOrFn) ? valueOrFn(...args) : valueOrFn; diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts index 513a301..541a1b9 100644 --- a/packages/utils/src/types.ts +++ b/packages/utils/src/types.ts @@ -4,7 +4,9 @@ import { LiteralUnion, ValueOf } from 'type-fest'; export type Dict = Record; -export type FirstParameters = T extends (arg: infer T) => any ? T : never; +export type FirstParameter = F extends (arg: infer T) => any ? T : never; + +export type ParameterTypes = F extends (...args: infer A) => any ? A : never; export type UnionStringArray> = T[number]; diff --git a/playground/package.json b/playground/package.json index 937fdb2..f190c01 100644 --- a/playground/package.json +++ b/playground/package.json @@ -21,6 +21,7 @@ }, "dependencies": { "destyle.css": "^1.0.13", + "react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "^4.0.2" }, diff --git a/yarn.lock b/yarn.lock index 154aade..c8abcd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -937,14 +937,16 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^3.4.0": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz#7e061338a1383f59edc204c605899f93dc2e2c8f" - integrity sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ== +"@typescript-eslint/eslint-plugin@^4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.2.tgz#981b26b4076c62a5a55873fbef3fe98f83360c61" + integrity sha512-uiQQeu9tWl3f1+oK0yoAv9lt/KXO24iafxgQTkIYO/kitruILGx3uH+QtIAHqxFV+yIsdnJH+alel9KuE3J15Q== dependencies: - "@typescript-eslint/experimental-utils" "3.10.1" + "@typescript-eslint/experimental-utils" "4.15.2" + "@typescript-eslint/scope-manager" "4.15.2" debug "^4.1.1" functional-red-black-tree "^1.0.1" + lodash "^4.17.15" regexpp "^3.0.0" semver "^7.3.2" tsutils "^3.17.1" @@ -960,7 +962,19 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@^3.1.0", "@typescript-eslint/parser@^3.4.0": +"@typescript-eslint/experimental-utils@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.2.tgz#5efd12355bd5b535e1831282e6cf465b9a71cf36" + integrity sha512-Fxoshw8+R5X3/Vmqwsjc8nRO/7iTysRtDqx6rlfLZ7HbT8TZhPeQqbPjTyk2RheH3L8afumecTQnUc9EeXxohQ== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/scope-manager" "4.15.2" + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/typescript-estree" "4.15.2" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + +"@typescript-eslint/parser@^3.1.0": version "3.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467" integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw== @@ -971,11 +985,34 @@ "@typescript-eslint/typescript-estree" "3.10.1" eslint-visitor-keys "^1.1.0" +"@typescript-eslint/parser@^4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.2.tgz#c804474321ef76a3955aec03664808f0d6e7872e" + integrity sha512-SHeF8xbsC6z2FKXsaTb1tBCf0QZsjJ94H6Bo51Y1aVEZ4XAefaw5ZAilMoDPlGghe+qtq7XdTiDlGfVTOmvA+Q== + dependencies: + "@typescript-eslint/scope-manager" "4.15.2" + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/typescript-estree" "4.15.2" + debug "^4.1.1" + +"@typescript-eslint/scope-manager@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.2.tgz#5725bda656995960ae1d004bfd1cd70320f37f4f" + integrity sha512-Zm0tf/MSKuX6aeJmuXexgdVyxT9/oJJhaCkijv0DvJVT3ui4zY6XYd6iwIo/8GEZGy43cd7w1rFMiCLHbRzAPQ== + dependencies: + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/visitor-keys" "4.15.2" + "@typescript-eslint/types@3.10.1": version "3.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== +"@typescript-eslint/types@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.2.tgz#04acf3a2dc8001a88985291744241e732ef22c60" + integrity sha512-r7lW7HFkAarfUylJ2tKndyO9njwSyoy6cpfDKWPX6/ctZA+QyaYscAHXVAfJqtnY6aaTwDYrOhp+ginlbc7HfQ== + "@typescript-eslint/typescript-estree@3.10.1": version "3.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853" @@ -990,6 +1027,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.2.tgz#c2f7a1e94f3428d229d5ecff3ead6581ee9b62fa" + integrity sha512-cGR8C2g5SPtHTQvAymEODeqx90pJHadWsgTtx6GbnTWKqsg7yp6Eaya9nFzUd4KrKhxdYTTFBiYeTPQaz/l8bw== + dependencies: + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/visitor-keys" "4.15.2" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@3.10.1": version "3.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931" @@ -997,6 +1047,14 @@ dependencies: eslint-visitor-keys "^1.1.0" +"@typescript-eslint/visitor-keys@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.2.tgz#3d1c7979ce75bf6acf9691109bd0d6b5706192b9" + integrity sha512-TME1VgSb7wTwgENN5KVj4Nqg25hP8DisXxNBojM4Nn31rYaNDIocNm5cmjOFfh42n7NVERxWrDFoETO/76ePyg== + dependencies: + "@typescript-eslint/types" "4.15.2" + eslint-visitor-keys "^2.0.0" + JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2483,7 +2541,7 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.0.3: +fast-glob@^3.0.3, fast-glob@^3.1.1: version "3.2.5" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661" integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg== @@ -2787,6 +2845,18 @@ globby@10.0.0: merge2 "^1.2.3" slash "^3.0.0" +globby@^11.0.1: + version "11.0.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.2.tgz#1af538b766a3b540ebfb58a32b2e2d5897321d83" + integrity sha512-2ZThXDvvV8fYFRVIxnrMQBipZQDr7MxKAmQK1vujaj9/7eF0efG7BPUKJ7jP7G5SLF37xKDXvO4S/KKLj/Z0og== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.1.1" + ignore "^5.1.4" + merge2 "^1.3.0" + slash "^3.0.0" + got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" @@ -2962,7 +3032,7 @@ ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.1.1: +ignore@^5.1.1, ignore@^5.1.4: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==