diff --git a/packages/analysis-report/eslint.config.mjs b/packages/analysis-report/eslint.config.mjs index 6217b3cbba1..5123bd756cb 100644 --- a/packages/analysis-report/eslint.config.mjs +++ b/packages/analysis-report/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/components/eslint.config.mjs b/packages/components/eslint.config.mjs index f0085c33ec4..e71e4079381 100644 --- a/packages/components/eslint.config.mjs +++ b/packages/components/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/js/eslint.config.mjs b/packages/js/eslint.config.mjs index 947caf6da42..8ccb8b61c53 100644 --- a/packages/js/eslint.config.mjs +++ b/packages/js/eslint.config.mjs @@ -23,12 +23,13 @@ export default [ ignore: [ // This is our internal externals used within `packages/js`, not actually a package. "^@yoast/externals/(components|contexts|redux)$", - // Ignore UI library and schema-blocks, or we have to build the code before linting. - // Because `main` in `package.json` points to the `build/index.js` (in the UI library), which is not present before building. - // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. - "^@yoast/(ui-library|schema-blocks|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + // Externals provided by @wordpress/dependency-extraction-webpack-plugin "^@wordpress/(annotations|api|edit-post|sanitize)$", "^jquery$", + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", "yoastseo", ], }, diff --git a/packages/related-keyphrase-suggestions/eslint.config.mjs b/packages/related-keyphrase-suggestions/eslint.config.mjs index 8e412907c38..d555c72cf3c 100644 --- a/packages/related-keyphrase-suggestions/eslint.config.mjs +++ b/packages/related-keyphrase-suggestions/eslint.config.mjs @@ -15,6 +15,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to allow use of short-circuit and ternary expressions to call functions with side effects, like setState. "no-unused-expressions": [ "error", diff --git a/packages/replacement-variable-editor/eslint.config.mjs b/packages/replacement-variable-editor/eslint.config.mjs index e69d9a907da..fbac5174165 100644 --- a/packages/replacement-variable-editor/eslint.config.mjs +++ b/packages/replacement-variable-editor/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/search-metadata-previews/eslint.config.mjs b/packages/search-metadata-previews/eslint.config.mjs index d7d41869d30..a7003ffc04d 100644 --- a/packages/search-metadata-previews/eslint.config.mjs +++ b/packages/search-metadata-previews/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/social-metadata-forms/eslint.config.mjs b/packages/social-metadata-forms/eslint.config.mjs index d3ec5aa28e9..06dcb4ee773 100644 --- a/packages/social-metadata-forms/eslint.config.mjs +++ b/packages/social-metadata-forms/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/social-metadata-previews/eslint.config.mjs b/packages/social-metadata-previews/eslint.config.mjs index 42916411f57..92bc5287cb3 100644 --- a/packages/social-metadata-previews/eslint.config.mjs +++ b/packages/social-metadata-previews/eslint.config.mjs @@ -14,6 +14,20 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", diff --git a/packages/yoastseo/eslint.config.mjs b/packages/yoastseo/eslint.config.mjs index 3ca7beb31b7..b1c2c8c6dde 100644 --- a/packages/yoastseo/eslint.config.mjs +++ b/packages/yoastseo/eslint.config.mjs @@ -13,6 +13,22 @@ export default [ }, }, rules: { + // Account for webpack externals and potentially unbuilt packages in the monorepo setup. + "import/no-unresolved": [ + "error", + { + ignore: [ + // Ignore @yoast packages from this workspace, or we have to build the code before linting. + // Because `main` in `package.json` points to the `build/index.js`, which is not present before building. + // As we are dealing with our source, not the actual NPM download, due to the monorepo setup. + "^@yoast/(ui-library|style-guide|components|helpers|search-metadata-previews|social-metadata-forms|replacement-variable-editor|analysis-report|feature-flag|related-keyphrase-suggestions)$", + "yoastseo", + // Ignore imports from premium-configuration, which might not be available in all environments. + "premium-configuration/data/morphologyData", + ], + }, + ], + // Deviate from the Yoast config to prohibit dangling commas in functions. "stylistic/comma-dangle": [ "error", @@ -45,9 +61,6 @@ export default [ // We sometimes export a value as both a named export and a default export. "import/no-named-as-default": "off", - // Deviate from the Yoast config to ignore imports from premium-configuration, which might not be available in all environments. - "import/no-unresolved": [ "error", { ignore: [ "premium-configuration/data/morphologyData" ] } ], - // Deviate from the Yoast config to allow for not using the error that is caught. "no-unused-vars": [ "error", { caughtErrors: "none" } ], },