From 0abad23daae214ebb817981f882774f0b3f76567 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 2 Jan 2025 08:47:19 +0100 Subject: [PATCH] [upd] migrate .eslintrc.json to eslint.config.mjs The migration was done by the following steps, firts prepare the node enviroment an open a bash in this environment:: $ make clean nvm.nodejs ... $ ./manage nvm.bash $ which npx searxng/.nvm/versions/node/v23.5.0/bin/npx In this environment the migration command from [1] is started:: $ npx @eslint/migrate-config .eslintrc.json Need to install the following packages: @eslint/migrate-config@1.3.5 Migrating .eslintrc.json Wrote new config to ./eslint.config.mjs You will need to install the following packages to use the new config: - globals - @eslint/js - @eslint/eslintrc You can install them using the following command: npm install globals @eslint/js @eslint/eslintrc -D The following messages were generated during migration: - The 'node' environment is used, so switching sourceType to 'commonjs'. [1] https://eslint.org/docs/latest/use/configure/migration-guide#migrate-your-config-file Signed-off-by: Markus Heiser --- searx/static/themes/simple/.eslintrc.json | 28 -------- searx/static/themes/simple/eslint.config.mjs | 68 ++++++++++++++++++++ searx/static/themes/simple/gruntfile.js | 2 +- 3 files changed, 69 insertions(+), 29 deletions(-) delete mode 100644 searx/static/themes/simple/.eslintrc.json create mode 100644 searx/static/themes/simple/eslint.config.mjs diff --git a/searx/static/themes/simple/.eslintrc.json b/searx/static/themes/simple/.eslintrc.json deleted file mode 100644 index df53fcce8..000000000 --- a/searx/static/themes/simple/.eslintrc.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true, - "node": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 12 - }, - "rules": { - "indent": ["error", 2], - "keyword-spacing": ["error", { "before": true, "after": true }], - "no-trailing-spaces": 2, - "space-before-function-paren": ["error", "always"], - "space-infix-ops": "error", - "comma-spacing": ["error", { "before": false, "after": true }], - "brace-style": ["error", "1tbs", { "allowSingleLine": true }], - "curly": ["error", "multi-line"], - "block-spacing": ["error", "always"], - "dot-location": ["error", "property"], - "key-spacing": ["error", { "beforeColon": false, "afterColon": true }], - "spaced-comment": ["error", "always", { - "line": { "markers": ["*package", "!", "/", ",", "="] }, - "block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] } - }] - } -} diff --git a/searx/static/themes/simple/eslint.config.mjs b/searx/static/themes/simple/eslint.config.mjs new file mode 100644 index 000000000..747f6bfd4 --- /dev/null +++ b/searx/static/themes/simple/eslint.config.mjs @@ -0,0 +1,68 @@ +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [...compat.extends("eslint:recommended"), { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + + ecmaVersion: 12, + sourceType: "commonjs", + }, + + rules: { + indent: ["error", 2], + + "keyword-spacing": ["error", { + before: true, + after: true, + }], + + "no-trailing-spaces": 2, + "space-before-function-paren": ["error", "always"], + "space-infix-ops": "error", + + "comma-spacing": ["error", { + before: false, + after: true, + }], + + "brace-style": ["error", "1tbs", { + allowSingleLine: true, + }], + + curly: ["error", "multi-line"], + "block-spacing": ["error", "always"], + "dot-location": ["error", "property"], + + "key-spacing": ["error", { + beforeColon: false, + afterColon: true, + }], + + "spaced-comment": ["error", "always", { + line: { + markers: ["*package", "!", "/", ",", "="], + }, + + block: { + balanced: true, + markers: ["*package", "!", ",", ":", "::", "flow-include"], + exceptions: ["*"], + }, + }], + }, +}]; \ No newline at end of file diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js index c2cbad315..bd04b2468 100644 --- a/searx/static/themes/simple/gruntfile.js +++ b/searx/static/themes/simple/gruntfile.js @@ -35,7 +35,7 @@ module.exports = function (grunt) { }, eslint: { options: { - overrideConfigFile: '.eslintrc.json', + overrideConfigFile: 'eslint.config.mjs', failOnError: true, fix: grunt.option('fix') },