refactor(blog): theme-common shouldn't depend on blog content plugins (#10313)

This commit is contained in:
Sébastien Lorber 2024-07-19 15:55:35 +02:00 committed by GitHub
parent 7544a2373d
commit 61d6858864
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 111 additions and 76 deletions

52
.eslintrc.js vendored
View file

@ -9,16 +9,18 @@ const OFF = 0;
const WARNING = 1;
const ERROR = 2;
const ClientRestrictedImportPatterns = [
// Prevent importing lodash in client bundle for bundle size
'lodash',
'lodash.**',
'lodash/**',
// Prevent importing server code in client bundle
'**/../babel/**',
'**/../server/**',
'**/../commands/**',
'**/../webpack/**',
// Prevent importing lodash, usually for browser bundle size reasons
const LodashImportPatterns = ['lodash', 'lodash.**', 'lodash/**'];
// Prevent importing content plugins, usually for coupling reasons
const ContentPluginsImportPatterns = [
'@docusaurus/plugin-content-blog',
'@docusaurus/plugin-content-blog/**',
// TODO fix theme-common => docs dependency issue
// '@docusaurus/plugin-content-docs',
// '@docusaurus/plugin-content-docs/**',
'@docusaurus/plugin-content-pages',
'@docusaurus/plugin-content-pages/**',
];
module.exports = {
@ -408,7 +410,33 @@ module.exports = {
'no-restricted-imports': [
'error',
{
patterns: ClientRestrictedImportPatterns,
patterns: [
...LodashImportPatterns,
...ContentPluginsImportPatterns,
// Prevent importing server code in client bundle
'**/../babel/**',
'**/../server/**',
'**/../commands/**',
'**/../webpack/**',
],
},
],
},
},
{
files: [
'packages/docusaurus-theme-common/src/**/*.{js,ts,tsx}',
'packages/docusaurus-utils-common/src/**/*.{js,ts,tsx}',
],
excludedFiles: '*.test.{js,ts,tsx}',
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
...LodashImportPatterns,
...ContentPluginsImportPatterns,
],
},
],
},
@ -420,7 +448,7 @@ module.exports = {
'no-restricted-imports': [
'error',
{
patterns: ClientRestrictedImportPatterns.concat(
patterns: LodashImportPatterns.concat(
// Prevents relative imports between React theme components
[
'../**',