From 779ed4cda7ec08a3b0ac9a28931b4ddd21872881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Zl=C3=A1mal?= Date: Fri, 4 Nov 2022 17:04:44 -0600 Subject: [PATCH] Flow: upgrade to version 0.191.0 --- package.json | 2 +- src/abacus-backoffice/src/d3/BarChart.js | 2 +- .../src/pos/ProductsGridCategories.js | 2 +- .../src/products/ProductsEditLayout.js | 2 +- src/abacus-docs/components/Shell/ThemeToggle.js | 2 +- .../valid-eslint-examples/react/jsx-no-bind.js | 2 +- .../src/changeNextVersionErrorLevel.js | 9 +++++++++ src/eslint-plugin-sx/src/getRules.js | 2 +- src/flow-config-parser/src/parse.js | 3 +++ src/forms/src/FormRoot.js | 5 ++++- src/relay/src/RelayRehydratePreloadedQueries.js | 3 +++ .../internal/__tests__/helpers.getRequestBody.test.js | 2 +- src/sx-design/src/Skeleton/Skeleton.js | 2 +- src/sx-design/src/Tabs/__tests__/Tabs.test.js | 2 +- src/sx/src/create.js | 2 +- src/sx/src/css-properties/isUnitlessNumber.js | 3 +++ yarn.lock | 10 +++++----- 17 files changed, 38 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index b376dfe272..b39a1ee8fe 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "babel-loader": "^8.3.0", "eslint": "^8.26.0", "eslint-formatter-codeframe": "^7.32.1", - "flow-bin": "^0.189.0", + "flow-bin": "^0.191.0", "glob": "^8.0.3", "hermes-eslint": "^0.9.0", "jest": "^29.2.2", diff --git a/src/abacus-backoffice/src/d3/BarChart.js b/src/abacus-backoffice/src/d3/BarChart.js index 0c93e17e47..ef65ff24ee 100644 --- a/src/abacus-backoffice/src/d3/BarChart.js +++ b/src/abacus-backoffice/src/d3/BarChart.js @@ -11,7 +11,7 @@ type Props = { export default function BarChart(props: Props): Node { const svg = React.useRef(null); - const [width, setWidth] = useState(null); + const [width, setWidth] = useState(null); React.useEffect(() => { if (width != null) { diff --git a/src/abacus-backoffice/src/pos/ProductsGridCategories.js b/src/abacus-backoffice/src/pos/ProductsGridCategories.js index 31e895c89f..42f48d8b82 100644 --- a/src/abacus-backoffice/src/pos/ProductsGridCategories.js +++ b/src/abacus-backoffice/src/pos/ProductsGridCategories.js @@ -14,7 +14,7 @@ import ProductsGrid from './ProductsGrid'; * for the first category (or for the selected category). */ export default function ProductsGridCategories(): Node { - const [selectedCategory, setSelectedCategory] = useState(null); + const [selectedCategory, setSelectedCategory] = useState(null); const applicationLocale = useApplicationLocale(); // eslint-disable-next-line relay/generated-flow-types -- https://github.com/relayjs/eslint-plugin-relay/issues/131 diff --git a/src/abacus-backoffice/src/products/ProductsEditLayout.js b/src/abacus-backoffice/src/products/ProductsEditLayout.js index ab36cc3e3e..00c7e0705f 100644 --- a/src/abacus-backoffice/src/products/ProductsEditLayout.js +++ b/src/abacus-backoffice/src/products/ProductsEditLayout.js @@ -16,7 +16,7 @@ type Props = { export default function ProductsEditLayout(props: Props): Node { const applicationLocale = useApplicationLocale(); - const [imagesToDelete, setImagesToDelete] = useState([]); + const [imagesToDelete, setImagesToDelete] = useState>([]); // eslint-disable-next-line relay/generated-flow-types -- https://github.com/relayjs/eslint-plugin-relay/issues/131 const data = useLazyLoadQuery( diff --git a/src/abacus-docs/components/Shell/ThemeToggle.js b/src/abacus-docs/components/Shell/ThemeToggle.js index 92702b7736..98c32f4c4b 100644 --- a/src/abacus-docs/components/Shell/ThemeToggle.js +++ b/src/abacus-docs/components/Shell/ThemeToggle.js @@ -86,7 +86,7 @@ const moon = ( ); export function ThemeToggle(): Node { - const [theme, setTheme] = React.useState(undefined); + const [theme, setTheme] = React.useState(undefined); const [, setHovering] = React.useState(false); function setPreferredTheme(newTheme: string) { diff --git a/src/eslint-config-adeira/__tests__/__fixtures__/valid-eslint-examples/react/jsx-no-bind.js b/src/eslint-config-adeira/__tests__/__fixtures__/valid-eslint-examples/react/jsx-no-bind.js index 2b6b48e15c..1a4cbf04ee 100644 --- a/src/eslint-config-adeira/__tests__/__fixtures__/valid-eslint-examples/react/jsx-no-bind.js +++ b/src/eslint-config-adeira/__tests__/__fixtures__/valid-eslint-examples/react/jsx-no-bind.js @@ -62,7 +62,7 @@ export class Alphabet1 extends Component { } export function Alphabet2(): Element<'div'> { - const [justClicked, updateJustClicked] = useState(null); + const [justClicked, updateJustClicked] = useState(null); const letters = Array.from({ length: 26 }, (_, i) => String.fromCharCode(A + i)); const handleClick = (letter: string) => { diff --git a/src/eslint-config-adeira/src/changeNextVersionErrorLevel.js b/src/eslint-config-adeira/src/changeNextVersionErrorLevel.js index 5b5bc803ff..c9cf126c9f 100644 --- a/src/eslint-config-adeira/src/changeNextVersionErrorLevel.js +++ b/src/eslint-config-adeira/src/changeNextVersionErrorLevel.js @@ -13,10 +13,19 @@ module.exports = function changeNextVersionErrorLevel( return Object.entries(config).reduce((acc, [ruleName, value]) => { if (Array.isArray(value) && value[0] === 3) { const [, ...config] = value; + /* $FlowFixMe[prop-missing] This comment suppresses an error when + * upgrading Flow to version 0.191.0. To see the error delete this + * comment and run Flow. */ acc[ruleName] = [level, ...config]; } else if (value === 3) { + /* $FlowFixMe[prop-missing] This comment suppresses an error when + * upgrading Flow to version 0.191.0. To see the error delete this + * comment and run Flow. */ acc[ruleName] = level; } else { + /* $FlowFixMe[prop-missing] This comment suppresses an error when + * upgrading Flow to version 0.191.0. To see the error delete this + * comment and run Flow. */ acc[ruleName] = value; } return acc; diff --git a/src/eslint-plugin-sx/src/getRules.js b/src/eslint-plugin-sx/src/getRules.js index aa751ff6d4..1b1f4b3c64 100644 --- a/src/eslint-plugin-sx/src/getRules.js +++ b/src/eslint-plugin-sx/src/getRules.js @@ -8,7 +8,7 @@ const DEFAULT_RULES_PATH = path.join(__dirname, 'rules'); module.exports = function getRules( rulesPath /*: string */ = DEFAULT_RULES_PATH, ) /*: { +[ruleName: string]: string } */ { - const rules = {}; + const rules /*: { [string]: $FlowFixMe } */ = {}; for (const dirent of fs.readdirSync(rulesPath, { encoding: 'utf8', withFileTypes: true, diff --git a/src/flow-config-parser/src/parse.js b/src/flow-config-parser/src/parse.js index 155c7bd5a8..820e5fd46c 100644 --- a/src/flow-config-parser/src/parse.js +++ b/src/flow-config-parser/src/parse.js @@ -56,6 +56,9 @@ export default function parse(input: string): ParsedConfig { const rawValue = keyValueMatch.groups?.rawValue; const key = rawKey?.trim(); if (parsedConfig[currentSection] === null) { + /* $FlowFixMe[prop-missing] This comment suppresses an error when + * upgrading Flow to version 0.191.0. To see the error delete this + * comment and run Flow. */ parsedConfig[currentSection] = {}; } if (KNOWN_LIST_OPTIONS.includes(key)) { diff --git a/src/forms/src/FormRoot.js b/src/forms/src/FormRoot.js index 58f54a2fff..e4b8b3c0b2 100644 --- a/src/forms/src/FormRoot.js +++ b/src/forms/src/FormRoot.js @@ -72,6 +72,9 @@ export default function FormRoot(props: Props): React.Element<'form'> { formFields: { ...prevState.formFields, [inputName]: { + /* $FlowFixMe[incompatible-type] This comment suppresses an + * error when upgrading Flow to version 0.191.0. To see the + * error delete this comment and run Flow. */ ...prevState.formFields[inputName], inputValue, validationError, @@ -82,7 +85,7 @@ export default function FormRoot(props: Props): React.Element<'form'> { }, unmaskFormFieldErrors: () => { setContextState((prevState) => { - const formFields = {}; + const formFields: { [empty]: any } = {}; Object.keys(prevState.formFields).forEach((inputName) => { formFields[inputName] = { ...prevState.formFields[inputName], diff --git a/src/relay/src/RelayRehydratePreloadedQueries.js b/src/relay/src/RelayRehydratePreloadedQueries.js index f0cd59f75f..8354095caa 100644 --- a/src/relay/src/RelayRehydratePreloadedQueries.js +++ b/src/relay/src/RelayRehydratePreloadedQueries.js @@ -70,6 +70,9 @@ export default function RelayRehydratePreloadedQueries({ Component, pageProps }: // $FlowFixMe[prop-missing]: property responseCache is missing in INetwork environment.getNetwork().responseCache.set(params.cacheID, variables, response); + /* $FlowFixMe[prop-missing] This comment suppresses an error when + * upgrading Flow to version 0.191.0. To see the error delete this + * comment and run Flow. */ relayPreloadedQueryRefs[queryName] = { environment, fetchKey: params.id, diff --git a/src/relay/src/internal/__tests__/helpers.getRequestBody.test.js b/src/relay/src/internal/__tests__/helpers.getRequestBody.test.js index 1e72c353af..9754a3e119 100644 --- a/src/relay/src/internal/__tests__/helpers.getRequestBody.test.js +++ b/src/relay/src/internal/__tests__/helpers.getRequestBody.test.js @@ -28,7 +28,7 @@ it('returns request body without uploadables - persistent queries', () => { }); function serializeFormData(formData: FormData) { - const object = {}; + const object: { [string]: FormDataEntryValue } = {}; for (const [key, value] of formData.entries()) { object[key] = value; } diff --git a/src/sx-design/src/Skeleton/Skeleton.js b/src/sx-design/src/Skeleton/Skeleton.js index 5a91690813..986b0e6e35 100644 --- a/src/sx-design/src/Skeleton/Skeleton.js +++ b/src/sx-design/src/Skeleton/Skeleton.js @@ -19,7 +19,7 @@ type Props = { */ export default function Skeleton(props: Props): Node { const childrenRef = useRef(null); - const [childrenRect, setChildrenRect] = useState(null); + const [childrenRect, setChildrenRect] = useState(null); if (props.show != null) { // Property `show` makes only sense when there is a children. It's commonly used for hiding the diff --git a/src/sx-design/src/Tabs/__tests__/Tabs.test.js b/src/sx-design/src/Tabs/__tests__/Tabs.test.js index d78de425ee..9bf3466829 100644 --- a/src/sx-design/src/Tabs/__tests__/Tabs.test.js +++ b/src/sx-design/src/Tabs/__tests__/Tabs.test.js @@ -53,7 +53,7 @@ function TestComponentFruits() { } function TestComponentNumbers() { - const [selected, setSelected] = useState(null); + const [selected, setSelected] = useState(null); return ( (sheetDefinitions: T): Create ); } - const selectedStyles = {}; + const selectedStyles: { [string]: void | string } = {}; for (const sheetDefinitionName of sheetDefinitionNames) { if (sheetDefinitionName != null && sheetDefinitionName !== false) { invariant( diff --git a/src/sx/src/css-properties/isUnitlessNumber.js b/src/sx/src/css-properties/isUnitlessNumber.js index f2919d21d8..b8266bda7f 100644 --- a/src/sx/src/css-properties/isUnitlessNumber.js +++ b/src/sx/src/css-properties/isUnitlessNumber.js @@ -58,6 +58,9 @@ function prefixKey(prefix: string, key: string) { const prefixes = ['webkit']; Object.keys(isUnitlessNumber).forEach(function (prop) { prefixes.forEach(function (prefix) { + /* $FlowFixMe[prop-missing] This comment suppresses an error when upgrading + * Flow to version 0.191.0. To see the error delete this comment and run + * Flow. */ isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; }); }); diff --git a/yarn.lock b/yarn.lock index f07dc94ab5..9b79f042cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10386,12 +10386,12 @@ __metadata: languageName: node linkType: hard -"flow-bin@npm:^0.189.0": - version: 0.189.0 - resolution: "flow-bin@npm:0.189.0" +"flow-bin@npm:^0.191.0": + version: 0.191.0 + resolution: "flow-bin@npm:0.191.0" bin: flow: cli.js - checksum: 85202fd7f4c7c4401f66b36b32589e7a7d67ab2646411f934c7799d09813dc17608f2d80bbd95125c1c274b13075bea94337e0672a73dfb581fde89e43c8a2a4 + checksum: 84b3ba07521c2253d069e090fb3a076371ee4926b78bdbc241a32ed725a1bf19656ed9831367c1e8f93884f893548649cd069bd3d6f4f08523b5fa97bf1e0b96 languageName: node linkType: hard @@ -17333,7 +17333,7 @@ __metadata: babel-loader: ^8.3.0 eslint: ^8.26.0 eslint-formatter-codeframe: ^7.32.1 - flow-bin: ^0.189.0 + flow-bin: ^0.191.0 glob: ^8.0.3 hermes-eslint: ^0.9.0 jest: ^29.2.2