Skip to content

Commit

Permalink
Merge pull request #21918 from Yoast/upgrade-eslint-to-9
Browse files Browse the repository at this point in the history
Upgrade eslint to 9
  • Loading branch information
mykola authored Jan 8, 2025
2 parents 53fe2f2 + bb46094 commit 0c73abc
Show file tree
Hide file tree
Showing 245 changed files with 1,825 additions and 1,659 deletions.
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

0 comments on commit 0c73abc

Please sign in to comment.