mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 23:26:16 +08:00
[Lexical] Add flow for eslint (#6127)
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
|
* @flow strict
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@ const BLOCK_REGEX =
|
|||||||
|
|
||||||
function flowTemplate(wwwName) {
|
function flowTemplate(wwwName) {
|
||||||
return (
|
return (
|
||||||
headerTemplate.replace(/^( \*\/)$/m, '* @flow strict\n$1') +
|
headerTemplate.replace(/^( \*\/)$/m, ' * @flow strict\n$1') +
|
||||||
`
|
`
|
||||||
/**
|
/**
|
||||||
* ${wwwName}
|
* ${wwwName}
|
||||||
@ -59,22 +59,7 @@ function updateFlowconfig(flowconfigPath = './.flowconfig') {
|
|||||||
const resolveRelative = (...subPaths) =>
|
const resolveRelative = (...subPaths) =>
|
||||||
'<PROJECT_ROOT>/' +
|
'<PROJECT_ROOT>/' +
|
||||||
path.relative(configDir, pkg.resolve(...subPaths)).replace(/^(?!\.)/, '');
|
path.relative(configDir, pkg.resolve(...subPaths)).replace(/^(?!\.)/, '');
|
||||||
if (pkg.isPrivate()) {
|
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 {
|
|
||||||
for (const name of pkg.getExportedNpmModuleNames()) {
|
for (const name of pkg.getExportedNpmModuleNames()) {
|
||||||
const wwwName = npmToWwwName(name);
|
const wwwName = npmToWwwName(name);
|
||||||
const flowFile = `${wwwName}.js.flow`;
|
const flowFile = `${wwwName}.js.flow`;
|
||||||
@ -85,6 +70,7 @@ function updateFlowconfig(flowconfigPath = './.flowconfig') {
|
|||||||
console.log(
|
console.log(
|
||||||
`Creating boilerplate ${resolvedFlowFile.replace(/^[^/]+\//, '')}`,
|
`Creating boilerplate ${resolvedFlowFile.replace(/^[^/]+\//, '')}`,
|
||||||
);
|
);
|
||||||
|
fs.mkdirsSync(path.dirname(flowFilePath));
|
||||||
fs.writeFileSync(flowFilePath, flowTemplate(wwwName));
|
fs.writeFileSync(flowFilePath, flowTemplate(wwwName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user