mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 03:29:11 +02:00
refactor(blog): theme-common shouldn't depend on blog content plugins (#10313)
This commit is contained in:
parent
7544a2373d
commit
61d6858864
29 changed files with 111 additions and 76 deletions
52
.eslintrc.js
vendored
52
.eslintrc.js
vendored
|
@ -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
|
||||
[
|
||||
'../**',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue