Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade eslint to 9 #21918

Merged
merged 53 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6ab136a
Remove redundant config that is part of eslint/js/recommended
diedexx Nov 6, 2024
4d2b934
Remove explicitly disabled rules
diedexx Nov 6, 2024
6bec3d5
Remove redundant options that match the rule's defaults
diedexx Nov 6, 2024
76e41fb
Remove redundant and deprecated rule
diedexx Nov 13, 2024
7b935bb
Replace deprecated rules with their suggested replacement
diedexx Nov 13, 2024
e457c63
Group plugin rules together
diedexx Nov 13, 2024
929705c
Replace 1 and 2 with warn and error
diedexx Nov 13, 2024
4bae9a2
Update URLs refering to the old location of the package
diedexx Nov 13, 2024
9ff8a34
Add plugins that the config uses as dependencies
diedexx Nov 13, 2024
61c5adb
Update shared preset to a flat config
diedexx Nov 13, 2024
7cf8202
Lint the config file itself
diedexx Nov 28, 2024
b5406a4
Split off React specific config in a separate preset
diedexx Nov 28, 2024
f1838a1
Split off Node specific config in a separate preset
diedexx Nov 28, 2024
a2c54e3
Bake in support for Jest-based tests
diedexx Nov 29, 2024
8adb43c
Let the consumer define language options
diedexx Nov 29, 2024
6d2dc54
Let the React preset detect the version
diedexx Nov 29, 2024
2ef531e
Add type docs to config
diedexx Nov 29, 2024
a9ddba1
Tweak jsDoc rule settings
diedexx Nov 29, 2024
7f49404
Prefer @const over @constant
diedexx Dec 3, 2024
1e99ba2
Prevent having to eslint-ignore all long translation strings
diedexx Dec 3, 2024
e8929d4
Allow for testing side-effects of a constructor in tests
diedexx Dec 3, 2024
768273d
Allow for gradually solving existing complexity issues
diedexx Dec 3, 2024
f10ca9f
Allow for omitting jsdoc on (arrow) function expressions
diedexx Dec 5, 2024
0935820
Update helpers to a flat eslint config
diedexx Nov 29, 2024
a3acb5a
Update social-metadata-previews to a flat eslint config
diedexx Dec 5, 2024
a9f515f
Update ui-library to a flat eslint config
diedexx Dec 4, 2024
2757e3c
Update yoastseo to a flat eslint config
diedexx Dec 3, 2024
8aebacc
Autofix ESLint in yoastseo
diedexx Dec 3, 2024
ab34229
Fix remaining ESLint errors in yoastseo
diedexx Dec 3, 2024
906cbf1
Update social-metadata-forms to a flat eslint config
diedexx Dec 5, 2024
47490b0
Update social-metadata-previews to a flat eslint config
diedexx Dec 5, 2024
5d60025
Update replacement-variable-editor to a flat eslint config
diedexx Dec 5, 2024
89e892b
Update related-keyphrase-suggestions to a flat eslint config
diedexx Dec 5, 2024
cf69443
Update feature-flag to a flat eslint config
diedexx Dec 13, 2024
e8264b2
Update browserlist-config to a flag elsint config
diedexx Dec 13, 2024
d99b94e
Update analysis-report to use a flat eslint config
diedexx Dec 13, 2024
625f942
Update js to use a flat eslint config
diedexx Dec 9, 2024
507cb46
Fix new linting errors about React imports
diedexx Dec 9, 2024
013bf30
Autofix ESLint indentation issues
diedexx Dec 9, 2024
d1a76d5
Disallow prototype builtins
diedexx Dec 4, 2024
d25c500
Remove redundant disable comments
diedexx Dec 13, 2024
66c3352
Fix too long translator comments
diedexx Dec 13, 2024
bed7cc3
Update disable comments to use stylistic plugin
diedexx Dec 13, 2024
8a1cebe
Update components to a flat eslint config
diedexx Dec 13, 2024
22f0461
Fix serveral linting errors in components
diedexx Dec 13, 2024
e4b604f
Update root to use a fla eslint config
diedexx Dec 13, 2024
2072c8e
Upgrade all packages to eslint 9
diedexx Dec 13, 2024
49c0bf3
Restore rule that prevents having to build all js before linting
diedexx Dec 16, 2024
39fbcbd
Remove empty lines left by the autofixer
diedexx Dec 16, 2024
950d53e
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into upgrade-e…
diedexx Dec 24, 2024
3c88cc4
Bump the eslint-config-yoast version
diedexx Dec 27, 2024
5c8b085
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into upgrade-e…
diedexx Jan 7, 2025
bb46094
Fix newly introduced warnings after merge
diedexx Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

55 changes: 0 additions & 55 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion config/grunt/custom-tasks/sync-gutenberg-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function( grunt ) {
*
* @returns {void}
*/
function setVersion( file, pattern, version ) {
function setVersion( file, pattern, version ) {
const contents = grunt.file.read( file ).replace(
pattern,
version
Expand Down
40 changes: 40 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import globals from "globals";
import yoastConfig from "eslint-config-yoast";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: [ "js/dist", "packages", "apps", "artifact", "vendor", "vendor_prefixed", ".yarn" ] },
...yoastConfig,
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.browser,
},
},
rules: {
// Deviate from the Yoast config to prohibit dangling commas in functions.
"stylistic/comma-dangle": [
"error",
{
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
},
],

// Deviate from the Yoast config to allow for not using the error that is caught.
"no-unused-vars": [ "error", { caughtErrors: "none" } ],
},
},
{
files: [ "*.config.js", "config/**", "Gruntfile.js" ],
languageOptions: {
globals: {
...globals.node,
},
},
},
];
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@
"core-js": "^2.6.12",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"eslint": "^8.57.0",
"eslint-config-yoast": "^6.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint": "^9.16.0",
"eslint-config-yoast": "^7.0.0",
"globals": "^15.13.0",
"grunt-git": "^1.0.14",
"grunt-prompt": "^1.3.3",
"grunt-shell": "^3.0.1",
Expand Down
66 changes: 0 additions & 66 deletions packages/analysis-report/.eslintrc.js

This file was deleted.

55 changes: 55 additions & 0 deletions packages/analysis-report/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import globals from "globals";
import yoastConfig, { reactConfig } from "eslint-config-yoast";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: [ "build" ] },
...yoastConfig,
...reactConfig,
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.browser,
},
},
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",
{
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
},
],

// Deviate from the Yoast config to allow existing violations. New occurrences are still disallowed.
"react/jsx-no-bind": "warn",
},
},
{
files: [ "*.config.js", "tools/jest/**" ],
languageOptions: {
globals: {
...globals.node,
},
},
},
];
8 changes: 3 additions & 5 deletions packages/analysis-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
"@yoast/babel-preset": "^1.1.1",
"@yoast/jest-preset": "^1.0.1",
"babel-plugin-styled-components": "^2.0.6",
"eslint": "^8.57.0",
"eslint-config-yoast": "^6.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint": "^9.16.0",
"eslint-config-yoast": "^7.0.0",
"globals": "^15.13.0",
"jest": "^27.5.1",
"jest-styled-components": "^7.0.8",
"react-test-renderer": "^18.2.0"
Expand Down
1 change: 0 additions & 1 deletion packages/analysis-report/src/AnalysisResult.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable complexity */
import React, { useCallback, useEffect, useState } from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable require-jsdoc */
/* eslint-disable jsdoc/require-jsdoc */

import { sprintf, setLocaleData } from "@wordpress/i18n";

Expand Down
36 changes: 36 additions & 0 deletions packages/browserslist-config/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import globals from "globals";
import yoastConfig from "eslint-config-yoast";

/** @type {import('eslint').Linter.Config[]} */
export default [
...yoastConfig,
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.node,
},
},
rules: {
// Deviate from the Yoast config to prohibit dangling commas in functions.
"stylistic/comma-dangle": [
"error",
{
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
},
],
},
},
{
files: [ "*.config.*" ],
languageOptions: {
globals: {
...globals.node,
},
},
},
];
3 changes: 3 additions & 0 deletions packages/browserslist-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
},
"devDependencies": {
"browserslist": "^4.7.3",
"eslint": "^9.16.0",
"eslint-config-yoast": "^7.0.0",
"globals": "^15.13.0",
"jest": "^29.7.0"
}
}
55 changes: 55 additions & 0 deletions packages/components/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import globals from "globals";
import yoastConfig, { reactConfig } from "eslint-config-yoast";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: [ "build" ] },
...yoastConfig,
...reactConfig,
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.browser,
},
},
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",
{
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
},
],

// Deviate from the Yoast config to allow existing violations. New occurrences are still disallowed.
"react/jsx-no-bind": "warn",
},
},
{
files: [ "*.config.*", "jest/**" ],
languageOptions: {
globals: {
...globals.node,
},
},
},
];
5 changes: 4 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build:css": "postcss src/**/*.css --base src --dir build",
"clean": "rm -rf build",
"test": "jest",
"lint": "eslint . --max-warnings=0"
"lint": "eslint . --max-warnings=20"
},
"dependencies": {
"@wordpress/a11y": "^1.1.3",
Expand All @@ -48,6 +48,9 @@
"babel-plugin-styled-components": "^2.0.6",
"browserslist": "^4.7.3",
"cssnano": "^6.0.2",
"eslint": "^9.16.0",
"eslint-config-yoast": "^7.0.0",
"globals": "^15.13.0",
"jest": "^27.5.1",
"jest-styled-components": "^7.0.3",
"postcss": "^8.4.32",
Expand Down
Loading
Loading