From 68f05923e0e55128787fd2f29c35f7ce507c08a9 Mon Sep 17 00:00:00 2001 From: Sahejkm <163521239+Sahejkm@users.noreply.github.com> Date: Sat, 18 May 2024 00:45:10 +0800 Subject: [PATCH] [Lexical] Add flow for eslint (#6127) --- .../flow/LexicalEslintPlugin.js.flow | 1 + scripts/update-flowconfig.js | 20 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/packages/lexical-eslint-plugin/flow/LexicalEslintPlugin.js.flow b/packages/lexical-eslint-plugin/flow/LexicalEslintPlugin.js.flow index 3b23ff98ce6..55f418a0d83 100644 --- a/packages/lexical-eslint-plugin/flow/LexicalEslintPlugin.js.flow +++ b/packages/lexical-eslint-plugin/flow/LexicalEslintPlugin.js.flow @@ -4,6 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict */ /** diff --git a/scripts/update-flowconfig.js b/scripts/update-flowconfig.js index be35f36d393..81c82d4c6c6 100644 --- a/scripts/update-flowconfig.js +++ b/scripts/update-flowconfig.js @@ -23,7 +23,7 @@ const BLOCK_REGEX = function flowTemplate(wwwName) { return ( - headerTemplate.replace(/^( \*\/)$/m, '* @flow strict\n$1') + + headerTemplate.replace(/^( \*\/)$/m, ' * @flow strict\n$1') + ` /** * ${wwwName} @@ -59,22 +59,7 @@ function updateFlowconfig(flowconfigPath = './.flowconfig') { const resolveRelative = (...subPaths) => '/' + path.relative(configDir, pkg.resolve(...subPaths)).replace(/^(?!\.)/, ''); - if (pkg.isPrivate()) { - if (pkg.getDirectoryName() !== 'shared') { - continue; - } - if (process.env.TODO_DOES_WWW_NEED_SHARED_FILES === '1') { - // Do these even work? These .js files aren't on disk and `npm run flow` - // passes without them. Code is left in for demonstration purposes if - // this is needed for www. - for (const {name, sourceFileName} of pkg.getPrivateModuleEntries()) { - emit( - name, - resolveRelative('src', sourceFileName.replace(/\.tsx?$/, '.js')), - ); - } - } - } else { + if (!pkg.isPrivate()) { for (const name of pkg.getExportedNpmModuleNames()) { const wwwName = npmToWwwName(name); const flowFile = `${wwwName}.js.flow`; @@ -85,6 +70,7 @@ function updateFlowconfig(flowconfigPath = './.flowconfig') { console.log( `Creating boilerplate ${resolvedFlowFile.replace(/^[^/]+\//, '')}`, ); + fs.mkdirsSync(path.dirname(flowFilePath)); fs.writeFileSync(flowFilePath, flowTemplate(wwwName)); } }