/**
 * ESLint flat config for alamin-donation-router.
 *
 * Extends the WordPress JavaScript coding standard (@wordpress/eslint-plugin)
 * and declares the plugin's browser globals. ESLint 9+/flat-config format.
 */

const wpPlugin = require( '@wordpress/eslint-plugin' );

module.exports = [
	// Never lint build output or dependencies.
	{
		ignores: [ '**/build/**', '**/node_modules/**', '**/vendor/**' ],
	},

	// WordPress recommended JavaScript standard.
	...wpPlugin.configs.recommended,

	// Plugin source: browser + jQuery globals and the localized data object.
	{
		files: [ 'src/**/*.js' ],
		languageOptions: {
			globals: {
				window: 'readonly',
				document: 'readonly',
				jQuery: 'readonly',
				adorAdmin: 'readonly',
			},
			parserOptions: {
				requireConfigFile: false,
				babelOptions: {
					presets: [
						require.resolve( '@wordpress/babel-preset-default' ),
					],
				},
			},
		},
		rules: {
			// This plugin renders in the classic admin and on the front end, not
			// inside a block-editor iframe, so document.activeElement is reliable.
			'@wordpress/no-global-active-element': 'off',
			// Native confirm() dialogs are the intended UX for destructive
			// admin actions (deactivate / bulk-deactivate / re-sync).
			'no-alert': 'off',
		},
	},
];
