|  | 
|  | 1 | +/** | 
|  | 2 | + * ESLint Configuration for Magento Project | 
|  | 3 | + * | 
|  | 4 | + * This configuration extends Magento, jQuery, and reset ESLint rules, | 
|  | 5 | + * while enforcing Magento coding standards using the `magento-coding-standard-eslint-plugin`. | 
|  | 6 | + * It uses FlatCompat to handle multiple config files in a modular way. | 
|  | 7 | + */ | 
|  | 8 | + | 
|  | 9 | +import { defineConfig } from "eslint/config"; | 
|  | 10 | +import magentoCodingStandardEslintPlugin from "magento-coding-standard-eslint-plugin"; | 
|  | 11 | +import path from "node:path"; | 
|  | 12 | +import { fileURLToPath } from "node:url"; | 
|  | 13 | +import js from "@eslint/js"; | 
|  | 14 | +import { FlatCompat } from "@eslint/eslintrc"; | 
|  | 15 | + | 
|  | 16 | +const __filename = fileURLToPath(import.meta.url); | 
|  | 17 | +const __dirname = path.dirname(__filename); | 
|  | 18 | +const compat = new FlatCompat({ | 
|  | 19 | +    baseDirectory: __dirname, | 
|  | 20 | +    recommendedConfig: js.configs.recommended, | 
|  | 21 | +    allConfig: js.configs.all | 
|  | 22 | +}); | 
|  | 23 | +export default defineConfig([{ | 
|  | 24 | +    extends: compat.extends( | 
|  | 25 | +        "./.eslintrc-reset", // Resets all rules before applying custom ones | 
|  | 26 | +        "./.eslintrc-magento", // Magento-specific coding standards | 
|  | 27 | +        "./.eslintrc-jquery", // jQuery-related ESLint Rules | 
|  | 28 | +        "./.eslintrc-misc", // Miscellaneous Rules | 
|  | 29 | +    ), | 
|  | 30 | +    plugins: { | 
|  | 31 | +        "magento-coding-standard-eslint-plugin": magentoCodingStandardEslintPlugin,  // This is in flat config format (object) | 
|  | 32 | +    } | 
|  | 33 | +}]); | 
0 commit comments