-
-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into fix/editing-event
- Loading branch information
Showing
109 changed files
with
566 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
common/shared/eslint/plugins/no-facade-imports-outside-facade.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// no-facade-imports-outside-facade.js | ||
const path = require('node:path'); | ||
|
||
const rule = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'Disallow imports containing facade in non-facade files', | ||
}, | ||
messages: { | ||
noFacadeImports: 'Imports containing "facade" are not allowed in non-facade files: "{{importPath}}"', | ||
}, | ||
}, | ||
|
||
create(context) { | ||
const filename = context.getFilename(); | ||
const normalizedPath = filename.split(path.sep).join('/'); | ||
|
||
const isInPackages = normalizedPath.includes('/packages/'); | ||
const isInFacade = normalizedPath.includes('/facade/'); | ||
|
||
if (!isInPackages || isInFacade) { | ||
return {}; | ||
} | ||
|
||
// get parent dir | ||
const parentDirMatch = normalizedPath.match(/\/([^/]+)\/packages\//); | ||
if (!parentDirMatch) { | ||
return {}; | ||
} | ||
|
||
const parentDir = parentDirMatch[1]; | ||
const packagePrefix = parentDir === 'univer' | ||
? '@univerjs/' : | ||
parentDir === 'univer-pro' | ||
? '@univerjs-pro/' : | ||
null; | ||
|
||
if (!packagePrefix) { | ||
return {}; | ||
} | ||
|
||
return { | ||
ImportDeclaration(node) { | ||
const importPath = node.source.value; | ||
|
||
// Check if the import path contains 'facade' | ||
if (importPath.includes('facade')) { | ||
context.report({ | ||
node, | ||
messageId: 'noFacadeImports', | ||
data: { importPath }, | ||
}); | ||
} | ||
}, | ||
ExportNamedDeclaration(node) { | ||
if (node.source) { | ||
const exportPath = node.source.value; | ||
if (exportPath.includes('facade')) { | ||
context.report({ | ||
node, | ||
messageId: 'noFacadeImports', | ||
data: { importPath: exportPath }, | ||
}); | ||
} | ||
} | ||
}, | ||
ExportAllDeclaration(node) { | ||
const exportPath = node.source.value; | ||
if (exportPath.includes('facade')) { | ||
context.report({ | ||
node, | ||
messageId: 'noFacadeImports', | ||
data: { importPath: exportPath }, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
module.exports = rule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.