From 829a372e76c71b619d959e49d5d9b559272026b2 Mon Sep 17 00:00:00 2001 From: javierbrea Date: Tue, 5 Nov 2024 08:16:29 +0100 Subject: [PATCH] chore: Fix lint in module files --- eslint.config.mjs | 306 ++++++++++++++++++++++++++-------------------- 1 file changed, 176 insertions(+), 130 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 89d28e7..49c6a41 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,161 +6,207 @@ 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 _filename = fileURLToPath(import.meta.url); +const _dirname = path.dirname(_filename); const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all + baseDirectory: _dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, }); -export default [...compat.extends("prettier"), { - ignores: ["eslint.config.mjs"], -}, -{ +export default [ + ...compat.extends("prettier"), + { plugins: { - prettier, - "local-rules": localRules, + prettier, + "local-rules": localRules, }, languageOptions: { - globals: { - ...globals.node, - }, + globals: { + ...globals.node, + }, - ecmaVersion: 2022, - sourceType: "commonjs", + ecmaVersion: 2022, + sourceType: "commonjs", }, rules: { - "prettier/prettier": ["error", { - printWidth: 99, - parser: "flow", - }], - - "no-shadow": [2, { - builtinGlobals: true, - hoist: "all", - }], - - "no-undef": "error", - - "no-unused-vars": ["error", { - vars: "all", - args: "after-used", - ignoreRestSiblings: false, - }], + "prettier/prettier": [ + "error", + { + printWidth: 99, + parser: "flow", + }, + ], + + "no-shadow": [ + 2, + { + builtinGlobals: true, + hoist: "all", + }, + ], + + "no-undef": "error", + + "no-unused-vars": [ + "error", + { + vars: "all", + args: "after-used", + ignoreRestSiblings: false, + }, + ], }, -}, { + }, + { + files: ["**/*.mjs"], + languageOptions: { + ecmaVersion: 2022, + sourceType: "module", + }, + }, + { files: ["src/**/*.js"], settings: { - "boundaries/dependency-nodes": ["require", "import", "dynamic-import", "export"], - - "boundaries/elements": [{ - type: "config", - mode: "file", - pattern: ["src/configs/*.js", "(package.json)"], - capture: ["name"], - }, { - type: "constants", - mode: "file", - pattern: "src/constants/*.js", - capture: ["name"], - }, { - type: "core", - mode: "file", - pattern: "src/core/*.js", - capture: ["name"], - }, { - type: "helper", - mode: "file", - pattern: "src/helpers/*.js", - capture: ["name"], - }, { - type: "rule", - mode: "file", - pattern: "src/rules/*.js", - capture: ["name"], - }, { - type: "rule-factory", - mode: "file", - pattern: "src/rules-factories/*.js", - capture: ["name"], - }, { - type: "plugin", - mode: "full", - pattern: ["src/index.js"], - }], + "boundaries/dependency-nodes": ["require", "import", "dynamic-import", "export"], + + "boundaries/elements": [ + { + type: "config", + mode: "file", + pattern: ["src/configs/*.js", "(package.json)"], + capture: ["name"], + }, + { + type: "constants", + mode: "file", + pattern: "src/constants/*.js", + capture: ["name"], + }, + { + type: "core", + mode: "file", + pattern: "src/core/*.js", + capture: ["name"], + }, + { + type: "helper", + mode: "file", + pattern: "src/helpers/*.js", + capture: ["name"], + }, + { + type: "rule", + mode: "file", + pattern: "src/rules/*.js", + capture: ["name"], + }, + { + type: "rule-factory", + mode: "file", + pattern: "src/rules-factories/*.js", + capture: ["name"], + }, + { + type: "plugin", + mode: "full", + pattern: ["src/index.js"], + }, + ], }, rules: { - "local-rules/boundaries/element-types": [2, { - default: "disallow", - - rules: [{ - from: "plugin", - allow: ["constants", "config", "rule"], - }, { - from: "config", - allow: ["constants", "config"], - }, { - from: "constants", - allow: ["constants"], - }, { - from: "core", - allow: ["constants", "helper", "core"], - }, { - from: "helper", - allow: ["constants", "helper"], - }, { - from: "rule", - allow: ["constants", "helper", "core", "rule-factory"], - }, { - from: "rule-factory", - allow: ["constants", "helper", "core"], - }], - }], - - "local-rules/boundaries/no-unknown": [2], - "local-rules/boundaries/no-unknown-files": [2], - }, -}, { + "local-rules/boundaries/element-types": [ + 2, + { + default: "disallow", + + rules: [ + { + from: "plugin", + allow: ["constants", "config", "rule"], + }, + { + from: "config", + allow: ["constants", "config"], + }, + { + from: "constants", + allow: ["constants"], + }, + { + from: "core", + allow: ["constants", "helper", "core"], + }, + { + from: "helper", + allow: ["constants", "helper"], + }, + { + from: "rule", + allow: ["constants", "helper", "core", "rule-factory"], + }, + { + from: "rule-factory", + allow: ["constants", "helper", "core"], + }, + ], + }, + ], + + "local-rules/boundaries/no-unknown": [2], + "local-rules/boundaries/no-unknown-files": [2], + }, + }, + { files: ["test/src/**/*.js"], plugins: { - prettier + prettier, }, languageOptions: { - globals: { - ...globals.node, - describe: "readonly", - it: "readonly", - expect: "readonly", - }, - - ecmaVersion: 2022, - sourceType: "commonjs", + globals: { + ...globals.node, + describe: "readonly", + it: "readonly", + expect: "readonly", + }, + + ecmaVersion: 2022, + sourceType: "commonjs", }, rules: { - "prettier/prettier": ["error", { - printWidth: 99, - parser: "flow", - }], - - "no-shadow": [2, { - builtinGlobals: true, - hoist: "all", - }], - - "no-undef": "error", - - "no-unused-vars": ["error", { - vars: "all", - args: "after-used", - ignoreRestSiblings: false, - }], + "prettier/prettier": [ + "error", + { + printWidth: 99, + parser: "flow", + }, + ], + + "no-shadow": [ + 2, + { + builtinGlobals: true, + hoist: "all", + }, + ], + + "no-undef": "error", + + "no-unused-vars": [ + "error", + { + vars: "all", + args: "after-used", + ignoreRestSiblings: false, + }, + ], }, -}]; + }, +];