From 38542e7ef6d21f1cc9e36bc85334db829b7411d9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:07:40 +0000 Subject: [PATCH 1/3] chore(deps): update eslint packages --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 06ae87f5a..40b7ce566 100644 --- a/package.json +++ b/package.json @@ -40,16 +40,16 @@ "@react-leaflet/core": "^2.1.0", "@testing-library/jest-dom": "6.6.3", "@testing-library/react": "15.0.7", - "eslint": "8.57.1", + "eslint": "9.15.0", "eslint-config-standard": "17.1.0", "eslint-config-standard-jsx": "11.0.0", "eslint-plugin-import": "2.31.0", - "eslint-plugin-jest": "27.9.0", + "eslint-plugin-jest": "28.9.0", "eslint-plugin-jsx-a11y": "6.10.2", - "eslint-plugin-n": "16.6.2", - "eslint-plugin-promise": "6.6.0", + "eslint-plugin-n": "17.14.0", + "eslint-plugin-promise": "7.2.1", "eslint-plugin-react": "7.37.2", - "eslint-plugin-react-hooks": "4.6.2", + "eslint-plugin-react-hooks": "5.0.0", "esquery": "1.6.0", "husky": "9.1.7", "jest": "29.7.0", From f219ffadd74c41f725c02385c36a70099e512bbf Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Wed, 27 Nov 2024 17:32:47 +0100 Subject: [PATCH 2/3] replace deprecated .eslintrc with eslint.config.mjs I tried to include all the rules and plugins from the old config as far as they are compatible with eslint 9. eslint-config-standard and eslint-config-standard-react seem to be dead and have been forked into neoconfig.The promise and n plugin is included in neoconfig afaik and doesn't need to be added explicitly. --- .eslintrc | 57 ----------------------------------------------- eslint.config.mjs | 50 +++++++++++++++++++++++++++++++++++++++++ package.json | 14 +++++------- 3 files changed, 56 insertions(+), 65 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 6714fd420..000000000 --- a/.eslintrc +++ /dev/null @@ -1,57 +0,0 @@ -{ - "parser": "@babel/eslint-parser", - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "requireConfigFile": false, - "ecmaFeatures": { - "experimentalObjectRestSpread": true - } - }, - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "jquery": true, - "jest/globals": true - }, - "extends": [ - "standard", - "standard-jsx", - "plugin:jsx-a11y/recommended", - "plugin:react/recommended", - "plugin:import/recommended", - "plugin:n/recommended", - "plugin:react-hooks/recommended", - "plugin:promise/recommended" - ], - "rules": { - "jsx-quotes": [2, "prefer-double"], - "jsx-a11y/no-onchange": "off", - "react/prop-types": "off", - "n/no-missing-require": "off", - "n/no-unsupported-features/es-syntax": "off", - "n/no-missing-import": "off", - "n/no-unpublished-import": "off", - "n/no-extraneous-import": "off", - "no-restricted-syntax": ["error", "TemplateLiteral"] - }, - "plugins": [ - "jsx-a11y", - "jest", - "promise" - ], - "ignorePatterns": [ - "node_modules/", - "venv/" - ], - "settings": { - "import/core-modules": [ django ], - "import/resolver": { - "node": { - "extensions": [".js", ".jsx"] - } - } - } -} - diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..54f3c4533 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,50 @@ +import globals from "globals"; +import hooksPlugin from "eslint-plugin-react-hooks"; +import importPlugin from "eslint-plugin-import"; +import jsxA11y from "eslint-plugin-jsx-a11y"; +import pluginJest from "eslint-plugin-jest"; +import pluginJs from "@eslint/js"; +import neostandard, { plugins } from "neostandard"; + +export default [ + ...neostandard(), + jsxA11y.flatConfigs.recommended, + importPlugin.flatConfigs.recommended, + { + files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx,jest.jsx,jest.js}"], + ignores: ["node_modules/", "venv/", "static/"], + languageOptions: { + ...jsxA11y.flatConfigs.recommended.languageOptions, + globals: { + ...globals.browser, + ...pluginJest.environments.globals.globals, + ...globals.jquery, + }, + ecmaVersion: "latest", + parserOptions: { + ecmaFeatures: { + jsx: true, + "experimentalObjectRestSpread": true, + }, + }, + }, + plugins: { + jest: pluginJest, + "react-hooks": hooksPlugin, + }, + rules: { + "no-restricted-syntax": ["error", "TemplateLiteral"], + "jsx-a11y/no-onchange": "off", + "@stylistic/jsx-quotes": [2, "prefer-double"], + ...hooksPlugin.configs.recommended.rules, + }, + settings: { + "import/core-modules": ["django"], + "import/resolver": { + node: { + extensions: [".js", ".jsx"], + }, + }, + }, + }, +]; diff --git a/package.json b/package.json index 40b7ce566..8f5bd4fe8 100644 --- a/package.json +++ b/package.json @@ -36,34 +36,32 @@ "@babel/plugin-transform-runtime": "7.25.9", "@babel/preset-env": "7.26.0", "@babel/preset-react": "7.25.9", + "@eslint/js": "9.13.0", "@maplibre/maplibre-gl-leaflet": "0.0.22", "@react-leaflet/core": "^2.1.0", "@testing-library/jest-dom": "6.6.3", "@testing-library/react": "15.0.7", "eslint": "9.15.0", - "eslint-config-standard": "17.1.0", - "eslint-config-standard-jsx": "11.0.0", "eslint-plugin-import": "2.31.0", "eslint-plugin-jest": "28.9.0", "eslint-plugin-jsx-a11y": "6.10.2", - "eslint-plugin-n": "17.14.0", - "eslint-plugin-promise": "7.2.1", - "eslint-plugin-react": "7.37.2", "eslint-plugin-react-hooks": "5.0.0", "esquery": "1.6.0", + "globals": "15.12.0", "husky": "9.1.7", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", - "lint-staged": "15.2.10" + "lint-staged": "15.2.10", + "neostandard": "0.11.7" }, "repository": { "type": "git", "url": "git@github.com:liqd/adhocracy4.git" }, "scripts": { - "lint": "eslint adhocracy4 --ext .js,.jsx", + "lint": "eslint adhocracy4", "lint-staged": "lint-staged", - "lint-fix": "eslint --fix --ext .js,.jsx .", + "lint-fix": "eslint --fix adhocracy4", "prepare": "husky", "test": "jest", "testDebug": "jest -o --coverage=false", From 4d39191e844813c3aab115a49a0b94dd58859e25 Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Wed, 27 Nov 2024 17:35:45 +0100 Subject: [PATCH 3/3] comments_async: fix some linting errors after the update of eslint --- .../static/comments_async/comment.jsx | 20 +++++++++++-------- .../static/comments_async/filter_category.jsx | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/adhocracy4/comments_async/static/comments_async/comment.jsx b/adhocracy4/comments_async/static/comments_async/comment.jsx index 55c800828..8e0382f17 100644 --- a/adhocracy4/comments_async/static/comments_async/comment.jsx +++ b/adhocracy4/comments_async/static/comments_async/comment.jsx @@ -207,20 +207,24 @@ export default class Comment extends React.Component { comment = (
{this.props.is_moderator_marked - ? + ? ( + + + {content} + + + ) + : ( {content} - // eslint-disable-line react/jsx-closing-tag-location - : - {content} - /* eslint-disable-line react/jsx-closing-tag-location */} + )}
) } diff --git a/adhocracy4/comments_async/static/comments_async/filter_category.jsx b/adhocracy4/comments_async/static/comments_async/filter_category.jsx index 435d90a03..2d4803d4a 100644 --- a/adhocracy4/comments_async/static/comments_async/filter_category.jsx +++ b/adhocracy4/comments_async/static/comments_async/filter_category.jsx @@ -40,6 +40,6 @@ export const FilterCategory = ({ })} - // eslint-disable-line react/jsx-closing-tag-location + ) }